2023-06-17 21:50:52 +00:00
|
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
2023-07-15 16:22:25 +00:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2023-06-17 21:50:52 +00:00
|
|
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
2023-07-10 17:42:20 +00:00
|
|
|
import 'package:tetra_stats/gen/strings.g.dart';
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2023-06-17 21:50:52 +00:00
|
|
|
import 'package:tetra_stats/views/main_view.dart';
|
|
|
|
import 'package:tetra_stats/views/settings_view.dart';
|
|
|
|
import 'package:tetra_stats/views/tracked_players_view.dart';
|
|
|
|
import 'package:tetra_stats/views/calc_view.dart';
|
|
|
|
|
2023-07-15 16:22:25 +00:00
|
|
|
void main() async {
|
2023-06-17 21:50:52 +00:00
|
|
|
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
|
|
|
sqfliteFfiInit();
|
|
|
|
databaseFactory = databaseFactoryFfi;
|
|
|
|
}
|
2023-07-15 16:22:25 +00:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
prefs = await SharedPreferences.getInstance();
|
|
|
|
String? locale = prefs.getString("locale");
|
|
|
|
if (locale == null){
|
|
|
|
LocaleSettings.useDeviceLocale();
|
|
|
|
}else{
|
|
|
|
LocaleSettings.setLocaleRaw(locale);
|
|
|
|
}
|
2023-07-10 17:42:20 +00:00
|
|
|
runApp(TranslationProvider(
|
|
|
|
child: MyApp(),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
2023-07-15 16:22:25 +00:00
|
|
|
const MyApp({super.key});
|
|
|
|
|
2023-07-10 17:42:20 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
home: const MainView(),
|
|
|
|
locale: TranslationProvider.of(context).flutterLocale,
|
|
|
|
supportedLocales: AppLocaleUtils.supportedLocales,
|
|
|
|
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
|
|
|
routes: {"/settings": (context) => const SettingsView(), "/states": (context) => const TrackedPlayersView(), "/calc": (context) => const CalcView()},
|
|
|
|
theme: ThemeData(
|
|
|
|
fontFamily: 'Eurostile Round',
|
|
|
|
colorScheme: const ColorScheme.dark(primary: Colors.cyanAccent, secondary: Colors.white),
|
|
|
|
scaffoldBackgroundColor: Colors.black
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2023-06-17 21:50:52 +00:00
|
|
|
}
|