feat: Implement show/hide functionality for bottom navigation bar based on route changes

This commit is contained in:
Achintha Isuru
2026-03-03 21:35:59 -05:00
parent 6d9cb64487
commit 630b90ee38
3 changed files with 18 additions and 4 deletions

View File

@@ -17,6 +17,10 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
final GetProfileCompletionUseCase _getProfileCompletionUsecase;
bool _isLoadingCompletion = false;
static const List<String> _hideBottomPaths = <String>[
StaffPaths.benefits,
];
void _onRouteChanged() {
if (isClosed) return;
@@ -40,8 +44,10 @@ class StaffMainCubit extends Cubit<StaffMainState> 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));
}
}

View File

@@ -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<Object> get props => <Object>[currentIndex, isProfileComplete];
List<Object> get props => <Object>[currentIndex, isProfileComplete, showBottomBar];
}

View File

@@ -24,6 +24,7 @@ class StaffMainPage extends StatelessWidget {
body: const RouterOutlet(),
bottomNavigationBar: BlocBuilder<StaffMainCubit, StaffMainState>(
builder: (BuildContext context, StaffMainState state) {
if (!state.showBottomBar) return const SizedBox.shrink();
return StaffMainBottomBar(
currentIndex: state.currentIndex,
onTap: (int index) {