2022-06-16 20:30:02 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-06-28 20:05:24 +00:00
|
|
|
import 'package:intl/intl.dart';
|
2022-06-17 10:38:28 +00:00
|
|
|
import 'package:localization/localization.dart';
|
2022-09-02 21:19:25 +00:00
|
|
|
import 'package:loris/pages/settings/app.dart';
|
2022-08-06 14:50:30 +00:00
|
|
|
import 'package:loris/partials/main_scaffold.dart';
|
2022-06-16 20:30:02 +00:00
|
|
|
import 'pages/login.dart';
|
2022-07-01 22:41:37 +00:00
|
|
|
import 'business_logic/settings.dart' as settings;
|
2022-06-17 12:13:45 +00:00
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2022-07-02 17:32:44 +00:00
|
|
|
import 'themes/themes.dart' as themes;
|
2022-07-03 13:47:24 +00:00
|
|
|
import 'global.dart' as global;
|
2022-06-16 20:30:02 +00:00
|
|
|
|
2022-09-02 21:19:25 +00:00
|
|
|
ThemeData theme = themes.getTheme(themes.available[1]);
|
2022-08-29 21:38:14 +00:00
|
|
|
Locale activeLocale = const Locale("en_US");
|
2022-07-01 22:41:37 +00:00
|
|
|
|
|
|
|
void main() async {
|
2022-08-29 21:38:14 +00:00
|
|
|
Intl.defaultLocale = "en_US";
|
2022-08-12 17:00:09 +00:00
|
|
|
global.settings = await settings.Settings.create();
|
|
|
|
activeLocale = global.settings!.locale;
|
2022-06-28 20:05:24 +00:00
|
|
|
|
2022-07-01 22:41:37 +00:00
|
|
|
// check if all information is available
|
2022-08-14 08:59:47 +00:00
|
|
|
if (global.settings!.identities.isNotEmpty) {
|
2022-08-14 11:32:26 +00:00
|
|
|
// await oauth.refreshToken();
|
2022-07-01 22:41:37 +00:00
|
|
|
}
|
2022-08-06 14:50:30 +00:00
|
|
|
runApp(const Loris());
|
2022-06-28 20:05:24 +00:00
|
|
|
}
|
2022-06-17 12:13:45 +00:00
|
|
|
|
2022-08-06 14:50:30 +00:00
|
|
|
class Loris extends StatefulWidget {
|
|
|
|
const Loris({Key? key}) : super(key: key);
|
2022-06-17 12:13:45 +00:00
|
|
|
|
|
|
|
@override
|
2022-08-06 14:50:30 +00:00
|
|
|
State<Loris> createState() => _LorisState();
|
2022-06-17 12:13:45 +00:00
|
|
|
}
|
|
|
|
|
2022-08-06 14:50:30 +00:00
|
|
|
class _LorisState extends State<Loris> {
|
2022-09-02 21:19:25 +00:00
|
|
|
var theme = global.settings!.theme;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
themeStream.stream.listen((event) {
|
|
|
|
setState(() {
|
|
|
|
theme = event;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2022-06-17 12:13:45 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
LocalJsonLocalization.delegate.directories = ['lib/i18n'];
|
2022-08-14 11:32:26 +00:00
|
|
|
return MaterialApp(
|
2022-09-02 21:19:25 +00:00
|
|
|
theme: themes.getTheme(theme),
|
2022-08-14 11:32:26 +00:00
|
|
|
locale: activeLocale,
|
|
|
|
supportedLocales: global.availableLocales,
|
|
|
|
localizationsDelegates: [
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
LocalJsonLocalization.delegate,
|
|
|
|
],
|
|
|
|
initialRoute: global.settings!.identities.isEmpty ? "/login" : "/",
|
|
|
|
routes: {
|
|
|
|
'/': (context) => const MainScaffold(),
|
|
|
|
'/login': (context) => const Login(),
|
|
|
|
},
|
2022-06-17 12:13:45 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|