2020-09-17 00:25:19 +02:00
|
|
|
import 'dart:async';
|
|
|
|
|
2020-08-02 13:34:42 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2020-09-17 00:25:19 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2020-09-16 23:15:42 +02:00
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
2020-08-30 22:43:16 +02:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
2020-09-16 23:15:42 +02:00
|
|
|
import 'hooks/stores.dart';
|
2020-09-17 00:29:35 +02:00
|
|
|
import 'pages/profile_tab.dart';
|
2020-09-01 13:22:37 +02:00
|
|
|
import 'stores/accounts_store.dart';
|
2020-08-30 22:43:16 +02:00
|
|
|
import 'stores/config_store.dart';
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-08-31 17:52:16 +02:00
|
|
|
Future<void> main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
2020-09-16 23:22:04 +02:00
|
|
|
final configStore = ConfigStore();
|
2020-08-31 17:52:16 +02:00
|
|
|
await configStore.load();
|
|
|
|
|
2020-09-16 23:22:04 +02:00
|
|
|
final accountsStore = AccountsStore();
|
2020-09-01 13:22:37 +02:00
|
|
|
await accountsStore.load();
|
|
|
|
|
2020-08-30 22:43:16 +02:00
|
|
|
runApp(
|
|
|
|
MultiProvider(
|
|
|
|
providers: [
|
|
|
|
Provider<ConfigStore>(
|
2020-08-31 17:52:16 +02:00
|
|
|
create: (_) => configStore,
|
2020-08-30 22:43:16 +02:00
|
|
|
dispose: (_, store) => store.dispose(),
|
|
|
|
),
|
2020-09-01 13:22:37 +02:00
|
|
|
Provider<AccountsStore>(
|
|
|
|
create: (_) => accountsStore,
|
|
|
|
dispose: (_, store) => store.dispose(),
|
|
|
|
),
|
2020-08-30 22:43:16 +02:00
|
|
|
],
|
|
|
|
child: MyApp(),
|
|
|
|
),
|
|
|
|
);
|
2020-08-02 13:34:42 +02:00
|
|
|
}
|
|
|
|
|
2020-09-16 23:15:42 +02:00
|
|
|
class MyApp extends HookWidget {
|
2020-08-02 13:34:42 +02:00
|
|
|
@override
|
2020-09-16 23:15:42 +02:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final configStore = useConfigStore();
|
|
|
|
|
|
|
|
return Observer(
|
|
|
|
builder: (ctx) {
|
|
|
|
final maybeAmoledColor =
|
|
|
|
configStore.amoledDarkMode ? Colors.black : null;
|
|
|
|
|
|
|
|
return MaterialApp(
|
2020-09-17 00:25:19 +02:00
|
|
|
title: 'Lemmur',
|
2020-09-16 23:15:42 +02:00
|
|
|
themeMode: configStore.theme,
|
|
|
|
darkTheme: ThemeData.dark().copyWith(
|
|
|
|
scaffoldBackgroundColor: maybeAmoledColor,
|
|
|
|
backgroundColor: maybeAmoledColor,
|
|
|
|
canvasColor: maybeAmoledColor,
|
|
|
|
cardColor: maybeAmoledColor,
|
|
|
|
splashColor: maybeAmoledColor,
|
|
|
|
),
|
|
|
|
theme: ThemeData(
|
|
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
|
|
),
|
2020-09-17 00:25:19 +02:00
|
|
|
home: MyHomePage(),
|
2020-09-16 23:15:42 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2020-08-02 13:34:42 +02:00
|
|
|
}
|
|
|
|
|
2020-09-17 00:25:19 +02:00
|
|
|
class MyHomePage extends HookWidget {
|
2020-08-02 13:34:42 +02:00
|
|
|
@override
|
2020-09-17 00:25:19 +02:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Theme.of(context);
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-09-17 00:25:19 +02:00
|
|
|
useEffect(() {
|
2020-09-17 00:29:35 +02:00
|
|
|
Future.microtask(
|
|
|
|
() => SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
|
|
|
systemNavigationBarColor: theme.scaffoldBackgroundColor,
|
|
|
|
)),
|
|
|
|
);
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-09-17 00:25:19 +02:00
|
|
|
return null;
|
|
|
|
}, [theme.scaffoldBackgroundColor]);
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-09-17 00:25:19 +02:00
|
|
|
return UserProfileTab();
|
|
|
|
}
|
2020-08-02 13:34:42 +02:00
|
|
|
}
|