feat: Introduce showBottomBar state to conditionally hide the bottom navigation bar based on specific routes.
This commit is contained in:
@@ -14,7 +14,6 @@ class ClientMainCubit extends Cubit<ClientMainState> 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(ClientPaths.coverage)) {
|
||||
newIndex = 0;
|
||||
} else if (path.contains(ClientPaths.billing)) {
|
||||
@@ -27,8 +26,15 @@ class ClientMainCubit extends Cubit<ClientMainState> implements Disposable {
|
||||
newIndex = 4;
|
||||
}
|
||||
|
||||
if (newIndex != state.currentIndex) {
|
||||
emit(state.copyWith(currentIndex: newIndex));
|
||||
final bool showBottomBar =
|
||||
!path.contains(ClientPaths.completionReview) &&
|
||||
!path.contains(ClientPaths.awaitingApproval);
|
||||
|
||||
if (newIndex != state.currentIndex ||
|
||||
showBottomBar != state.showBottomBar) {
|
||||
emit(
|
||||
state.copyWith(currentIndex: newIndex, showBottomBar: showBottomBar),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,19 @@ import 'package:equatable/equatable.dart';
|
||||
class ClientMainState extends Equatable {
|
||||
const ClientMainState({
|
||||
this.currentIndex = 2, // Default to Home
|
||||
this.showBottomBar = true,
|
||||
});
|
||||
|
||||
final int currentIndex;
|
||||
final bool showBottomBar;
|
||||
|
||||
ClientMainState copyWith({int? currentIndex}) {
|
||||
return ClientMainState(currentIndex: currentIndex ?? this.currentIndex);
|
||||
ClientMainState copyWith({int? currentIndex, bool? showBottomBar}) {
|
||||
return ClientMainState(
|
||||
currentIndex: currentIndex ?? this.currentIndex,
|
||||
showBottomBar: showBottomBar ?? this.showBottomBar,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object> get props => <Object>[currentIndex];
|
||||
List<Object> get props => <Object>[currentIndex, showBottomBar];
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ class ClientMainPage extends StatelessWidget {
|
||||
body: const RouterOutlet(),
|
||||
bottomNavigationBar: BlocBuilder<ClientMainCubit, ClientMainState>(
|
||||
builder: (BuildContext context, ClientMainState state) {
|
||||
if (!state.showBottomBar) return const SizedBox.shrink();
|
||||
|
||||
return ClientMainBottomBar(
|
||||
currentIndex: state.currentIndex,
|
||||
onTap: (int index) {
|
||||
|
||||
Reference in New Issue
Block a user