feat: Refactor context reading in emergency contact and FAQs widgets
- Updated the context reading method in `EmergencyContactAddButton` and `EmergencyContactFormItem` to use `ReadContext`. - Modified the `FaqsWidget` to utilize `ReadContext` for fetching FAQs. - Adjusted the `PrivacySectionWidget` to read from `PrivacySecurityBloc` using `ReadContext`. feat: Implement Firebase Auth isolation pattern - Introduced `FirebaseAuthService` and `FirebaseAuthServiceImpl` to abstract Firebase Auth operations. - Ensured features do not directly import `firebase_auth`, adhering to architecture rules. feat: Create repository interfaces for billing and coverage - Added `BillingRepositoryInterface` for billing-related operations. - Created `CoverageRepositoryInterface` for coverage data access. feat: Add use cases for order management - Implemented use cases for fetching hubs, managers, and roles related to orders. - Created `GetHubsUseCase`, `GetManagersByHubUseCase`, and `GetRolesByVendorUseCase`. feat: Develop report use cases for client reports - Added use cases for fetching various reports including coverage, daily operations, forecast, no-show, performance, and spend reports. - Implemented `GetCoverageReportUseCase`, `GetDailyOpsReportUseCase`, `GetForecastReportUseCase`, `GetNoShowReportUseCase`, `GetPerformanceReportUseCase`, and `GetSpendReportUseCase`. feat: Establish profile repository and use cases - Created `ProfileRepositoryInterface` for staff profile data access. - Implemented use cases for retrieving staff profile and section statuses: `GetStaffProfileUseCase` and `GetProfileSectionsUseCase`. - Added `SignOutUseCase` for signing out the current user.
This commit is contained in:
@@ -1,20 +1,34 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'client_main_state.dart';
|
||||
import 'package:client_main/src/presentation/blocs/client_main_state.dart';
|
||||
|
||||
class ClientMainCubit extends Cubit<ClientMainState> implements Disposable {
|
||||
/// Cubit that manages the client app's main navigation state.
|
||||
///
|
||||
/// Tracks the active bottom bar tab and controls tab visibility
|
||||
/// based on the current route.
|
||||
class ClientMainCubit extends Cubit<ClientMainState>
|
||||
with BlocErrorHandler<ClientMainState>
|
||||
implements Disposable {
|
||||
/// Creates a [ClientMainCubit] and starts listening for route changes.
|
||||
ClientMainCubit() : super(const ClientMainState()) {
|
||||
Modular.to.addListener(_onRouteChanged);
|
||||
_onRouteChanged();
|
||||
}
|
||||
|
||||
/// Routes that should hide the bottom navigation bar.
|
||||
static const List<String> _hideBottomBarPaths = <String>[
|
||||
ClientPaths.completionReview,
|
||||
ClientPaths.awaitingApproval,
|
||||
];
|
||||
|
||||
/// Updates state when the current route changes.
|
||||
///
|
||||
/// Detects the active tab from the route path and determines
|
||||
/// whether the bottom bar should be visible.
|
||||
void _onRouteChanged() {
|
||||
if (isClosed) return;
|
||||
|
||||
final String path = Modular.to.path;
|
||||
int newIndex = state.currentIndex;
|
||||
|
||||
@@ -41,6 +55,9 @@ class ClientMainCubit extends Cubit<ClientMainState> implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigates to the tab at [index] via Modular safe navigation.
|
||||
///
|
||||
/// State update happens automatically via [_onRouteChanged].
|
||||
void navigateToTab(int index) {
|
||||
if (index == state.currentIndex) return;
|
||||
|
||||
@@ -61,7 +78,6 @@ class ClientMainCubit extends Cubit<ClientMainState> implements Disposable {
|
||||
Modular.to.toClientReports();
|
||||
break;
|
||||
}
|
||||
// State update will happen via _onRouteChanged
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// State for [ClientMainCubit] representing bottom navigation status.
|
||||
class ClientMainState extends Equatable {
|
||||
/// Creates a [ClientMainState] with the given tab index and bar visibility.
|
||||
const ClientMainState({
|
||||
this.currentIndex = 2, // Default to Home
|
||||
this.showBottomBar = true,
|
||||
});
|
||||
|
||||
/// Index of the currently active bottom navigation tab.
|
||||
final int currentIndex;
|
||||
|
||||
/// Whether the bottom navigation bar should be visible.
|
||||
final bool showBottomBar;
|
||||
|
||||
/// Creates a copy of this state with updated fields.
|
||||
ClientMainState copyWith({int? currentIndex, bool? showBottomBar}) {
|
||||
return ClientMainState(
|
||||
currentIndex: currentIndex ?? this.currentIndex,
|
||||
|
||||
Reference in New Issue
Block a user