fixed disclaimer not showing on first visit
This commit is contained in:
@ -6,6 +6,7 @@ import '../../../../../widget/list_view_util.dart';
|
||||
import '../../../../../widget/centeredLeading.dart';
|
||||
import '../../../../../widget/debug/debugTile.dart';
|
||||
import '../../../../../widget/string_extensions.dart';
|
||||
import '../../../infrastructure/loadableState/loadable_state.dart';
|
||||
import '../../../infrastructure/loadableState/view/loadable_state_consumer.dart';
|
||||
import '../../../infrastructure/utilityWidgets/bloc_module.dart';
|
||||
import '../bloc/holidays_bloc.dart';
|
||||
@ -16,7 +17,7 @@ class HolidaysView extends StatelessWidget {
|
||||
const HolidaysView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => BlocModule(
|
||||
Widget build(BuildContext context) => BlocModule<HolidaysBloc, LoadableState<HolidaysState>>(
|
||||
create: (context) => HolidaysBloc(),
|
||||
autoRebuild: true,
|
||||
child: (context, bloc, state) {
|
||||
@ -28,10 +29,7 @@ class HolidaysView extends StatelessWidget {
|
||||
'Ich übernehme weder Verantwortung für die Richtigkeit der Daten noch hafte ich für wirtschaftliche Schäden die aus der Verwendung dieser Daten entstehen können.\n\n'
|
||||
'Die Daten stammen von https://ferien-api.de/'),
|
||||
actions: [
|
||||
TextButton(child: const Text('Okay'), onPressed: () {
|
||||
bloc.add(DisclaimerDismissed());
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
TextButton(child: const Text('Okay'), onPressed: () => Navigator.of(context).pop()),
|
||||
],
|
||||
));
|
||||
}
|
||||
@ -63,6 +61,10 @@ class HolidaysView extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
body: LoadableStateConsumer<HolidaysBloc, HolidaysState>(
|
||||
onLoad: (state) {
|
||||
if(state.showDisclaimer) showDisclaimer();
|
||||
bloc.add(DisclaimerDismissed());
|
||||
},
|
||||
child: (state, loading) => ListViewUtil.fromList<Holiday>(bloc.getHolidays(), (holiday) {
|
||||
var holidayType = holiday.name.split(' ').first.capitalize();
|
||||
String formatDate(String date) => Jiffy.parse(date).format(pattern: 'dd.MM.yyyy');
|
||||
|
Reference in New Issue
Block a user