diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 78d6f63..219a17e 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -78,6 +78,7 @@ class _SettingsScreenState extends State { if (image == null) return; await File(image.path).copy('$_docBasepath/app_background_image'); + _prefs?.setBool('has_background_image', true); setState(() {}); }, @@ -98,6 +99,7 @@ class _SettingsScreenState extends State { trailing: const Icon(Symbols.chevron_right), onTap: () { File('$_docBasepath/app_background_image').deleteSync(); + _prefs?.remove('has_background_image'); setState(() {}); }, ); diff --git a/lib/theme.dart b/lib/theme.dart index 9575efd..bec7f77 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -1,4 +1,8 @@ +import 'dart:io'; + +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; const kMaterialYouToggleStoreKey = 'app_theme_material_you'; @@ -28,9 +32,10 @@ Future createAppTheme( brightness: brightness, ); + final hasBackground = prefs.getBool('has_background_image') ?? false; + return ThemeData( - useMaterial3: - useMaterial3 ?? (prefs.getBool(kMaterialYouToggleStoreKey) ?? false), + useMaterial3: useMaterial3 ?? (prefs.getBool(kMaterialYouToggleStoreKey) ?? false), colorScheme: colorScheme, brightness: brightness, iconTheme: IconThemeData( @@ -41,6 +46,8 @@ Future createAppTheme( ), appBarTheme: AppBarTheme( centerTitle: true, + backgroundColor: hasBackground ? colorScheme.primary.withOpacity(0.75) : colorScheme.primary, + foregroundColor: colorScheme.onPrimary, ), scaffoldBackgroundColor: Colors.transparent, );