mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
48 lines
1.4 KiB
Dart
48 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'core/utils/ui.dart';
|
|
import 'data/res/build_data.dart';
|
|
import 'data/res/color.dart';
|
|
import 'data/store/setting.dart';
|
|
import 'locator.dart';
|
|
import 'view/page/home.dart';
|
|
|
|
class MyApp extends StatelessWidget {
|
|
MyApp({Key? key}) : super(key: key);
|
|
|
|
final _setting = locator<SettingStore>();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
setTransparentNavigationBar(context);
|
|
primaryColor = Color(_setting.primaryColor.fetch()!);
|
|
|
|
return ValueListenableBuilder<int>(
|
|
valueListenable: _setting.themeMode.listenable(),
|
|
builder: (_, tMode, __) {
|
|
final ok = tMode >= 0 && tMode <= ThemeMode.values.length - 1;
|
|
final themeMode = ok ? ThemeMode.values[tMode] : ThemeMode.system;
|
|
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
localizationsDelegates: S.localizationsDelegates,
|
|
supportedLocales: S.supportedLocales,
|
|
title: BuildData.name,
|
|
themeMode: themeMode,
|
|
theme: ThemeData(
|
|
useMaterial3: true,
|
|
colorSchemeSeed: primaryColor,
|
|
),
|
|
darkTheme: ThemeData(
|
|
useMaterial3: true,
|
|
brightness: Brightness.dark,
|
|
colorSchemeSeed: primaryColor,
|
|
),
|
|
home: const MyHomePage(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|