From 7c4409b2ec67c3f065a3b794bd9f23a17e149296 Mon Sep 17 00:00:00 2001 From: Shubham Date: Tue, 9 Jan 2024 16:32:28 +0530 Subject: [PATCH] Fix #726: Status bar wrong theme in dark mode --- lib/config/themes.dart | 23 ++++++++++++++++------- lib/pages/chat_list/chat_list.dart | 5 ----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/config/themes.dart b/lib/config/themes.dart index f03c74d4f..e97eac25a 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -67,6 +67,11 @@ abstract class FluffyThemes { brightness: brightness, seedColor: seed ?? AppConfig.colorSchemeSeed ?? AppConfig.primaryColor, ); + // Sets status and navigation bar style whenever buildTheme called + SystemChrome.setSystemUIOverlayStyle( + getOverlayStyle(brightness, colorScheme), + ); + return ThemeData( visualDensity: VisualDensity.standard, useMaterial3: true, @@ -99,13 +104,7 @@ abstract class FluffyThemes { toolbarHeight: FluffyThemes.isColumnMode(context) ? 72 : 56, shadowColor: Colors.grey.withAlpha(64), surfaceTintColor: colorScheme.background, - systemOverlayStyle: SystemUiOverlayStyle( - statusBarColor: Colors.transparent, - statusBarIconBrightness: brightness.reversed, - statusBarBrightness: brightness, - systemNavigationBarIconBrightness: brightness.reversed, - systemNavigationBarColor: colorScheme.background, - ), + systemOverlayStyle: getOverlayStyle(brightness, colorScheme), ), textButtonTheme: TextButtonThemeData( style: TextButton.styleFrom( @@ -142,6 +141,16 @@ abstract class FluffyThemes { ), ); } + + static getOverlayStyle(Brightness brightness, ColorScheme colorScheme) { + return SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + statusBarIconBrightness: brightness.reversed, + statusBarBrightness: brightness, + systemNavigationBarIconBrightness: brightness.reversed, + systemNavigationBarColor: colorScheme.background, + ); + } } extension on Brightness { diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 8968121d5..0878ad1e9 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -392,11 +392,6 @@ class ChatListController extends State Matrix.of(context).store.getString(_serverStoreNamespace); Matrix.of(context).backgroundPush?.setupPush(); } - - // Workaround for system UI overlay style not applied on app start - SystemChrome.setSystemUIOverlayStyle( - Theme.of(context).appBarTheme.systemOverlayStyle!, - ); }); _checkTorBrowser();