refactored data providers with centralized cache resolution, unified UI using custom dialogs and bottom sheets, and enhanced network error handling for Dio and TLS errors
This commit is contained in:
@@ -10,6 +10,8 @@ import '../../../state/app/modules/holidays/bloc/holidays_state.dart';
|
||||
import '../../../widget/animated_time.dart';
|
||||
import '../../../widget/centered_leading.dart';
|
||||
import '../../../widget/debug/debug_tile.dart';
|
||||
import '../../../widget/details_bottom_sheet.dart';
|
||||
import '../../../widget/info_dialog.dart';
|
||||
import '../../../widget/list_view_util.dart';
|
||||
import '../../../widget/string_extensions.dart';
|
||||
|
||||
@@ -21,18 +23,13 @@ class HolidaysView extends StatelessWidget {
|
||||
create: (context) => HolidaysBloc(),
|
||||
autoRebuild: true,
|
||||
child: (context, bloc, state) {
|
||||
void showDisclaimer() {
|
||||
showDialog(context: context, builder: (context) => AlertDialog(
|
||||
title: const Text('Richtigkeit und Bereitstellung der Daten'),
|
||||
content: const Text(''
|
||||
'Sämtliche Datumsangaben sind ohne Gewähr.\n'
|
||||
'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: () => Navigator.of(context).pop()),
|
||||
],
|
||||
));
|
||||
}
|
||||
void showDisclaimer() => InfoDialog.show(
|
||||
context,
|
||||
'Sämtliche Datumsangaben sind ohne Gewähr.\n'
|
||||
'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/',
|
||||
title: 'Richtigkeit und Bereitstellung der Daten',
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -78,9 +75,16 @@ class HolidaysView extends StatelessWidget {
|
||||
leading: const CenteredLeading(Icon(Icons.calendar_month)),
|
||||
title: Text('$holidayType ${getHolidayYear(holiday.start, holiday.end)}'),
|
||||
subtitle: Text('${formatDate(holiday.start)} - ${formatDate(holiday.end)}'),
|
||||
onTap: () => showDialog(context: context, builder: (context) => SimpleDialog(
|
||||
title: Text('$holidayType ${holiday.year} in Hessen'),
|
||||
children: [
|
||||
onTap: () => showDetailsBottomSheet(
|
||||
context,
|
||||
header: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 12),
|
||||
child: Text(
|
||||
'$holidayType ${holiday.year} in Hessen',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
children: (sheetCtx) => [
|
||||
ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.signpost_outlined)),
|
||||
title: Text(holiday.name.capitalize()),
|
||||
@@ -94,21 +98,20 @@ class HolidaysView extends StatelessWidget {
|
||||
leading: const Icon(Icons.date_range_outlined),
|
||||
title: Text('bis zum ${formatDate(holiday.end)}'),
|
||||
),
|
||||
Visibility(
|
||||
visible: !DateTime.parse(holiday.start).difference(DateTime.now()).isNegative,
|
||||
replacement: ListTile(
|
||||
if (DateTime.parse(holiday.start).difference(DateTime.now()).isNegative)
|
||||
ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.content_paste_search_outlined)),
|
||||
title: Text(Jiffy.parse(holiday.start).fromNow()),
|
||||
),
|
||||
child: ListTile(
|
||||
)
|
||||
else
|
||||
ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.timer_outlined)),
|
||||
title: AnimatedTime(callback: () => DateTime.parse(holiday.start).difference(DateTime.now())),
|
||||
subtitle: Text(Jiffy.parse(holiday.start).fromNow()),
|
||||
),
|
||||
),
|
||||
DebugTile(context).jsonData(holiday.toJson()),
|
||||
DebugTile(sheetCtx).jsonData(holiday.toJson()),
|
||||
],
|
||||
)),
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
);
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user