From 630b90ee38511b7bbdd367820d77b257bcd7e542 Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Tue, 3 Mar 2026 21:35:59 -0500 Subject: [PATCH] feat: Implement show/hide functionality for bottom navigation bar based on route changes --- .../lib/src/presentation/blocs/staff_main_cubit.dart | 10 ++++++++-- .../lib/src/presentation/blocs/staff_main_state.dart | 11 +++++++++-- .../lib/src/presentation/pages/staff_main_page.dart | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart index 814b5932..6e10209b 100644 --- a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart +++ b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart @@ -17,6 +17,10 @@ class StaffMainCubit extends Cubit implements Disposable { final GetProfileCompletionUseCase _getProfileCompletionUsecase; bool _isLoadingCompletion = false; + static const List _hideBottomPaths = [ + StaffPaths.benefits, + ]; + void _onRouteChanged() { if (isClosed) return; @@ -40,8 +44,10 @@ class StaffMainCubit extends Cubit implements Disposable { newIndex = 4; } - if (newIndex != state.currentIndex) { - emit(state.copyWith(currentIndex: newIndex)); + final bool showBottomBar = !_hideBottomPaths.any(path.contains); + + if (newIndex != state.currentIndex || showBottomBar != state.showBottomBar) { + emit(state.copyWith(currentIndex: newIndex, showBottomBar: showBottomBar)); } } diff --git a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_state.dart b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_state.dart index 0903b877..86667bfd 100644 --- a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_state.dart +++ b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_state.dart @@ -4,18 +4,25 @@ class StaffMainState extends Equatable { const StaffMainState({ this.currentIndex = 2, // Default to Home this.isProfileComplete = false, + this.showBottomBar = true, }); final int currentIndex; final bool isProfileComplete; + final bool showBottomBar; - StaffMainState copyWith({int? currentIndex, bool? isProfileComplete}) { + StaffMainState copyWith({ + int? currentIndex, + bool? isProfileComplete, + bool? showBottomBar, + }) { return StaffMainState( currentIndex: currentIndex ?? this.currentIndex, isProfileComplete: isProfileComplete ?? this.isProfileComplete, + showBottomBar: showBottomBar ?? this.showBottomBar, ); } @override - List get props => [currentIndex, isProfileComplete]; + List get props => [currentIndex, isProfileComplete, showBottomBar]; } diff --git a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/pages/staff_main_page.dart b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/pages/staff_main_page.dart index 10ae9f8f..bfcae589 100644 --- a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/pages/staff_main_page.dart +++ b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/pages/staff_main_page.dart @@ -24,6 +24,7 @@ class StaffMainPage extends StatelessWidget { body: const RouterOutlet(), bottomNavigationBar: BlocBuilder( builder: (BuildContext context, StaffMainState state) { + if (!state.showBottomBar) return const SizedBox.shrink(); return StaffMainBottomBar( currentIndex: state.currentIndex, onTap: (int index) {