diff --git a/lib/index.dart b/lib/index.dart index 8efcbad5..0f55a17e 100644 --- a/lib/index.dart +++ b/lib/index.dart @@ -50,6 +50,16 @@ extension _NavigationDestX on _NavigationDest { typedef NavigationItems = List<({String route, _NavigationDest item})>; +final _immersiveWallpaperMode = Provider.autoDispose((ref) { + final immersiveWallpaper = ref.watch(Settings.timetable.$immersiveWallpaper); + if (immersiveWallpaper) { + final bg = ref.watch(Settings.timetable.$backgroundImage); + return bg?.enabled == true; + } + return false; +}); + + class _MainStagePageState extends ConsumerState { NavigationItems buildItems() { return [ @@ -112,7 +122,7 @@ class _MainStagePageState extends ConsumerState { @override Widget build(BuildContext context) { - final immersiveWallpaper = ref.watch(Settings.timetable.$immersiveWallpaper); + final immersiveWallpaper = ref.watch(_immersiveWallpaperMode); if (immersiveWallpaper) { return [ Positioned.fill( @@ -130,7 +140,7 @@ class _MainStagePageState extends ConsumerState { } Widget buildBody() { - final immersiveWallpaper = ref.watch(Settings.timetable.$immersiveWallpaper); + final immersiveWallpaper = ref.watch(_immersiveWallpaperMode); final items = buildItems(); if (context.isPortrait) { return Scaffold( @@ -151,7 +161,7 @@ class _MainStagePageState extends ConsumerState { } Widget buildNavigationBar(NavigationItems items) { - final immersiveWallpaper = ref.watch(Settings.timetable.$immersiveWallpaper); + final immersiveWallpaper = ref.watch(_immersiveWallpaperMode); return NavigationBar( backgroundColor: immersiveWallpaper ? context.colorScheme.surfaceContainer.withOpacity(Settings.timetable.immersiveOpacity) @@ -163,7 +173,7 @@ class _MainStagePageState extends ConsumerState { } Widget buildNavigationRail(NavigationItems items) { - final immersiveWallpaper = ref.watch(Settings.timetable.$immersiveWallpaper); + final immersiveWallpaper = ref.watch(_immersiveWallpaperMode); return NavigationRail( backgroundColor: immersiveWallpaper ? context.colorScheme.surfaceContainer.withOpacity(Settings.timetable.immersiveOpacity) diff --git a/lib/timetable/widget/timetable/header.dart b/lib/timetable/widget/timetable/header.dart index b793833e..ea1fa276 100644 --- a/lib/timetable/widget/timetable/header.dart +++ b/lib/timetable/widget/timetable/header.dart @@ -6,8 +6,7 @@ import 'package:mimir/school/utils.dart'; import 'package:mimir/timetable/p13n/widget/style.dart'; import 'package:rettulf/rettulf.dart'; -Color? getTimetableHeaderColor( - BuildContext context, { +Color? getTimetableHeaderColor(BuildContext context, { bool selected = false, }) { if (selected) { @@ -21,9 +20,7 @@ Color? getTimetableHeaderColor( return null; } -Color? getTimetableHeaderDashLinedColor( - BuildContext context, -) { +Color? getTimetableHeaderDashLinedColor(BuildContext context,) { return context.colorScheme.surfaceTint.withOpacity(0.35); } @@ -64,8 +61,8 @@ class TimetableHeader extends StatelessWidget { child: InkWell( onTap: onDayTap != null ? () { - onDayTap.call(weekday); - } + onDayTap.call(weekday); + } : null, child: HeaderCell( weekIndex: weekIndex, @@ -138,16 +135,10 @@ class HeaderCellTextBox extends StatelessWidget { final day = date.month == firstDateInWeek.month || date.day != 1 ? "${date.day}" : DateFormat("MMM", context.locale.toString()).format(DateTime(0, date.month)); - return [ - weekday.l10nShort().text( - textAlign: TextAlign.center, - style: context.textTheme.titleSmall, - ), - day.text( - textAlign: TextAlign.center, - style: context.textTheme.labelSmall, - ), - ].column().padOnly(t: 5, b: 5); + return CustomHeaderCellTextBox( + line1: weekday.l10nShort(), + line2: day, + ); } } @@ -170,7 +161,7 @@ class MonthHeaderCellTextBox extends StatelessWidget { ); } return CustomHeaderCellTextBox( - line1: "$month", + line1: "", line2: _monthAbbr.format(DateTime(0, month)), ); }