-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
88 lines (81 loc) · 2.81 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import 'dart:async';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_phoenix/flutter_phoenix.dart';
import 'package:get/route_manager.dart';
import 'package:kanbasu/models/model.dart';
import 'package:kanbasu/models/resolver_model.dart';
import 'package:kanbasu/router.dart';
import 'package:kanbasu/utils/timeago_zh_cn.dart';
import 'package:kanbasu/widgets/offline_mode.dart';
import 'package:provider/provider.dart';
import 'home.dart';
import 'buffer_api/kvstore.dart';
import 'package:easy_localization_loader/easy_localization_loader.dart';
import 'package:timeago/timeago.dart' as timeago;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
KvStore.initFfi();
timeago.setLocaleMessages('zh_CN', KZhCnMessages());
final model = Model();
await model.init();
return runApp(EasyLocalization(
supportedLocales: [
Locale('zh', 'CN'),
Locale('en', 'US'),
],
startLocale: Locale('zh', 'CN'),
fallbackLocale: Locale('en', 'US'),
useFallbackTranslations: true,
path: 'assets/translations',
assetLoader: YamlAssetLoader(),
child: MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => model),
ChangeNotifierProxyProvider<Model, ResolverModel>(
create: (_) => ResolverModel(),
update: (_, model, notifier) => notifier!..updateModel(model))
],
child: Phoenix(child: MyApp()), // for rebirthing the app
),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final model = context.watch<Model>();
final theme = model.theme;
final themeData = ThemeData(
brightness: model.brightness,
primarySwatch: Colors.red,
primaryColor: theme.primary,
scaffoldBackgroundColor: theme.background,
primaryTextTheme: TextTheme(
headline6: TextStyle(color: theme.text),
),
tabBarTheme: TabBarTheme(labelColor: theme.text),
appBarTheme: AppBarTheme(
backgroundColor: theme.grayBackground,
foregroundColor: theme.text,
actionsIconTheme: IconThemeData(color: theme.text),
iconTheme: IconThemeData(color: theme.text),
),
pageTransitionsTheme: PageTransitionsTheme(builders: {}),
indicatorColor: theme.primary,
);
return GetMaterialApp(
title: 'Kanbasu',
darkTheme: themeData,
theme: themeData,
locale: context.locale,
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
defaultTransition: Transition.fade,
getPages: getPages,
debugShowCheckedModeBanner: false,
builder: (_, child) => OfflineModeWrapper(child: child),
home: Home(),
);
}
}