Match navigation bar color with theme

This commit is contained in:
Ming Ming 2023-08-05 03:32:54 +08:00
parent 9201e394ac
commit ad5146607a
2 changed files with 23 additions and 4 deletions

View file

@ -20,9 +20,6 @@ void main() async {
if (platform_k.isMobile) {
// reset orientation override just in case, see #59
unawaited(SystemChrome.setPreferredOrientations([]));
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
));
}
Bloc.observer = const _BlocObserver();
Bloc.transformer = sequential();

View file

@ -1,6 +1,7 @@
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:kiwi/kiwi.dart';
@ -148,7 +149,7 @@ class _WrappedAppState extends State<_WrappedApp>
],
builder: (context, child) {
MyApp._globalContext = context;
return child!;
return _ThemedMyApp(child: child!);
},
debugShowCheckedModeBanner: false,
scrollBehavior: const _MyScrollBehavior(),
@ -605,6 +606,27 @@ class _WrappedAppState extends State<_WrappedApp>
late AppEventListener<ThemeChangedEvent> _themeChangedListener;
}
class _ThemedMyApp extends StatelessWidget {
const _ThemedMyApp({
required this.child,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
// set status bar and navigation bar color
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
systemNavigationBarColor: theme.colorScheme.secondaryContainer,
),
child: child,
);
}
final Widget child;
}
class _MyScrollBehavior extends MaterialScrollBehavior {
const _MyScrollBehavior();