dart format
This commit is contained in:
@@ -19,7 +19,8 @@ class MarianumDatesView extends StatelessWidget {
|
||||
static List<_MonthGroup> _groupByMonth(List<MarianumDate> events) {
|
||||
final byMonth = <String, List<MarianumDate>>{};
|
||||
for (final e in events) {
|
||||
final key = '${e.start.year.toString().padLeft(4, '0')}-${e.start.month.toString().padLeft(2, '0')}';
|
||||
final key =
|
||||
'${e.start.year.toString().padLeft(4, '0')}-${e.start.month.toString().padLeft(2, '0')}';
|
||||
byMonth.putIfAbsent(key, () => []).add(e);
|
||||
}
|
||||
final keys = byMonth.keys.toList()..sort();
|
||||
@@ -31,7 +32,8 @@ class MarianumDatesView extends StatelessWidget {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => BlocModule<MarianumDatesBloc, LoadableState<MarianumDatesState>>(
|
||||
Widget build(BuildContext context) =>
|
||||
BlocModule<MarianumDatesBloc, LoadableState<MarianumDatesState>>(
|
||||
create: (context) => MarianumDatesBloc(),
|
||||
autoRebuild: true,
|
||||
child: (context, bloc, state) => Scaffold(
|
||||
@@ -42,18 +44,26 @@ class MarianumDatesView extends StatelessWidget {
|
||||
initialValue: bloc.showPastEvents(),
|
||||
icon: const Icon(Icons.history),
|
||||
itemBuilder: (context) => [true, false]
|
||||
.map((e) => PopupMenuItem<bool>(
|
||||
value: e,
|
||||
enabled: e != bloc.showPastEvents(),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(e ? Icons.history_outlined : Icons.history_toggle_off_outlined,
|
||||
color: Theme.of(context).colorScheme.onSurface),
|
||||
const SizedBox(width: 15),
|
||||
Text(e ? 'Alle anzeigen' : 'Nur zukünftige anzeigen'),
|
||||
],
|
||||
),
|
||||
))
|
||||
.map(
|
||||
(e) => PopupMenuItem<bool>(
|
||||
value: e,
|
||||
enabled: e != bloc.showPastEvents(),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
e
|
||||
? Icons.history_outlined
|
||||
: Icons.history_toggle_off_outlined,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
Text(
|
||||
e ? 'Alle anzeigen' : 'Nur zukünftige anzeigen',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onSelected: (e) => bloc.add(SetPastEventsVisible(e)),
|
||||
),
|
||||
@@ -61,7 +71,10 @@ class MarianumDatesView extends StatelessWidget {
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () {
|
||||
final events = bloc.getEvents() ?? const <MarianumDate>[];
|
||||
showSearch(context: context, delegate: SearchMarianumDates(events));
|
||||
showSearch(
|
||||
context: context,
|
||||
delegate: SearchMarianumDates(events),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -89,7 +102,8 @@ class MarianumDatesView extends StatelessWidget {
|
||||
),
|
||||
SliverList.builder(
|
||||
itemCount: group.events.length,
|
||||
itemBuilder: (_, i) => MarianumDateRow(event: group.events[i]),
|
||||
itemBuilder: (_, i) =>
|
||||
MarianumDateRow(event: group.events[i]),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -21,15 +21,15 @@ class SearchMarianumDates extends SearchDelegate<MarianumDate?> {
|
||||
|
||||
@override
|
||||
List<Widget>? buildActions(BuildContext context) => [
|
||||
if (query.isNotEmpty)
|
||||
IconButton(onPressed: () => query = '', icon: const Icon(Icons.delete)),
|
||||
];
|
||||
if (query.isNotEmpty)
|
||||
IconButton(onPressed: () => query = '', icon: const Icon(Icons.delete)),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget? buildLeading(BuildContext context) => IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => close(context, null),
|
||||
);
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => close(context, null),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget buildResults(BuildContext context) {
|
||||
|
||||
@@ -32,12 +32,16 @@ void showEventDetailsSheet(BuildContext context, MarianumDate event) {
|
||||
if (isUpcoming)
|
||||
ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.timer_outlined)),
|
||||
title: AnimatedTime(callback: () => event.start.difference(DateTime.now())),
|
||||
title: AnimatedTime(
|
||||
callback: () => event.start.difference(DateTime.now()),
|
||||
),
|
||||
subtitle: Text(event.start.formatRelative()),
|
||||
)
|
||||
else
|
||||
ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.content_paste_search_outlined)),
|
||||
leading: const CenteredLeading(
|
||||
Icon(Icons.content_paste_search_outlined),
|
||||
),
|
||||
title: Text(event.start.formatRelative()),
|
||||
),
|
||||
DebugTile(sheetContext).jsonData(event.toJson()),
|
||||
|
||||
@@ -63,9 +63,12 @@ class MarianumDateRow extends StatelessWidget {
|
||||
event.title.isEmpty ? '(ohne Titel)' : event.title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.onSurface),
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (event.description != null && event.description!.trim().isNotEmpty) ...[
|
||||
if (event.description != null &&
|
||||
event.description!.trim().isNotEmpty) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
event.description!.trim(),
|
||||
@@ -88,7 +91,9 @@ class MarianumDateRow extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
IconButton(
|
||||
icon: _CalendarPlusIcon(color: theme.colorScheme.onSurfaceVariant),
|
||||
icon: _CalendarPlusIcon(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
tooltip: 'In Stundenplan übernehmen',
|
||||
onPressed: () => showDialog(
|
||||
context: context,
|
||||
@@ -117,25 +122,25 @@ class _CalendarPlusIcon extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => SizedBox(
|
||||
width: 22,
|
||||
height: 22,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Icon(Icons.event_outlined, size: 22, color: color),
|
||||
Positioned(
|
||||
right: -2,
|
||||
bottom: -2,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
padding: const EdgeInsets.all(1),
|
||||
child: Icon(Icons.add_circle, size: 12, color: color),
|
||||
),
|
||||
width: 22,
|
||||
height: 22,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Icon(Icons.event_outlined, size: 22, color: color),
|
||||
Positioned(
|
||||
right: -2,
|
||||
bottom: -2,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.all(1),
|
||||
child: Icon(Icons.add_circle, size: 12, color: color),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,11 @@ class MonthHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||
static const double _height = 38;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
double shrinkOffset,
|
||||
bool overlapsContent,
|
||||
) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
height: _height,
|
||||
@@ -32,5 +36,6 @@ class MonthHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||
double get minExtent => _height;
|
||||
|
||||
@override
|
||||
bool shouldRebuild(covariant MonthHeaderDelegate oldDelegate) => oldDelegate.label != label;
|
||||
bool shouldRebuild(covariant MonthHeaderDelegate oldDelegate) =>
|
||||
oldDelegate.label != label;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user