2023-06-17 21:50:52 +00:00
|
|
|
import 'dart:io';
|
2023-07-20 20:56:00 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/gestures.dart';
|
2023-06-17 21:50:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-10-09 18:48:50 +00:00
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
2023-07-15 16:22:25 +00:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2023-10-19 21:45:07 +00:00
|
|
|
import 'package:tetra_stats/views/customization_view.dart';
|
2023-10-08 17:20:42 +00:00
|
|
|
import 'package:window_manager/window_manager.dart';
|
2023-06-17 21:50:52 +00:00
|
|
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
2023-07-20 20:56:00 +00:00
|
|
|
import 'package:sqflite_common_ffi_web/sqflite_ffi_web.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-10-09 18:48:50 +00:00
|
|
|
late final PackageInfo packageInfo;
|
2023-10-26 22:38:03 +00:00
|
|
|
late SharedPreferences prefs;
|
2023-10-28 22:05:56 +00:00
|
|
|
ColorScheme sheme = ColorScheme.dark(primary: Colors.cyanAccent, secondary: Colors.white);
|
|
|
|
|
|
|
|
void setAccentColor(Color color){
|
|
|
|
sheme = ColorScheme.dark(primary: color, secondary: Colors.white);
|
|
|
|
}
|
2023-10-09 18:48:50 +00:00
|
|
|
|
2023-07-15 16:22:25 +00:00
|
|
|
void main() async {
|
2023-07-20 20:56:00 +00:00
|
|
|
if (kIsWeb) {
|
|
|
|
sqfliteFfiInit();
|
|
|
|
databaseFactory = databaseFactoryFfiWeb;
|
|
|
|
} else if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
2023-06-17 21:50:52 +00:00
|
|
|
sqfliteFfiInit();
|
|
|
|
databaseFactory = databaseFactoryFfi;
|
|
|
|
}
|
2023-07-15 16:22:25 +00:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2023-10-10 20:20:27 +00:00
|
|
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS){
|
2023-10-09 18:48:50 +00:00
|
|
|
await WindowManager.instance.ensureInitialized();
|
|
|
|
windowManager.waitUntilReadyToShow().then((_) async {
|
2023-10-08 17:20:42 +00:00
|
|
|
await windowManager.setTitle('Tetra Stats');
|
2023-10-09 18:48:50 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
packageInfo = await PackageInfo.fromPlatform();
|
2023-07-15 16:22:25 +00:00
|
|
|
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(
|
2023-08-21 15:39:04 +00:00
|
|
|
child: const MyApp(),
|
2023-07-10 17:42:20 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
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(
|
2023-07-20 20:56:00 +00:00
|
|
|
title: "Tetra Stats",
|
2023-07-10 17:42:20 +00:00
|
|
|
home: const MainView(),
|
2023-08-21 15:39:04 +00:00
|
|
|
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
2023-07-20 20:56:00 +00:00
|
|
|
dragDevices: {PointerDeviceKind.mouse, PointerDeviceKind.touch, PointerDeviceKind.stylus, PointerDeviceKind.unknown},
|
|
|
|
),
|
2023-07-10 17:42:20 +00:00
|
|
|
locale: TranslationProvider.of(context).flutterLocale,
|
|
|
|
supportedLocales: AppLocaleUtils.supportedLocales,
|
|
|
|
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
2023-10-19 21:45:07 +00:00
|
|
|
routes: {"/settings": (context) => const SettingsView(), "/states": (context) => const TrackedPlayersView(), "/calc": (context) => const CalcView(), "/customization": (context) => const CustomizationView()},
|
2023-07-10 17:42:20 +00:00
|
|
|
theme: ThemeData(
|
|
|
|
fontFamily: 'Eurostile Round',
|
2023-10-28 22:05:56 +00:00
|
|
|
colorScheme: sheme,
|
2023-07-10 17:42:20 +00:00
|
|
|
scaffoldBackgroundColor: Colors.black
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2023-06-17 21:50:52 +00:00
|
|
|
}
|