feat: implement staff availability, clock-in, payments and fix UI navigation
This commit is contained in:
@@ -16,16 +16,15 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
|
||||
int newIndex = state.currentIndex;
|
||||
|
||||
// Detect which tab is active based on the route path
|
||||
// Using contains() to handle child routes and trailing slashes
|
||||
if (path.contains(StaffMainRoutes.shiftsFull)) {
|
||||
newIndex = 0;
|
||||
} else if (path.contains(StaffMainRoutes.paymentsFull)) {
|
||||
newIndex = 1;
|
||||
} else if (path.contains(StaffMainRoutes.homeFull)) {
|
||||
newIndex = 2;
|
||||
} else if (path.contains(StaffMainRoutes.clockInFull)) {
|
||||
if (path.contains('/clock-in')) {
|
||||
newIndex = 3;
|
||||
} else if (path.contains(StaffMainRoutes.profileFull)) {
|
||||
} else if (path.contains('/payments')) {
|
||||
newIndex = 1;
|
||||
} else if (path.contains('/home')) {
|
||||
newIndex = 2;
|
||||
} else if (path.contains('/shifts')) {
|
||||
newIndex = 0;
|
||||
} else if (path.contains('/profile')) {
|
||||
newIndex = 4;
|
||||
}
|
||||
|
||||
@@ -37,6 +36,9 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
|
||||
void navigateToTab(int index) {
|
||||
if (index == state.currentIndex) return;
|
||||
|
||||
// Optimistically update the tab index for instant feedback
|
||||
emit(state.copyWith(currentIndex: index));
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
Modular.to.navigateToShifts();
|
||||
@@ -54,7 +56,6 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
|
||||
Modular.to.navigateToProfile();
|
||||
break;
|
||||
}
|
||||
// State update will happen via _onRouteChanged
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -17,8 +17,8 @@ class StaffMainPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<StaffMainCubit>(
|
||||
create: (BuildContext context) => Modular.get<StaffMainCubit>(),
|
||||
return BlocProvider<StaffMainCubit>.value(
|
||||
value: Modular.get<StaffMainCubit>(),
|
||||
child: Scaffold(
|
||||
extendBody: true,
|
||||
body: const RouterOutlet(),
|
||||
|
||||
@@ -73,10 +73,10 @@ class StaffMainModule extends Module {
|
||||
'/time-card',
|
||||
module: StaffTimeCardModule(),
|
||||
);
|
||||
r.module('/availability', module: StaffAvailabilityModule());
|
||||
r.module(
|
||||
'/clock-in',
|
||||
module: StaffClockInModule(),
|
||||
'/availability',
|
||||
module: StaffAvailabilityModule(),
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ dependencies:
|
||||
path: ../availability
|
||||
staff_clock_in:
|
||||
path: ../clock_in
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user