113 lines
4.2 KiB
Dart
113 lines
4.2 KiB
Dart
// ignore_for_file: depend_on_referenced_packages
|
|
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
|
import 'package:flex_color_scheme/flex_color_scheme.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:intl/date_symbol_data_local.dart';
|
|
import 'package:isar/isar.dart';
|
|
import 'package:mangayomi/providers/storage_provider.dart';
|
|
import 'package:mangayomi/router/router.dart';
|
|
import 'package:mangayomi/modules/more/settings/appearance/providers/blend_level_state_provider.dart';
|
|
import 'package:mangayomi/modules/more/settings/appearance/providers/flex_scheme_color_state_provider.dart';
|
|
import 'package:mangayomi/modules/more/settings/appearance/providers/pure_black_dark_mode_state_provider.dart';
|
|
import 'package:mangayomi/modules/more/settings/appearance/providers/theme_mode_state_provider.dart';
|
|
|
|
late Isar isar;
|
|
void main(List<String> args) async {
|
|
if (runWebViewTitleBarWidget(args)) {
|
|
return;
|
|
}
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
isar = await StorageProvider().initDB(null);
|
|
await StorageProvider().requestPermission();
|
|
runApp(const ProviderScope(child: MyApp()));
|
|
}
|
|
|
|
_iniDateFormatting() {
|
|
initializeDateFormatting("en", null);
|
|
initializeDateFormatting("fr", null);
|
|
initializeDateFormatting("ar", null);
|
|
initializeDateFormatting("es", null);
|
|
initializeDateFormatting("pt", null);
|
|
initializeDateFormatting("ru", null);
|
|
initializeDateFormatting("hi", null);
|
|
initializeDateFormatting("id", null);
|
|
initializeDateFormatting("it", null);
|
|
initializeDateFormatting("de", null);
|
|
initializeDateFormatting("ja", null);
|
|
initializeDateFormatting("zh", null);
|
|
initializeDateFormatting("pl", null);
|
|
initializeDateFormatting("tr", null);
|
|
}
|
|
|
|
class MyApp extends ConsumerStatefulWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
ConsumerState<MyApp> createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends ConsumerState<MyApp> {
|
|
@override
|
|
void initState() {
|
|
_iniDateFormatting();
|
|
super.initState();
|
|
}
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDarkTheme = ref.watch(themeModeStateProvider);
|
|
final blendLevel = ref.watch(blendLevelStateProvider);
|
|
final pureBlackDarkMode = ref.watch(pureBlackDarkModeStateProvider);
|
|
ThemeData themeLight = FlexThemeData.light(
|
|
colors: ref.watch(flexSchemeColorStateProvider),
|
|
surfaceMode: FlexSurfaceMode.highScaffoldLevelSurface,
|
|
blendLevel: blendLevel.toInt(),
|
|
appBarOpacity: 0.00,
|
|
subThemesData: const FlexSubThemesData(
|
|
blendOnLevel: 10,
|
|
thinBorderWidth: 2.0,
|
|
unselectedToggleIsColored: true,
|
|
inputDecoratorRadius: 24.0,
|
|
chipRadius: 24.0,
|
|
dialogBackgroundSchemeColor: SchemeColor.background,
|
|
),
|
|
useMaterial3ErrorColors: true,
|
|
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
|
useMaterial3: true,
|
|
fontFamily: GoogleFonts.aBeeZee().fontFamily,
|
|
);
|
|
ThemeData themeDark = FlexThemeData.dark(
|
|
colors: ref.watch(flexSchemeColorStateProvider),
|
|
surfaceMode: FlexSurfaceMode.level,
|
|
blendLevel: blendLevel.toInt(),
|
|
appBarOpacity: 0.00,
|
|
scaffoldBackground: pureBlackDarkMode ? Colors.black : null,
|
|
subThemesData: const FlexSubThemesData(
|
|
blendOnLevel: 10,
|
|
thinBorderWidth: 2.0,
|
|
unselectedToggleIsColored: true,
|
|
inputDecoratorRadius: 24.0,
|
|
chipRadius: 24.0,
|
|
dialogBackgroundSchemeColor: SchemeColor.background,
|
|
),
|
|
useMaterial3ErrorColors: true,
|
|
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
|
useMaterial3: true,
|
|
fontFamily: GoogleFonts.aBeeZee().fontFamily,
|
|
);
|
|
final router = ref.watch(routerProvider);
|
|
return MaterialApp.router(
|
|
darkTheme: themeDark,
|
|
themeMode: isDarkTheme ? ThemeMode.dark : ThemeMode.light,
|
|
theme: themeLight,
|
|
debugShowCheckedModeBanner: false,
|
|
routeInformationParser: router.routeInformationParser,
|
|
routerDelegate: router.routerDelegate,
|
|
routeInformationProvider: router.routeInformationProvider,
|
|
title: 'MangaYomi',
|
|
);
|
|
}
|
|
}
|