fix(staff_home): fix compilation errors
- Removed flutter_riverpod dependency and usage - Removed go_router dependency and usage (replaced with Modular) - Fixed syntax errors in WorkerHomePage - Updated dependencies (google_fonts, intl) - Fixed undefined identifier errors by moving localization access - Removed unused methods in ShiftCard
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:lucide_icons/lucide_icons.dart';
|
import 'package:lucide_icons/lucide_icons.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:core_localization/core_localization.dart';
|
import 'package:core_localization/core_localization.dart';
|
||||||
import 'package:flutter_modular/flutter_modular.dart';
|
import 'package:flutter_modular/flutter_modular.dart';
|
||||||
|
|
||||||
|
import 'package:staff_home/src/presentation/navigation/home_navigator.dart';
|
||||||
import 'package:staff_home/src/theme.dart';
|
import 'package:staff_home/src/theme.dart';
|
||||||
import 'package:staff_home/src/presentation/widgets/shift_card.dart';
|
import 'package:staff_home/src/presentation/widgets/shift_card.dart';
|
||||||
import 'package:staff_home/src/presentation/widgets/worker/auto_match_toggle.dart';
|
import 'package:staff_home/src/presentation/widgets/worker/auto_match_toggle.dart';
|
||||||
@@ -17,27 +16,24 @@ import 'package:staff_home/src/domain/models/shift.dart';
|
|||||||
import 'package:staff_home/src/presentation/blocs/home_cubit.dart';
|
import 'package:staff_home/src/presentation/blocs/home_cubit.dart';
|
||||||
import 'package:staff_home/src/data/repositories/home_repository_impl.dart';
|
import 'package:staff_home/src/data/repositories/home_repository_impl.dart';
|
||||||
|
|
||||||
class WorkerHomePage extends ConsumerStatefulWidget {
|
class WorkerHomePage extends StatefulWidget {
|
||||||
const WorkerHomePage({super.key});
|
const WorkerHomePage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<WorkerHomePage> createState() => _WorkerHomePageState();
|
State<WorkerHomePage> createState() => _WorkerHomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _WorkerHomePageState extends ConsumerState<WorkerHomePage> {
|
class _WorkerHomePageState extends State<WorkerHomePage> {
|
||||||
bool _autoMatchEnabled = false;
|
bool _autoMatchEnabled = false;
|
||||||
final bool _isProfileComplete = false; // Added for mock profile completion
|
final bool _isProfileComplete = false; // Added for mock profile completion
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final i18n = t.staff.home;
|
final i18n = t.staff.home;
|
||||||
final headerI18n = i18n.header;
|
|
||||||
final bannersI18n = i18n.banners;
|
final bannersI18n = i18n.banners;
|
||||||
final quickI18n = i18n.quick_actions;
|
final quickI18n = i18n.quick_actions;
|
||||||
final sectionsI18n = i18n.sections;
|
final sectionsI18n = i18n.sections;
|
||||||
final emptyI18n = i18n.empty_states;
|
final emptyI18n = i18n.empty_states;
|
||||||
final pendingI18n = i18n.pending_payment;
|
|
||||||
final recI18n = i18n.recommended_card;
|
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => HomeCubit(
|
create: (_) => HomeCubit(
|
||||||
// provide repository implementation backed by mock service for now
|
// provide repository implementation backed by mock service for now
|
||||||
@@ -135,9 +131,8 @@ class _WorkerHomePageState extends ConsumerState<WorkerHomePage> {
|
|||||||
_buildSectionHeader(
|
_buildSectionHeader(
|
||||||
sectionsI18n.todays_shift,
|
sectionsI18n.todays_shift,
|
||||||
shifts.isNotEmpty
|
shifts.isNotEmpty
|
||||||
? sectionsI18n.scheduled_count.replaceAll(
|
? sectionsI18n.scheduled_count(
|
||||||
r'$count',
|
count: shifts.length,
|
||||||
'${shifts.length}',
|
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
@@ -359,6 +354,7 @@ class _WorkerHomePageState extends ConsumerState<WorkerHomePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHeader() {
|
Widget _buildHeader() {
|
||||||
|
final headerI18n = t.staff.home.header;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(20, 24, 20, 16),
|
padding: const EdgeInsets.fromLTRB(20, 24, 20, 16),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -565,8 +561,9 @@ class _WorkerHomePageState extends ConsumerState<WorkerHomePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildPendingPaymentCard() {
|
Widget _buildPendingPaymentCard() {
|
||||||
|
final pendingI18n = t.staff.home.pending_payment;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => context.go('/payments'),
|
onTap: () => Modular.to.pushPayments(),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -650,6 +647,7 @@ class _WorkerHomePageState extends ConsumerState<WorkerHomePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildRecommendedCard(Shift shift) {
|
Widget _buildRecommendedCard(Shift shift) {
|
||||||
|
final recI18n = t.staff.home.recommended_card;
|
||||||
final duration = 8;
|
final duration = 8;
|
||||||
final totalPay = duration * shift.hourlyRate;
|
final totalPay = duration * shift.hourlyRate;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
@@ -657,7 +655,7 @@ class _WorkerHomePageState extends ConsumerState<WorkerHomePage> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
recI18n.applied_for.replaceAll(r'$title', shift.title),
|
recI18n.applied_for(title: shift.title),
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
duration: const Duration(seconds: 2),
|
duration: const Duration(seconds: 2),
|
||||||
@@ -810,9 +808,7 @@ class _WorkerHomePageState extends ConsumerState<WorkerHomePage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
recI18n.time_range
|
recI18n.time_range(start: shift.startTime, end: shift.endTime),
|
||||||
.replaceAll(r'$start', shift.startTime)
|
|
||||||
.replaceAll(r'$end', shift.endTime),
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppColors.krowMuted,
|
color: AppColors.krowMuted,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:flutter_modular/flutter_modular.dart';
|
||||||
import 'package:lucide_icons/lucide_icons.dart';
|
import 'package:lucide_icons/lucide_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
@@ -65,24 +65,6 @@ class _ShiftCardState extends State<ShiftCard> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> _calculateDuration() {
|
|
||||||
if (widget.shift.startTime.isEmpty || widget.shift.endTime.isEmpty) {
|
|
||||||
return {'hours': 0, 'breakTime': '1 hour'};
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final startParts = widget.shift.startTime
|
|
||||||
.split(':')
|
|
||||||
.map(int.parse)
|
|
||||||
.toList();
|
|
||||||
final endParts = widget.shift.endTime.split(':').map(int.parse).toList();
|
|
||||||
double hours =
|
|
||||||
(endParts[0] - startParts[0]) + (endParts[1] - startParts[1]) / 60;
|
|
||||||
if (hours < 0) hours += 24;
|
|
||||||
return {'hours': hours.round(), 'breakTime': '1 hour'};
|
|
||||||
} catch (e) {
|
|
||||||
return {'hours': 0, 'breakTime': '1 hour'};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -92,9 +74,9 @@ class _ShiftCardState extends State<ShiftCard> {
|
|||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
setState(() => isExpanded = !isExpanded);
|
setState(() => isExpanded = !isExpanded);
|
||||||
GoRouter.of(context).push(
|
Modular.to.pushNamed(
|
||||||
'/shift-details/${widget.shift.id}',
|
'/shift-details/${widget.shift.id}',
|
||||||
extra: widget.shift,
|
arguments: widget.shift,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -458,40 +440,5 @@ class _ShiftCardState extends State<ShiftCard> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDetailRow(IconData icon, String label, bool? value) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
border: Border(bottom: BorderSide(color: AppColors.krowBorder)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(icon, size: 16, color: AppColors.krowMuted),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
label,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: AppColors.krowMuted,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
value == true ? 'Yes' : 'No',
|
|
||||||
style: TextStyle(
|
|
||||||
color: value == true
|
|
||||||
? const Color(0xFF10B981)
|
|
||||||
: AppColors.krowMuted,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_modular/flutter_modular.dart';
|
||||||
import 'package:lucide_icons/lucide_icons.dart';
|
import 'package:lucide_icons/lucide_icons.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:core_localization/core_localization.dart';
|
import 'package:core_localization/core_localization.dart';
|
||||||
@@ -19,7 +19,7 @@ class BenefitsWidget extends StatelessWidget {
|
|||||||
border: Border.all(color: Colors.grey.shade100),
|
border: Border.all(color: Colors.grey.shade100),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black.withOpacity(0.05),
|
color: Colors.black.withValues(alpha: 0.05),
|
||||||
blurRadius: 2,
|
blurRadius: 2,
|
||||||
offset: const Offset(0, 1),
|
offset: const Offset(0, 1),
|
||||||
),
|
),
|
||||||
@@ -38,7 +38,7 @@ class BenefitsWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => context.push('/benefits'),
|
onTap: () => Modular.to.pushNamed('/benefits'),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:flutter_modular/flutter_modular.dart';
|
||||||
import 'package:core_localization/core_localization.dart';
|
import 'package:core_localization/core_localization.dart';
|
||||||
|
|
||||||
class ImproveYourselfWidget extends StatelessWidget {
|
class ImproveYourselfWidget extends StatelessWidget {
|
||||||
@@ -51,7 +51,7 @@ class ImproveYourselfWidget extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _buildCard(BuildContext context, Map<String, String> item) {
|
Widget _buildCard(BuildContext context, Map<String, String> item) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => context.push(item['page']!),
|
onTap: () => Modular.to.pushNamed(item['page']!),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 160,
|
width: 160,
|
||||||
margin: const EdgeInsets.only(right: 12),
|
margin: const EdgeInsets.only(right: 12),
|
||||||
@@ -61,7 +61,7 @@ class ImproveYourselfWidget extends StatelessWidget {
|
|||||||
border: Border.all(color: Colors.grey.shade100),
|
border: Border.all(color: Colors.grey.shade100),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black.withOpacity(0.05),
|
color: Colors.black.withValues(alpha: 0.05),
|
||||||
blurRadius: 2,
|
blurRadius: 2,
|
||||||
offset: const Offset(0, 1),
|
offset: const Offset(0, 1),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:flutter_modular/flutter_modular.dart';
|
||||||
import 'package:core_localization/core_localization.dart';
|
import 'package:core_localization/core_localization.dart';
|
||||||
|
|
||||||
class MoreWaysToUseKrowWidget extends StatelessWidget {
|
class MoreWaysToUseKrowWidget extends StatelessWidget {
|
||||||
@@ -49,7 +49,7 @@ class MoreWaysToUseKrowWidget extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _buildCard(BuildContext context, Map<String, String> item) {
|
Widget _buildCard(BuildContext context, Map<String, String> item) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => context.push(item['page']!),
|
onTap: () => Modular.to.pushNamed(item['page']!),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 160,
|
width: 160,
|
||||||
margin: const EdgeInsets.only(right: 12),
|
margin: const EdgeInsets.only(right: 12),
|
||||||
@@ -59,7 +59,7 @@ class MoreWaysToUseKrowWidget extends StatelessWidget {
|
|||||||
border: Border.all(color: Colors.grey.shade100),
|
border: Border.all(color: Colors.grey.shade100),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black.withOpacity(0.05),
|
color: Colors.black.withValues(alpha: 0.05),
|
||||||
blurRadius: 2,
|
blurRadius: 2,
|
||||||
offset: const Offset(0, 1),
|
offset: const Offset(0, 1),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_bloc: ^8.1.0
|
flutter_bloc: ^8.1.0
|
||||||
|
bloc: ^8.1.0
|
||||||
flutter_modular: ^6.3.0
|
flutter_modular: ^6.3.0
|
||||||
equatable: ^2.0.5
|
equatable: ^2.0.5
|
||||||
lucide_icons: ^0.257.0
|
lucide_icons: ^0.257.0
|
||||||
intl: ^0.20.0
|
intl: ^0.20.0
|
||||||
|
google_fonts: ^7.0.0
|
||||||
|
|
||||||
# Architecture Packages
|
# Architecture Packages
|
||||||
design_system:
|
design_system:
|
||||||
|
|||||||
Reference in New Issue
Block a user