feat: Implement show/hide functionality for bottom navigation bar based on route changes
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user