feat: Refactor Staff Profile page to use ProfileCubit and improve loading logic
This commit is contained in:
@@ -29,17 +29,20 @@ class StaffProfilePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final i18n = t.staff.profile;
|
||||
final cubit = Modular.get<ProfileCubit>();
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) {
|
||||
// Load profile data on first build
|
||||
// TODO: Get actual userId from auth session
|
||||
// For now, using mock userId that matches ProfileRepositoryMock data
|
||||
const userId = 't8P3fYh4y1cPoZbbVPXUhfQCsDo3';
|
||||
return Modular.get<ProfileCubit>()..loadProfile(userId);
|
||||
},
|
||||
child: Scaffold(
|
||||
if (cubit.state.status == ProfileStatus.initial) {
|
||||
cubit.loadProfile(userId);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: UiColors.background,
|
||||
body: BlocBuilder<ProfileCubit, ProfileState>(
|
||||
bloc: cubit,
|
||||
builder: (context, state) {
|
||||
if (state.status == ProfileStatus.loading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
@@ -230,7 +233,6 @@ class StaffProfilePage extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ class StaffProfileModule extends Module {
|
||||
);
|
||||
|
||||
// Presentation layer - Cubit depends on use cases
|
||||
i.addSingleton(
|
||||
// Use addLazySingleton to create a new instance per module lifecycle
|
||||
i.addLazySingleton(
|
||||
() => ProfileCubit(
|
||||
i.get<GetProfileUseCase>(),
|
||||
i.get<SignOutUseCase>(),
|
||||
|
||||
@@ -1,41 +1,40 @@
|
||||
name: staff_profile
|
||||
description: Staff Profile feature package.
|
||||
version: 0.0.1
|
||||
publish_to: 'none'
|
||||
publish_to: none
|
||||
resolution: workspace
|
||||
|
||||
environment:
|
||||
sdk: '>=3.0.0 <4.0.0'
|
||||
flutter: ">=1.17.0"
|
||||
sdk: '>=3.10.0 <4.0.0'
|
||||
flutter: ">=3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_bloc: ^8.1.0
|
||||
bloc: ^8.1.0
|
||||
flutter_modular: ^6.3.0
|
||||
equatable: ^2.0.5
|
||||
lucide_icons: ^0.257.0
|
||||
|
||||
# Architecture
|
||||
flutter_modular: ^5.0.0
|
||||
flutter_bloc: ^8.1.3
|
||||
|
||||
# Utility/DI
|
||||
injectable: ^2.3.0
|
||||
get_it: ^7.6.4
|
||||
|
||||
# Project-specific packages
|
||||
domain:
|
||||
path: ../../../domain
|
||||
data_connect:
|
||||
path: ../../../data_connect
|
||||
# Architecture Packages
|
||||
design_system:
|
||||
path: ../../../design_system
|
||||
core_localization:
|
||||
path: ../../../core_localization
|
||||
design_system:
|
||||
path: ../../../design_system # Assuming this path
|
||||
krow_core:
|
||||
path: ../../../core
|
||||
krow_domain:
|
||||
path: ../../../domain
|
||||
krow_data_connect:
|
||||
path: ../../../data_connect
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^2.0.0
|
||||
injectable_generator: ^2.4.1
|
||||
build_runner: ^2.4.6
|
||||
bloc_test: ^9.1.0
|
||||
mocktail: ^1.0.0
|
||||
flutter_lints: ^6.0.0
|
||||
|
||||
# Flutter modular configuration
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:staff_home/staff_home.dart';
|
||||
import 'package:staff_profile/staff_profile.dart';
|
||||
|
||||
import 'package:staff_main/src/presentation/blocs/staff_main_cubit.dart';
|
||||
import 'package:staff_main/src/presentation/constants/staff_main_routes.dart';
|
||||
@@ -38,10 +39,9 @@ class StaffMainModule extends Module {
|
||||
child: (BuildContext context) =>
|
||||
const PlaceholderPage(title: 'Clock In'),
|
||||
),
|
||||
ChildRoute<dynamic>(
|
||||
ModuleRoute<dynamic>(
|
||||
StaffMainRoutes.profile,
|
||||
child: (BuildContext context) =>
|
||||
const PlaceholderPage(title: 'Profile'),
|
||||
module: StaffProfileModule(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -25,12 +25,12 @@ dependencies:
|
||||
# Features
|
||||
staff_home:
|
||||
path: ../home
|
||||
staff_profile:
|
||||
path: ../profile
|
||||
# staff_shifts:
|
||||
# path: ../shifts
|
||||
# staff_payments:
|
||||
# path: ../payments
|
||||
# staff_profile:
|
||||
# path: ../profile
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -1064,6 +1064,13 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.12.1"
|
||||
staff_profile:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/features/staff/profile"
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user