1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-29 16:26:27 +00:00
comunicmobile/lib/main.dart

63 lines
1.7 KiB
Dart
Raw Normal View History

2019-04-23 16:11:19 +00:00
import 'package:comunic/helpers/account_helper.dart';
2019-04-24 09:24:05 +00:00
import 'package:comunic/helpers/database/database_helper.dart';
2019-11-01 12:48:40 +00:00
import 'package:comunic/helpers/preferences_helper.dart';
import 'package:comunic/helpers/version_helper.dart';
2020-04-17 13:25:26 +00:00
import 'package:comunic/ui/widgets/init_widget.dart';
2020-03-28 16:11:11 +00:00
import 'package:comunic/utils/intl_utils.dart';
2019-04-21 08:34:27 +00:00
import 'package:flutter/material.dart';
/// Main file of the application
///
/// @author Pierre HUBERT
2019-11-01 12:48:40 +00:00
void subMain() async {
WidgetsFlutterBinding.ensureInitialized();
// Load package information
await VersionHelper.ensureLoaded();
2019-04-24 09:24:05 +00:00
// Connect to database
2019-11-01 12:48:40 +00:00
await DatabaseHelper.open();
2020-04-17 09:53:47 +00:00
await DatabaseHelper.cleanUpDatabase();
2019-04-24 09:24:05 +00:00
2020-03-28 16:11:11 +00:00
// Get current system language
await initTranslations();
2020-05-09 11:50:18 +00:00
// Check if the user is currently signed in
await AccountHelper().signedIn();
2020-05-09 11:50:18 +00:00
2019-11-01 12:48:40 +00:00
runApp(ComunicApplication(
2020-05-12 17:00:35 +00:00
preferences: await PreferencesHelper.getInstance(),
2019-11-01 12:48:40 +00:00
));
2019-04-21 08:34:27 +00:00
}
class ComunicApplication extends StatefulWidget {
2020-05-12 17:00:35 +00:00
final PreferencesHelper preferences;
2020-05-09 11:50:18 +00:00
const ComunicApplication({
Key key,
2020-05-12 17:00:35 +00:00
@required this.preferences,
}) : assert(preferences != null),
2019-11-01 12:48:40 +00:00
super(key: key);
@override
ComunicApplicationState createState() => ComunicApplicationState();
}
class ComunicApplicationState extends State<ComunicApplication> {
/// Use this method to force the application to rebuild
void refresh() => setState(() {});
2019-04-21 08:34:27 +00:00
@override
Widget build(BuildContext context) {
2020-05-13 16:26:21 +00:00
final prefs = widget.preferences.preferences;
2019-04-21 08:34:27 +00:00
return MaterialApp(
2019-04-21 09:44:07 +00:00
debugShowCheckedModeBanner: false,
home: InitializeWidget(),
2020-05-13 16:26:21 +00:00
theme: prefs.enableDarkMode ? ThemeData.dark() : null,
showPerformanceOverlay: prefs.showPerformancesOverlay,
2019-04-21 08:34:27 +00:00
);
}
}