mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
theme and language
This commit is contained in:
@@ -118,7 +118,10 @@
|
||||
"Back" : "返回",
|
||||
"Logging in" : "登录中",
|
||||
"Browse": "浏览",
|
||||
"Proxy": "代理"
|
||||
"Proxy": "代理",
|
||||
"Appearance": "外观",
|
||||
"Language": "语言",
|
||||
"Theme": "主题"
|
||||
},
|
||||
"zh_TW": {
|
||||
"Search": "搜索",
|
||||
@@ -239,6 +242,9 @@
|
||||
"Back" : "返回",
|
||||
"Logging in" : "登錄中",
|
||||
"Browse": "瀏覽",
|
||||
"Proxy": "代理"
|
||||
"Proxy": "代理",
|
||||
"Appearance": "外觀",
|
||||
"Language": "語言",
|
||||
"Theme": "主題"
|
||||
}
|
||||
}
|
@@ -18,6 +18,8 @@ class _Appdata {
|
||||
"downloadSubPath": r"/${id}-p${index}.${ext}",
|
||||
"maxParallels": 3,
|
||||
"proxy": "",
|
||||
"darkMode": "System",
|
||||
"language": "System",
|
||||
};
|
||||
|
||||
bool lock = false;
|
||||
|
@@ -30,7 +30,7 @@ class ToastOverlay extends StatelessWidget {
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: PhysicalModel(
|
||||
color: FluentTheme.of(context).cardColor.withOpacity(0),
|
||||
color: ColorScheme.of(context).surface.withOpacity(1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
elevation: 1,
|
||||
child: Container(
|
||||
|
@@ -4,6 +4,8 @@ import 'dart:ui';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../appdata.dart';
|
||||
|
||||
export "widget_utils.dart";
|
||||
export "state_controller.dart";
|
||||
export "navigation.dart";
|
||||
@@ -21,6 +23,14 @@ class _App {
|
||||
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
||||
|
||||
Locale get locale {
|
||||
if(appdata.settings["language"] != "System"){
|
||||
return switch(appdata.settings["language"]){
|
||||
"English" => const Locale("en"),
|
||||
"简体中文" => const Locale("zh"),
|
||||
"繁體中文" => const Locale("zh", "Hant"),
|
||||
_ => const Locale("en"),
|
||||
};
|
||||
}
|
||||
Locale deviceLocale = PlatformDispatcher.instance.locale;
|
||||
if (deviceLocale.languageCode == "zh" && deviceLocale.scriptCode == "Hant") {
|
||||
deviceLocale = const Locale("zh", "TW");
|
||||
|
@@ -55,12 +55,20 @@ class MyApp extends StatelessWidget {
|
||||
init: SimpleController(),
|
||||
tag: "MyApp",
|
||||
builder: (controller) {
|
||||
Brightness? brightness;
|
||||
|
||||
if(appdata.settings["theme"] == "Dark") {
|
||||
brightness = Brightness.dark;
|
||||
} else if(appdata.settings["theme"] == "Light") {
|
||||
brightness = Brightness.light;
|
||||
}
|
||||
|
||||
return FluentApp(
|
||||
navigatorKey: App.rootNavigatorKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'pixes',
|
||||
theme: FluentThemeData(
|
||||
brightness: Brightness.light,
|
||||
brightness: brightness ?? Brightness.light,
|
||||
fontFamily: App.isWindows ? 'font' : null,
|
||||
accentColor: AccentColor.swatch({
|
||||
'darkest': SystemTheme.accentColor.darkest,
|
||||
@@ -72,7 +80,7 @@ class MyApp extends StatelessWidget {
|
||||
'lightest': SystemTheme.accentColor.lightest,
|
||||
})),
|
||||
darkTheme: FluentThemeData(
|
||||
brightness: Brightness.dark,
|
||||
brightness: brightness ?? Brightness.dark,
|
||||
fontFamily: App.isWindows ? 'font' : null,
|
||||
accentColor: AccentColor.swatch({
|
||||
'darkest': SystemTheme.accentColor.darkest,
|
||||
|
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
@@ -266,11 +267,13 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScaffoldPage(
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
||||
content: Listener(
|
||||
color: FluentTheme.of(context).micaBackgroundColor,
|
||||
child: Listener(
|
||||
onPointerSignal: (event) {
|
||||
if(event is PointerScrollEvent) {
|
||||
if(event is PointerScrollEvent &&
|
||||
!HardwareKeyboard.instance.isControlPressed) {
|
||||
if(event.scrollDelta.dy > 0
|
||||
&& controller.page!.toInt() < widget.imagePaths.length - 1) {
|
||||
controller.jumpToPage(controller.page!.toInt() + 1);
|
||||
@@ -286,8 +289,8 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
children: [
|
||||
Positioned.fill(child: PhotoViewGallery.builder(
|
||||
pageController: controller,
|
||||
backgroundDecoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).micaBackgroundColor
|
||||
backgroundDecoration: const BoxDecoration(
|
||||
color: Colors.transparent
|
||||
),
|
||||
itemCount: widget.imagePaths.length,
|
||||
builder: (context, index) {
|
||||
|
@@ -35,6 +35,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
buildBrowse(),
|
||||
buildHeader("Download".tl),
|
||||
buildDownload(),
|
||||
buildHeader("Appearance".tl),
|
||||
buildAppearance(),
|
||||
buildHeader("About".tl),
|
||||
buildAbout(),
|
||||
SliverPadding(
|
||||
@@ -221,6 +223,76 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildAppearance() {
|
||||
return SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
buildItem(
|
||||
title: "Theme".tl,
|
||||
action: DropDownButton(
|
||||
title: Text(appdata.settings["theme"] ?? "System".tl),
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("System".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("light".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Light";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("dark".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Dark";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
buildItem(
|
||||
title: "Language".tl,
|
||||
action: DropDownButton(
|
||||
title: Text(appdata.settings["language"] ?? "System"),
|
||||
items: [
|
||||
MenuFlyoutItem(text: const Text("System"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("English"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "English";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("简体中文"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "简体中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("繁體中文"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "繁體中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SetSingleFieldPage extends StatefulWidget {
|
||||
|
Reference in New Issue
Block a user