updated project style guidelines
This commit is contained in:
@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../api/holidays/getHolidaysResponse.dart';
|
||||
import '../../../../model/holidays/holidaysProps.dart';
|
||||
import '../../../../storage/base/settingsProvider.dart';
|
||||
import '../../../../widget/centeredLeading.dart';
|
||||
@ -22,9 +21,7 @@ class Holidays extends StatefulWidget {
|
||||
}
|
||||
|
||||
extension StringExtension on String {
|
||||
String capitalize() {
|
||||
return "${this[0].toUpperCase()}${substring(1).toLowerCase()}";
|
||||
}
|
||||
String capitalize() => '${this[0].toUpperCase()}${substring(1).toLowerCase()}';
|
||||
}
|
||||
|
||||
class _HolidaysState extends State<Holidays> {
|
||||
@ -41,13 +38,10 @@ class _HolidaysState extends State<Holidays> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
String parseString(String enDate) {
|
||||
return Jiffy.parse(enDate).format(pattern: 'dd.MM.yyyy');
|
||||
}
|
||||
String parseString(String enDate) => Jiffy.parse(enDate).format(pattern: 'dd.MM.yyyy');
|
||||
|
||||
void showDisclaimer() {
|
||||
showDialog(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
showDialog(context: context, builder: (context) => AlertDialog(
|
||||
title: const Text('Richtigkeit und Bereitstellung der Daten'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@ -70,13 +64,11 @@ class _HolidaysState extends State<Holidays> {
|
||||
TextButton(child: const Text('ferien-api.de besuchen'), onPressed: () => ConfirmDialog.openBrowser(context, 'https://ferien-api.de/')),
|
||||
TextButton(child: const Text('Okay'), onPressed: () => Navigator.of(context).pop()),
|
||||
],
|
||||
);
|
||||
});
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Schulferien in Hessen'),
|
||||
actions: [
|
||||
@ -87,8 +79,7 @@ class _HolidaysState extends State<Holidays> {
|
||||
PopupMenuButton<bool>(
|
||||
initialValue: settings.val().holidaysSettings.showPastEvents,
|
||||
icon: const Icon(Icons.manage_history_outlined),
|
||||
itemBuilder: (context) {
|
||||
return [true, false].map((e) => PopupMenuItem<bool>(
|
||||
itemBuilder: (context) => [true, false].map((e) => PopupMenuItem<bool>(
|
||||
value: e,
|
||||
enabled: e != showPastEvents,
|
||||
child: Row(
|
||||
@ -98,8 +89,7 @@ class _HolidaysState extends State<Holidays> {
|
||||
Text(e ? 'Alle anzeigen' : 'Nur zukünftige anzeigen')
|
||||
],
|
||||
)
|
||||
)).toList();
|
||||
},
|
||||
)).toList(),
|
||||
onSelected: (e) {
|
||||
setState(() {
|
||||
showPastEvents = e;
|
||||
@ -112,7 +102,7 @@ class _HolidaysState extends State<Holidays> {
|
||||
body: Consumer<HolidaysProps>(builder: (context, value, child) {
|
||||
if(value.primaryLoading()) return const LoadingSpinner();
|
||||
|
||||
List<GetHolidaysResponseObject> holidays = value.getHolidaysResponse.data;
|
||||
var holidays = value.getHolidaysResponse.data;
|
||||
if(!showPastEvents) holidays = holidays.where((element) => DateTime.parse(element.end).isAfter(DateTime.now())).toList();
|
||||
|
||||
if(holidays.isEmpty) return const PlaceholderView(icon: Icons.search_off, text: 'Es wurden keine Ferieneinträge gefunden!');
|
||||
@ -120,8 +110,8 @@ class _HolidaysState extends State<Holidays> {
|
||||
return ListView.builder(
|
||||
itemCount: holidays.length,
|
||||
itemBuilder: (context, index) {
|
||||
GetHolidaysResponseObject holiday = holidays[index];
|
||||
String holidayType = holiday.name.split(' ').first.capitalize();
|
||||
var holiday = holidays[index];
|
||||
var holidayType = holiday.name.split(' ').first.capitalize();
|
||||
return ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.calendar_month)),
|
||||
title: Text('$holidayType ab ${parseString(holiday.start)}'),
|
||||
@ -164,5 +154,4 @@ class _HolidaysState extends State<Holidays> {
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user