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;
|
final GetProfileCompletionUseCase _getProfileCompletionUsecase;
|
||||||
bool _isLoadingCompletion = false;
|
bool _isLoadingCompletion = false;
|
||||||
|
|
||||||
|
static const List<String> _hideBottomPaths = <String>[
|
||||||
|
StaffPaths.benefits,
|
||||||
|
];
|
||||||
|
|
||||||
void _onRouteChanged() {
|
void _onRouteChanged() {
|
||||||
if (isClosed) return;
|
if (isClosed) return;
|
||||||
|
|
||||||
@@ -40,8 +44,10 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
|
|||||||
newIndex = 4;
|
newIndex = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newIndex != state.currentIndex) {
|
final bool showBottomBar = !_hideBottomPaths.any(path.contains);
|
||||||
emit(state.copyWith(currentIndex: newIndex));
|
|
||||||
|
if (newIndex != state.currentIndex || showBottomBar != state.showBottomBar) {
|
||||||
|
emit(state.copyWith(currentIndex: newIndex, showBottomBar: showBottomBar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,25 @@ class StaffMainState extends Equatable {
|
|||||||
const StaffMainState({
|
const StaffMainState({
|
||||||
this.currentIndex = 2, // Default to Home
|
this.currentIndex = 2, // Default to Home
|
||||||
this.isProfileComplete = false,
|
this.isProfileComplete = false,
|
||||||
|
this.showBottomBar = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int currentIndex;
|
final int currentIndex;
|
||||||
final bool isProfileComplete;
|
final bool isProfileComplete;
|
||||||
|
final bool showBottomBar;
|
||||||
|
|
||||||
StaffMainState copyWith({int? currentIndex, bool? isProfileComplete}) {
|
StaffMainState copyWith({
|
||||||
|
int? currentIndex,
|
||||||
|
bool? isProfileComplete,
|
||||||
|
bool? showBottomBar,
|
||||||
|
}) {
|
||||||
return StaffMainState(
|
return StaffMainState(
|
||||||
currentIndex: currentIndex ?? this.currentIndex,
|
currentIndex: currentIndex ?? this.currentIndex,
|
||||||
isProfileComplete: isProfileComplete ?? this.isProfileComplete,
|
isProfileComplete: isProfileComplete ?? this.isProfileComplete,
|
||||||
|
showBottomBar: showBottomBar ?? this.showBottomBar,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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(),
|
body: const RouterOutlet(),
|
||||||
bottomNavigationBar: BlocBuilder<StaffMainCubit, StaffMainState>(
|
bottomNavigationBar: BlocBuilder<StaffMainCubit, StaffMainState>(
|
||||||
builder: (BuildContext context, StaffMainState state) {
|
builder: (BuildContext context, StaffMainState state) {
|
||||||
|
if (!state.showBottomBar) return const SizedBox.shrink();
|
||||||
return StaffMainBottomBar(
|
return StaffMainBottomBar(
|
||||||
currentIndex: state.currentIndex,
|
currentIndex: state.currentIndex,
|
||||||
onTap: (int index) {
|
onTap: (int index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user