mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Update theme
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_saf/flutter_saf.dart';
|
import 'package:flutter_saf/flutter_saf.dart';
|
||||||
|
import 'package:rhttp/rhttp.dart';
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
import 'package:venera/foundation/cache_manager.dart';
|
import 'package:venera/foundation/cache_manager.dart';
|
||||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||||
@@ -8,12 +10,12 @@ import 'package:venera/foundation/js_engine.dart';
|
|||||||
import 'package:venera/foundation/local.dart';
|
import 'package:venera/foundation/local.dart';
|
||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/network/cookie_jar.dart';
|
import 'package:venera/network/cookie_jar.dart';
|
||||||
|
import 'package:venera/utils/app_links.dart';
|
||||||
import 'package:venera/utils/tags_translation.dart';
|
import 'package:venera/utils/tags_translation.dart';
|
||||||
import 'package:venera/utils/translations.dart';
|
import 'package:venera/utils/translations.dart';
|
||||||
|
|
||||||
import 'foundation/appdata.dart';
|
import 'foundation/appdata.dart';
|
||||||
|
|
||||||
extension FutureInit<T> on Future<T> {
|
extension _FutureInit<T> on Future<T> {
|
||||||
/// Prevent unhandled exception
|
/// Prevent unhandled exception
|
||||||
///
|
///
|
||||||
/// A unhandled exception occurred in init() will cause the app to crash.
|
/// A unhandled exception occurred in init() will cause the app to crash.
|
||||||
@@ -27,6 +29,7 @@ extension FutureInit<T> on Future<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
|
await Rhttp.init();
|
||||||
await SAFTaskWorker().init().wait();
|
await SAFTaskWorker().init().wait();
|
||||||
await AppTranslation.init().wait();
|
await AppTranslation.init().wait();
|
||||||
await appdata.init().wait();
|
await appdata.init().wait();
|
||||||
@@ -39,4 +42,11 @@ Future<void> init() async {
|
|||||||
await ComicSource.init().wait();
|
await ComicSource.init().wait();
|
||||||
await LocalManager().init().wait();
|
await LocalManager().init().wait();
|
||||||
CacheManager().setLimitSize(appdata.settings['cacheSize']);
|
CacheManager().setLimitSize(appdata.settings['cacheSize']);
|
||||||
|
if (App.isAndroid) {
|
||||||
|
handleLinks();
|
||||||
|
}
|
||||||
|
FlutterError.onError = (details) {
|
||||||
|
Log.error(
|
||||||
|
"Unhandled Exception", "${details.exception}\n${details.stack}");
|
||||||
|
};
|
||||||
}
|
}
|
@@ -1,13 +1,13 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
||||||
import 'package:dynamic_color/dynamic_color.dart';
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
|
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:rhttp/rhttp.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/pages/auth_page.dart';
|
import 'package:venera/pages/auth_page.dart';
|
||||||
import 'package:venera/pages/main_page.dart';
|
import 'package:venera/pages/main_page.dart';
|
||||||
import 'package:venera/utils/app_links.dart';
|
|
||||||
import 'package:venera/utils/io.dart';
|
import 'package:venera/utils/io.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
import 'components/components.dart';
|
import 'components/components.dart';
|
||||||
@@ -17,21 +17,11 @@ import 'foundation/appdata.dart';
|
|||||||
import 'init.dart';
|
import 'init.dart';
|
||||||
|
|
||||||
void main(List<String> args) {
|
void main(List<String> args) {
|
||||||
if (runWebViewTitleBarWidget(args)) {
|
if (runWebViewTitleBarWidget(args)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
overrideIO(() {
|
overrideIO(() {
|
||||||
runZonedGuarded(() async {
|
runZonedGuarded(() async {
|
||||||
await Rhttp.init();
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await init();
|
await init();
|
||||||
if (App.isAndroid) {
|
|
||||||
handleLinks();
|
|
||||||
}
|
|
||||||
FlutterError.onError = (details) {
|
|
||||||
Log.error(
|
|
||||||
"Unhandled Exception", "${details.exception}\n${details.stack}");
|
|
||||||
};
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
if (App.isDesktop) {
|
if (App.isDesktop) {
|
||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
@@ -54,7 +44,7 @@ void main(List<String> args) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, (error, stack) {
|
}, (error, stack) {
|
||||||
Log.error("Unhandled Exception", "$error\n$stack");
|
Log.error("Unhandled Exception", error, stack);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -155,47 +145,63 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|||||||
home = const MainPage();
|
home = const MainPage();
|
||||||
}
|
}
|
||||||
return DynamicColorBuilder(builder: (light, dark) {
|
return DynamicColorBuilder(builder: (light, dark) {
|
||||||
|
Color? primary, secondary, tertiary;
|
||||||
if (appdata.settings['color'] != 'system' ||
|
if (appdata.settings['color'] != 'system' ||
|
||||||
light == null ||
|
light == null ||
|
||||||
dark == null) {
|
dark == null) {
|
||||||
var color = translateColorSetting();
|
primary = translateColorSetting();
|
||||||
light = ColorScheme.fromSeed(
|
|
||||||
seedColor: color,
|
|
||||||
surface: Colors.white,
|
|
||||||
);
|
|
||||||
dark = ColorScheme.fromSeed(
|
|
||||||
seedColor: color,
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
surface: Colors.black,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
light = ColorScheme.fromSeed(
|
primary = light.primary;
|
||||||
seedColor: light.primary,
|
secondary = light.secondary;
|
||||||
surface: Colors.white,
|
tertiary = light.tertiary;
|
||||||
);
|
|
||||||
dark = ColorScheme.fromSeed(
|
|
||||||
seedColor: dark.primary,
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
surface: Colors.black,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
home: home,
|
home: home,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: light,
|
colorScheme: SeedColorScheme.fromSeeds(
|
||||||
fontFamily: App.isWindows ? "Microsoft YaHei" : null,
|
primaryKey: primary,
|
||||||
|
secondaryKey: secondary,
|
||||||
|
tertiaryKey: tertiary,
|
||||||
|
tones: FlexTones.vividBackground(Brightness.light),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
navigatorKey: App.rootNavigatorKey,
|
navigatorKey: App.rootNavigatorKey,
|
||||||
darkTheme: ThemeData(
|
darkTheme: ThemeData(
|
||||||
colorScheme: dark,
|
colorScheme: SeedColorScheme.fromSeeds(
|
||||||
fontFamily: App.isWindows ? "Microsoft YaHei" : null,
|
primaryKey: primary,
|
||||||
|
secondaryKey: secondary,
|
||||||
|
tertiaryKey: tertiary,
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
tones: FlexTones.vividBackground(Brightness.dark),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
themeMode: switch (appdata.settings['theme_mode']) {
|
themeMode: switch (appdata.settings['theme_mode']) {
|
||||||
'light' => ThemeMode.light,
|
'light' => ThemeMode.light,
|
||||||
'dark' => ThemeMode.dark,
|
'dark' => ThemeMode.dark,
|
||||||
_ => ThemeMode.system
|
_ => ThemeMode.system
|
||||||
},
|
},
|
||||||
|
localizationsDelegates: [
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
],
|
||||||
|
locale: () {
|
||||||
|
var lang = appdata.settings['language'];
|
||||||
|
if (lang == 'system') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (lang) {
|
||||||
|
'zh-CN' => const Locale('zh', 'CN'),
|
||||||
|
'zh-TW' => const Locale('zh', 'TW'),
|
||||||
|
'en-US' => const Locale('en'),
|
||||||
|
_ => null
|
||||||
|
};
|
||||||
|
}(),
|
||||||
|
supportedLocales: const [
|
||||||
|
Locale('zh', 'CN'),
|
||||||
|
Locale('zh', 'TW'),
|
||||||
|
Locale('en'),
|
||||||
|
],
|
||||||
builder: (context, widget) {
|
builder: (context, widget) {
|
||||||
ErrorWidget.builder = (details) {
|
ErrorWidget.builder = (details) {
|
||||||
Log.error("Unhandled Exception",
|
Log.error("Unhandled Exception",
|
||||||
|
13
pubspec.lock
13
pubspec.lock
@@ -274,6 +274,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
|
flex_seed_scheme:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flex_seed_scheme
|
||||||
|
sha256: d3ba3c5c92d2d79d45e94b4c6c71d01fac3c15017da1545880c53864da5dfeb0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.5.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -368,6 +376,11 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
flutter_localizations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
flutter_memory_info:
|
flutter_memory_info:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@@ -72,6 +72,9 @@ dependencies:
|
|||||||
git:
|
git:
|
||||||
url: https://github.com/wgh136/flutter_7zip
|
url: https://github.com/wgh136/flutter_7zip
|
||||||
ref: b33344797f1d2469339e0e1b75f5f954f1da224c
|
ref: b33344797f1d2469339e0e1b75f5f954f1da224c
|
||||||
|
flex_seed_scheme: ^3.5.0
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user