feat: Add post-save navigation to staff profile for emergency contact and experience, remove a placeholder page, and refine bloc usage and UI rendering.

This commit is contained in:
Achintha Isuru
2026-02-22 03:01:44 -05:00
parent 214e0d1237
commit a9ead783e4
8 changed files with 149 additions and 126 deletions

View File

@@ -8,17 +8,22 @@ import 'package:staff_main/src/presentation/blocs/staff_main_state.dart';
class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
StaffMainCubit({
required GetProfileCompletionUseCase getProfileCompletionUsecase,
}) : _getProfileCompletionUsecase = getProfileCompletionUsecase,
super(const StaffMainState()) {
}) : _getProfileCompletionUsecase = getProfileCompletionUsecase,
super(const StaffMainState()) {
Modular.to.addListener(_onRouteChanged);
_onRouteChanged();
_loadProfileCompletion();
}
final GetProfileCompletionUseCase _getProfileCompletionUsecase;
bool _isLoadingCompletion = false;
void _onRouteChanged() {
if (isClosed) return;
// Refresh completion status whenever route changes to catch profile updates
// only if it's not already complete.
refreshProfileCompletion();
final String path = Modular.to.path;
int newIndex = state.currentIndex;
@@ -41,7 +46,10 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
}
/// Loads the profile completion status.
Future<void> _loadProfileCompletion() async {
Future<void> refreshProfileCompletion() async {
if (_isLoadingCompletion || isClosed) return;
_isLoadingCompletion = true;
try {
final isComplete = await _getProfileCompletionUsecase();
if (!isClosed) {
@@ -53,6 +61,8 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
if (!isClosed) {
emit(state.copyWith(isProfileComplete: true));
}
} finally {
_isLoadingCompletion = false;
}
}

View File

@@ -1,15 +0,0 @@
import 'package:flutter/material.dart';
class PlaceholderPage extends StatelessWidget {
const PlaceholderPage({required this.title, super.key});
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(child: Text('$title Page')),
);
}
}