Skip to content

Commit

Permalink
immersive mode only when background was set
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Sep 27, 2024
1 parent f6fb5d6 commit c424e9c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
18 changes: 14 additions & 4 deletions lib/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<MainStagePage> {
NavigationItems buildItems() {
return [
Expand Down Expand Up @@ -112,7 +122,7 @@ class _MainStagePageState extends ConsumerState<MainStagePage> {

@override
Widget build(BuildContext context) {
final immersiveWallpaper = ref.watch(Settings.timetable.$immersiveWallpaper);
final immersiveWallpaper = ref.watch(_immersiveWallpaperMode);
if (immersiveWallpaper) {
return [
Positioned.fill(
Expand All @@ -130,7 +140,7 @@ class _MainStagePageState extends ConsumerState<MainStagePage> {
}

Widget buildBody() {
final immersiveWallpaper = ref.watch(Settings.timetable.$immersiveWallpaper);
final immersiveWallpaper = ref.watch(_immersiveWallpaperMode);
final items = buildItems();
if (context.isPortrait) {
return Scaffold(
Expand All @@ -151,7 +161,7 @@ class _MainStagePageState extends ConsumerState<MainStagePage> {
}

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)
Expand All @@ -163,7 +173,7 @@ class _MainStagePageState extends ConsumerState<MainStagePage> {
}

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)
Expand Down
27 changes: 9 additions & 18 deletions lib/timetable/widget/timetable/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -21,9 +20,7 @@ Color? getTimetableHeaderColor(
return null;
}

Color? getTimetableHeaderDashLinedColor(
BuildContext context,
) {
Color? getTimetableHeaderDashLinedColor(BuildContext context,) {
return context.colorScheme.surfaceTint.withOpacity(0.35);
}

Expand Down Expand Up @@ -64,8 +61,8 @@ class TimetableHeader extends StatelessWidget {
child: InkWell(
onTap: onDayTap != null
? () {
onDayTap.call(weekday);
}
onDayTap.call(weekday);
}
: null,
child: HeaderCell(
weekIndex: weekIndex,
Expand Down Expand Up @@ -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,
);
}
}

Expand All @@ -170,7 +161,7 @@ class MonthHeaderCellTextBox extends StatelessWidget {
);
}
return CustomHeaderCellTextBox(
line1: "$month",
line1: "",
line2: _monthAbbr.format(DateTime(0, month)),
);
}
Expand Down

0 comments on commit c424e9c

Please sign in to comment.