From c21055c56ff12a6b7170a0b377e459e5042f01c5 Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Tue, 19 Nov 2024 18:43:37 +0100 Subject: [PATCH] fix status bar icon contrast on player screen on Android - fixes #957 and #798 --- lib/main.dart | 13 +++++++------ lib/screens/player_screen.dart | 7 ++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 4b79fd28..db117ef8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -109,11 +109,6 @@ void main() async { FlutterError.presentError(details); flutterLogger.severe(error, error, details.stack); }; - // On iOS, the status bar will have black icons by default on the login - // screen as it does not have an AppBar. To fix this, we set the - // brightness to dark manually on startup. - SystemChrome.setSystemUIOverlayStyle( - const SystemUiOverlayStyle(statusBarBrightness: Brightness.dark)); await findSystemLocale(); await initializeDateFormatting(); @@ -129,6 +124,12 @@ Future _setupEdgeToEdgeOverlayStyle() async { systemNavigationBarColor: Colors.transparent)); final binding = WidgetsFlutterBinding.ensureInitialized(); binding.addObserver(UIOverlaySetterObserver()); + } else if (Platform.isIOS) { + // On iOS, the status bar will have black icons by default on the login + // screen as it does not have an AppBar. To fix this, we set the + // brightness to dark manually on startup. + SystemChrome.setSystemUIOverlayStyle( + const SystemUiOverlayStyle(statusBarBrightness: Brightness.dark)); } } @@ -442,7 +443,7 @@ class _FinampState extends ConsumerState with WindowListener { } @override - Widget build(BuildContext context) { + Widget build(BuildContext context) { return ProviderScope( child: GestureDetector( onTap: () { diff --git a/lib/screens/player_screen.dart b/lib/screens/player_screen.dart index d2545bf7..a1e15700 100644 --- a/lib/screens/player_screen.dart +++ b/lib/screens/player_screen.dart @@ -15,6 +15,7 @@ import 'package:finamp/services/finamp_settings_helper.dart'; import 'package:finamp/services/queue_service.dart'; import 'package:finamp/services/theme_provider.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_tabler_icons/flutter_tabler_icons.dart'; @@ -217,6 +218,9 @@ class _PlayerScreenContent extends ConsumerWidget { child: Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, + systemOverlayStyle: Theme.of(context).brightness == Brightness.dark + ? SystemUiOverlayStyle.light + : SystemUiOverlayStyle.dark, elevation: 0, scrolledUnderElevation: 0.0, // disable tint/shadow when content is scrolled under the app bar @@ -249,7 +253,8 @@ class _PlayerScreenContent extends ConsumerWidget { ], ), // Required for sleep timer input - resizeToAvoidBottomInset: false, extendBodyBehindAppBar: true, + resizeToAvoidBottomInset: false, + extendBodyBehindAppBar: true, body: Stack( children: [ if (FinampSettingsHelper.finampSettings.useCoverAsBackground)