an attempt at changing systemnavigationbarcolor

This commit is contained in:
shilangyu 2020-09-17 00:25:19 +02:00
parent a08a7c5b93
commit c38dee0e73
1 changed files with 18 additions and 39 deletions

View File

@ -1,4 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:lemmur/pages/profile_tab.dart'; import 'package:lemmur/pages/profile_tab.dart';
@ -45,7 +48,7 @@ class MyApp extends HookWidget {
configStore.amoledDarkMode ? Colors.black : null; configStore.amoledDarkMode ? Colors.black : null;
return MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'Lemmur',
themeMode: configStore.theme, themeMode: configStore.theme,
darkTheme: ThemeData.dark().copyWith( darkTheme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: maybeAmoledColor, scaffoldBackgroundColor: maybeAmoledColor,
@ -57,52 +60,28 @@ class MyApp extends HookWidget {
theme: ThemeData( theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
), ),
home: UserProfileTab(), home: MyHomePage(),
); );
}, },
); );
} }
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends HookWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override @override
_MyHomePageState createState() => _MyHomePageState(); Widget build(BuildContext context) {
} final theme = Theme.of(context);
class _MyHomePageState extends State<MyHomePage> { useEffect(() {
int _counter = 0; print('about to change');
print(theme.scaffoldBackgroundColor);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
systemNavigationBarColor: theme.scaffoldBackgroundColor,
));
void _incrementCounter() { return null;
setState(() { }, [theme.scaffoldBackgroundColor]);
_counter++;
}); return UserProfileTab();
} }
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('You have pushed the button this many times:'),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
} }