refactor: Rearrange MultiBlocProvider and Scaffold structure in ClockInPage for improved readability
This commit is contained in:
@@ -25,29 +25,25 @@ class ClockInPage extends StatelessWidget {
|
||||
context,
|
||||
).staff.clock_in;
|
||||
|
||||
return MultiBlocProvider(
|
||||
providers: <BlocProvider<dynamic>>[
|
||||
BlocProvider<ClockInBloc>.value(
|
||||
value: Modular.get<ClockInBloc>(),
|
||||
),
|
||||
BlocProvider<GeofenceBloc>.value(
|
||||
value: Modular.get<GeofenceBloc>(),
|
||||
),
|
||||
],
|
||||
child: BlocListener<ClockInBloc, ClockInState>(
|
||||
listenWhen: (ClockInState previous, ClockInState current) =>
|
||||
current.status == ClockInStatus.failure &&
|
||||
current.errorMessage != null,
|
||||
listener: (BuildContext context, ClockInState state) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: translateErrorKey(state.errorMessage!),
|
||||
type: UiSnackbarType.error,
|
||||
);
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: UiAppBar(title: i18n.title, showBackButton: false),
|
||||
body: BlocBuilder<ClockInBloc, ClockInState>(
|
||||
return Scaffold(
|
||||
appBar: UiAppBar(title: i18n.title, showBackButton: false),
|
||||
body: MultiBlocProvider(
|
||||
providers: <BlocProvider<dynamic>>[
|
||||
BlocProvider<ClockInBloc>.value(value: Modular.get<ClockInBloc>()),
|
||||
BlocProvider<GeofenceBloc>.value(value: Modular.get<GeofenceBloc>()),
|
||||
],
|
||||
child: BlocListener<ClockInBloc, ClockInState>(
|
||||
listenWhen: (ClockInState previous, ClockInState current) =>
|
||||
current.status == ClockInStatus.failure &&
|
||||
current.errorMessage != null,
|
||||
listener: (BuildContext context, ClockInState state) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: translateErrorKey(state.errorMessage!),
|
||||
type: UiSnackbarType.error,
|
||||
);
|
||||
},
|
||||
child: BlocBuilder<ClockInBloc, ClockInState>(
|
||||
buildWhen: (ClockInState previous, ClockInState current) =>
|
||||
previous.status != current.status ||
|
||||
previous.todayShifts != current.todayShifts,
|
||||
|
||||
Reference in New Issue
Block a user