From 56480cca0acbd44bf9ea337a1801eb64ac1d77d2 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sat, 7 Jan 2023 12:14:18 +0300 Subject: [PATCH] Fixed navigation bar color Cleanup --- lib/application.dart | 66 ++++++++----------- .../shared/widget_dialog_animated.dart | 2 +- 2 files changed, 28 insertions(+), 40 deletions(-) diff --git a/lib/application.dart b/lib/application.dart index b53b1ee..243608f 100644 --- a/lib/application.dart +++ b/lib/application.dart @@ -15,63 +15,51 @@ import 'utils/stop_type_provider.dart'; final RouteObserver routeObserver = RouteObserver(); -class Application extends StatefulWidget { +class Application extends StatelessWidget { final EvSourceType evSource; const Application(this.evSource, {super.key}); - @override - State createState() => _ApplicationState(); -} - -class _ApplicationState extends State { - @override - void initState() { - super.initState(); - final mySystemTheme = SystemUiOverlayStyle.light.copyWith( - statusBarColor: Colors.transparent, - statusBarBrightness: Brightness.light, - statusBarIconBrightness: Brightness.dark, - systemNavigationBarColor: Colors.transparent, - systemNavigationBarIconBrightness: Brightness.dark, - ); - SystemChrome.setSystemUIOverlayStyle(mySystemTheme); - } - @override Widget build(BuildContext context) { return FutureBuilder( future: SharedPreferences.getInstance(), - builder: (context, snapshot) { + builder: (_, snapshot) { if (snapshot.data != null) { return MultiProvider( providers: [ Provider(create: (_) => UserPreferencesService(snapshot.data!)), - Provider.value(value: widget.evSource), + Provider.value(value: evSource), ], child: Provider( - create: (context) => PermissionsService(), + create: (_) => PermissionsService(), child: StopTypeProvider( child: ThemeProvider( initialPrimaryColor: const Color(0xFF2196f3), - builder: (context, child) => MaterialApp( - theme: context.watch(), - localizationsDelegates: const [ - S.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: S.delegate.supportedLocales, - builder: (context, child) => MediaQuery( - data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), - child: child!, + builder: (context, child) => AnnotatedRegion( + value: SystemUiOverlayStyle( + statusBarColor: context.watch().colorScheme.surface, + systemNavigationBarColor: context.watch().colorScheme.surface, + ), + child: MaterialApp( + theme: context.watch(), + localizationsDelegates: const [ + S.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: S.delegate.supportedLocales, + builder: (context, child) => MediaQuery( + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), + child: child!, + ), + initialRoute: "metering", + routes: { + "metering": (context) => const MeteringFlow(), + "settings": (context) => const SettingsScreen(), + }, ), - home: const MeteringFlow(), - routes: { - "metering": (context) => const MeteringFlow(), - "settings": (context) => const SettingsScreen(), - }, ), ), ), diff --git a/lib/screens/metering/components/topbar/components/shared/widget_dialog_animated.dart b/lib/screens/metering/components/topbar/components/shared/widget_dialog_animated.dart index 9dbf0a5..04de475 100644 --- a/lib/screens/metering/components/topbar/components/shared/widget_dialog_animated.dart +++ b/lib/screens/metering/components/topbar/components/shared/widget_dialog_animated.dart @@ -80,7 +80,7 @@ class AnimatedDialogState extends State with SingleTickerProvide ), )); - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + WidgetsBinding.instance.addPostFrameCallback((_) { final mediaQuery = MediaQuery.of(context); _closedSize = _key.currentContext!.size!;