refactor: Rearrange MultiBlocProvider and Scaffold structure in ClockInPage for improved readability

This commit is contained in:
Achintha Isuru
2026-03-13 17:15:44 -04:00
parent a85cd36975
commit ea078eaa02

View File

@@ -25,29 +25,25 @@ class ClockInPage extends StatelessWidget {
context, context,
).staff.clock_in; ).staff.clock_in;
return MultiBlocProvider( return Scaffold(
providers: <BlocProvider<dynamic>>[ appBar: UiAppBar(title: i18n.title, showBackButton: false),
BlocProvider<ClockInBloc>.value( body: MultiBlocProvider(
value: Modular.get<ClockInBloc>(), providers: <BlocProvider<dynamic>>[
), BlocProvider<ClockInBloc>.value(value: Modular.get<ClockInBloc>()),
BlocProvider<GeofenceBloc>.value( BlocProvider<GeofenceBloc>.value(value: Modular.get<GeofenceBloc>()),
value: Modular.get<GeofenceBloc>(), ],
), child: BlocListener<ClockInBloc, ClockInState>(
], listenWhen: (ClockInState previous, ClockInState current) =>
child: BlocListener<ClockInBloc, ClockInState>( current.status == ClockInStatus.failure &&
listenWhen: (ClockInState previous, ClockInState current) => current.errorMessage != null,
current.status == ClockInStatus.failure && listener: (BuildContext context, ClockInState state) {
current.errorMessage != null, UiSnackbar.show(
listener: (BuildContext context, ClockInState state) { context,
UiSnackbar.show( message: translateErrorKey(state.errorMessage!),
context, type: UiSnackbarType.error,
message: translateErrorKey(state.errorMessage!), );
type: UiSnackbarType.error, },
); child: BlocBuilder<ClockInBloc, ClockInState>(
},
child: Scaffold(
appBar: UiAppBar(title: i18n.title, showBackButton: false),
body: BlocBuilder<ClockInBloc, ClockInState>(
buildWhen: (ClockInState previous, ClockInState current) => buildWhen: (ClockInState previous, ClockInState current) =>
previous.status != current.status || previous.status != current.status ||
previous.todayShifts != current.todayShifts, previous.todayShifts != current.todayShifts,