From d986986c97b003dddc8511f2d1320dbb3497642f Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sun, 16 May 2021 16:44:21 +0200 Subject: [PATCH] fix: Status bar and system navigation bar theme --- lib/config/themes.dart | 11 +++++++++ lib/main.dart | 55 +++++++++++++++--------------------------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/lib/config/themes.dart b/lib/config/themes.dart index 86aa109a..9699d214 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:fluffychat/utils/platform_infos.dart'; +import 'package:flutter/services.dart'; import 'app_config.dart'; @@ -98,6 +99,11 @@ abstract class FluffyThemes { appBarTheme: AppBarTheme( brightness: Brightness.light, color: Colors.white, + systemOverlayStyle: SystemUiOverlayStyle( + systemNavigationBarColor: Colors.white, + systemNavigationBarIconBrightness: Brightness.dark, + statusBarColor: Colors.transparent, + ), textTheme: TextTheme( headline6: TextStyle( color: Colors.black, @@ -176,6 +182,11 @@ abstract class FluffyThemes { appBarTheme: AppBarTheme( brightness: Brightness.dark, color: Color(0xff1D1D1D), + systemOverlayStyle: SystemUiOverlayStyle( + systemNavigationBarColor: Colors.black, + systemNavigationBarIconBrightness: Brightness.light, + statusBarColor: Colors.transparent, + ), textTheme: TextTheme( headline6: TextStyle( color: Colors.white, diff --git a/lib/main.dart b/lib/main.dart index a6806228..2114f2c9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,7 +10,6 @@ import 'package:fluffychat/utils/sentry_controller.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_app_lock/flutter_app_lock.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:universal_html/html.dart' as html; @@ -82,41 +81,25 @@ class FluffyChatApp extends StatelessWidget { apl: _apl, testClient: testClient, child: Builder( - builder: (context) { - final darkMode = - Theme.of(context).brightness == Brightness.dark; - final brightness = - darkMode ? Brightness.light : Brightness.dark; - WidgetsBinding.instance.addPostFrameCallback((_) { - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( - systemNavigationBarColor: - Theme.of(context).scaffoldBackgroundColor, - statusBarColor: Colors.transparent, - statusBarBrightness: brightness, - statusBarIconBrightness: brightness, - systemNavigationBarIconBrightness: brightness, - )); - }); - return AdaptivePageLayout( - key: _apl, - safeAreaOnColumnView: false, - onGenerateRoute: testWidget == null - ? FluffyRoutes(context).onGenerateRoute - : (_) => ViewData(mainView: (_) => testWidget), - dividerColor: Theme.of(context).dividerColor, - columnWidth: FluffyThemes.columnWidth, - dividerWidth: 1.0, - routeBuilder: (builder, settings) => - Matrix.of(context).loginState == LoginState.logged && - !{ - '/', - '/search', - '/contacts', - }.contains(settings.name) - ? MaterialPageRoute(builder: builder) - : FadeRoute(page: builder(context)), - ); - }, + builder: (context) => AdaptivePageLayout( + key: _apl, + safeAreaOnColumnView: false, + onGenerateRoute: testWidget == null + ? FluffyRoutes(context).onGenerateRoute + : (_) => ViewData(mainView: (_) => testWidget), + dividerColor: Theme.of(context).dividerColor, + columnWidth: FluffyThemes.columnWidth, + dividerWidth: 1.0, + routeBuilder: (builder, settings) => + Matrix.of(context).loginState == LoginState.logged && + !{ + '/', + '/search', + '/contacts', + }.contains(settings.name) + ? MaterialPageRoute(builder: builder) + : FadeRoute(page: builder(context)), + ), ), ), ),