app/lib/main.dart

64 lines
2.2 KiB
Dart
Raw Normal View History

2024-03-07 23:01:32 +08:00
import 'package:fluent_ui/fluent_ui.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
2024-03-15 00:01:06 +08:00
import 'package:starcitizen_doctor/generated/l10n.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
2023-10-09 09:32:07 +08:00
2024-03-07 23:01:32 +08:00
import 'app.dart';
2023-10-09 09:32:07 +08:00
void main(List<String> args) async {
2024-03-07 23:01:32 +08:00
WidgetsFlutterBinding.ensureInitialized();
// run app
runApp(const ProviderScope(child: App()));
2023-10-09 09:32:07 +08:00
}
2024-03-07 23:01:32 +08:00
class App extends HookConsumerWidget {
const App({super.key});
2023-10-09 09:32:07 +08:00
@override
2024-03-07 23:01:32 +08:00
Widget build(BuildContext context, WidgetRef ref) {
final router = ref.watch(routerProvider);
final appState = ref.watch(appGlobalModelProvider);
return FluentApp.router(
title: "StarCitizenToolBox",
restorationScopeId: "StarCitizenToolBox",
2023-10-09 09:32:07 +08:00
themeMode: ThemeMode.dark,
2024-03-15 00:01:06 +08:00
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
FluentLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
2023-12-13 22:53:03 +08:00
builder: (context, child) {
return MediaQuery(
data:
2024-03-17 12:44:50 +08:00
MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
2023-12-13 22:53:03 +08:00
child: child ?? const SizedBox(),
);
},
2023-11-11 01:18:30 +08:00
theme: FluentThemeData(
brightness: Brightness.dark,
fontFamily: "SourceHanSansCN-Regular",
navigationPaneTheme: NavigationPaneThemeData(
2024-03-07 23:01:32 +08:00
backgroundColor: appState.themeConf.backgroundColor,
),
2024-03-07 23:01:32 +08:00
menuColor: appState.themeConf.menuColor,
micaBackgroundColor: appState.themeConf.micaColor,
buttonTheme: ButtonThemeData(
defaultButtonStyle: ButtonStyle(
2024-07-07 17:16:47 +08:00
shape: WidgetStateProperty.all(RoundedRectangleBorder(
2024-03-17 12:44:50 +08:00
borderRadius: BorderRadius.circular(4),
side: BorderSide(color: Colors.white.withOpacity(.01)))),
))),
2024-03-17 16:54:09 +08:00
locale: appState.appLocale,
2023-10-09 09:32:07 +08:00
debugShowCheckedModeBanner: false,
2024-03-07 23:01:32 +08:00
routeInformationParser: router.routeInformationParser,
routerDelegate: router.routerDelegate,
routeInformationProvider: router.routeInformationProvider,
2023-10-09 09:32:07 +08:00
);
}
}