diff --git a/lib/main.dart b/lib/main.dart index 1fdb2af9..acdbe933 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -72,6 +72,7 @@ import 'services/jellyfin_api_helper.dart'; import 'services/locale_helper.dart'; import 'services/music_player_background_task.dart'; import 'services/theme_mode_helper.dart'; +import 'services/ui_overlay_setter_observer.dart'; import 'setup_logging.dart'; void main() async { @@ -79,6 +80,7 @@ void main() async { bool hasFailed = false; try { await setupLogging(); + await _setupEdgeToEdgeOverlayStyle(); await setupHive(); _migrateDownloadLocations(); _migrateSortOptions(); @@ -119,6 +121,15 @@ void main() async { } } +Future _setupEdgeToEdgeOverlayStyle() async { + if (Platform.isAndroid) { + await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); + SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(systemNavigationBarColor: Colors.transparent)); + final binding = WidgetsFlutterBinding.ensureInitialized(); + binding.addObserver(UIOverlaySetterObserver()); + } +} + Future _setupJellyfinApiData() async { GetIt.instance.registerSingleton(JellyfinApiHelper()); } diff --git a/lib/services/ui_overlay_setter_observer.dart b/lib/services/ui_overlay_setter_observer.dart new file mode 100644 index 00000000..beed2372 --- /dev/null +++ b/lib/services/ui_overlay_setter_observer.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class UIOverlaySetterObserver extends WidgetsBindingObserver { + @override + void didChangeAppLifecycleState(AppLifecycleState state) async { + switch (state) { + case AppLifecycleState.resumed: + SystemChrome.setSystemUIOverlayStyle( + const SystemUiOverlayStyle( + systemNavigationBarColor: Colors.transparent, + ), + ); + await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); + break; + default: + break; + } + } +} \ No newline at end of file