Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

feat: optional start page (#1709)

Fernede6ab6238624
diff --git a/lib/app_widget.dart b/lib/app_widget.dart
index 328d2159..78ad8aec 100644
--- a/lib/app_widget.dart
+++ b/lib/app_widget.dart
@@ -154,9 +154,11 @@ class _AppWidgetState extends State<AppWidget>
void didChangeAppLifecycleState(AppLifecycleState state) async {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.paused) {
- KazumiLogger().i("AppLifecycleState.paused: Application moved to background");
+ KazumiLogger()
+ .i("AppLifecycleState.paused: Application moved to background");
} else if (state == AppLifecycleState.resumed) {
- KazumiLogger().i("AppLifecycleState.resumed: Application moved to foreground");
+ KazumiLogger()
+ .i("AppLifecycleState.resumed: Application moved to foreground");
} else if (state == AppLifecycleState.inactive) {
KazumiLogger().i("AppLifecycleState.inactive: Application is inactive");
}
diff --git a/lib/pages/init_page.dart b/lib/pages/init_page.dart
index 3cf47278..bed69b9a 100644
--- a/lib/pages/init_page.dart
+++ b/lib/pages/init_page.dart
@@ -29,7 +29,8 @@ class _InitPageState extends State<InitPage> {
final CollectController collectController = Modular.get<CollectController>();
final ShadersController shadersController = Modular.get<ShadersController>();
final MyController myController = Modular.get<MyController>();
- final DownloadController downloadController = Modular.get<DownloadController>();
+ final DownloadController downloadController =
+ Modular.get<DownloadController>();
Box setting = GStorage.setting;
late final ThemeProvider themeProvider;
@@ -55,7 +56,7 @@ class _InitPageState extends State<InitPage> {
await _checkRunningOnX11();
await _pluginInit();
- _navigateToHome();
+ _startDefaultPage();
_update();
}
@@ -68,7 +69,8 @@ class _InitPageState extends State<InitPage> {
if (Modular.to.path.contains('/download')) return;
Modular.to.pushNamed('/settings/download/');
} catch (e) {
- KazumiLogger().w('InitPage: failed to navigate to download page', error: e);
+ KazumiLogger()
+ .w('InitPage: failed to navigate to download page', error: e);
}
});
};
@@ -88,7 +90,8 @@ class _InitPageState extends State<InitPage> {
onPressed: () => KazumiDialog.dismiss(popWith: false),
child: Text(
'稍后再说',
- style: TextStyle(color: Theme.of(context).colorScheme.outline),
+ style:
+ TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
@@ -103,12 +106,16 @@ class _InitPageState extends State<InitPage> {
};
}
- void _navigateToHome() {
+ void _startDefaultPage() {
+ final defaultStartupPage = setting.get(
+ SettingBoxKey.defaultStartupPage,
+ defaultValue: '/tab/popular/',
+ );
// Workaround for dynamic_color. dynamic_color need PlatformChannel to get color, it takes time.
// setDynamic here to avoid white screen flash when themeMode is dark.
themeProvider.setDynamic(
setting.get(SettingBoxKey.useDynamicColor, defaultValue: false));
- Modular.to.navigate('/tab/popular/');
+ Modular.to.navigate(defaultStartupPage);
}
// migrate collect from old version (favorites)
diff --git a/lib/pages/menu/menu.dart b/lib/pages/menu/menu.dart
index 6e10810c..ea12a40b 100644
--- a/lib/pages/menu/menu.dart
+++ b/lib/pages/menu/menu.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/widget/embedded_native_control_area.dart';
import 'package:kazumi/pages/router.dart';
+import 'package:kazumi/utils/storage.dart';
import 'package:provider/provider.dart';
class ScaffoldMenu extends StatefulWidget {
@@ -12,7 +13,7 @@ class ScaffoldMenu extends StatefulWidget {
}
class NavigationBarState extends ChangeNotifier {
- int _selectedIndex = 0;
+ late int _selectedIndex = getDefaultSelectedIndex();
bool _isHide = false;
bool _isBottom = false;
@@ -22,6 +23,24 @@ class NavigationBarState extends ChangeNotifier {
bool get isBottom => _isBottom;
+ int getDefaultSelectedIndex() {
+ final defaultPage = GStorage.setting
+ .get(SettingBoxKey.defaultStartupPage, defaultValue: "/tab/popular/");
+
+ switch (defaultPage) {
+ case "/tab/popular/":
+ return 0;
+ case "/tab/timeline/":
+ return 1;
+ case "/tab/collect/":
+ return 2;
+ case "/tab/my/":
+ return 3;
+ default:
+ return 0;
+ }
+ }
+
void updateSelectedIndex(int pageIndex) {
_selectedIndex = pageIndex;
notifyListeners();
@@ -175,4 +194,4 @@ class _ScaffoldMenu extends State<ScaffoldMenu> {
),
);
}
-}
+}
\ No newline at end of file
diff --git a/lib/pages/my/my_page.dart b/lib/pages/my/my_page.dart
index e16cf4f9..0dc897f6 100644
--- a/lib/pages/my/my_page.dart
+++ b/lib/pages/my/my_page.dart
@@ -57,7 +57,8 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.history_rounded),
title: Text('历史记录', style: TextStyle(fontFamily: fontFamily)),
- description: Text('查看播放历史记录', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('查看播放历史记录',
+ style: TextStyle(fontFamily: fontFamily)),
),
SettingsTile.navigation(
onPressed: (_) {
@@ -81,7 +82,8 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.extension),
title: Text('规则管理', style: TextStyle(fontFamily: fontFamily)),
- description: Text('管理番剧资源规则', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('管理番剧资源规则',
+ style: TextStyle(fontFamily: fontFamily)),
),
],
),
@@ -94,7 +96,17 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.display_settings_rounded),
title: Text('播放设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置播放器相关参数', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('设置播放器相关参数',
+ style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ Modular.to.pushNamed('/settings/interface');
+ },
+ leading: const Icon(Icons.pages_rounded),
+ title: Text('界面设置', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('设置应用界面样式',
+ style: TextStyle(fontFamily: fontFamily)),
),
SettingsTile.navigation(
onPressed: (_) {
@@ -102,7 +114,8 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.subtitles_rounded),
title: Text('弹幕设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置弹幕相关参数', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('设置弹幕相关参数',
+ style: TextStyle(fontFamily: fontFamily)),
),
SettingsTile.navigation(
onPressed: (_) {
@@ -110,7 +123,8 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.keyboard_rounded),
title: Text('操作设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置播放器按键映射', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('设置播放器按键映射',
+ style: TextStyle(fontFamily: fontFamily)),
),
SettingsTile.navigation(
onPressed: (_) {
@@ -118,7 +132,8 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.vpn_key_rounded),
title: Text('代理设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('配置HTTP代理', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('配置HTTP代理',
+ style: TextStyle(fontFamily: fontFamily)),
),
],
),
@@ -131,7 +146,8 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.palette_rounded),
title: Text('外观设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置应用主题和刷新率', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('设置应用主题和刷新率',
+ style: TextStyle(fontFamily: fontFamily)),
),
SettingsTile.navigation(
onPressed: (_) {
@@ -139,7 +155,8 @@ class _MyPageState extends State<MyPage> {
},
leading: const Icon(Icons.cloud),
title: Text('同步设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置同步参数', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('设置同步参数', style: TextStyle(fontFamily: fontFamily)),
),
],
),
@@ -160,4 +177,4 @@ class _MyPageState extends State<MyPage> {
),
);
}
-}
+}
\ No newline at end of file
diff --git a/lib/pages/settings/interface_settings.dart b/lib/pages/settings/interface_settings.dart
new file mode 100644
index 00000000..391ad3cb
--- /dev/null
+++ b/lib/pages/settings/interface_settings.dart
@@ -0,0 +1,93 @@
+import 'package:card_settings_ui/list/settings_list.dart';
+import 'package:card_settings_ui/section/settings_section.dart';
+import 'package:card_settings_ui/tile/settings_tile.dart';
+import 'package:flutter/material.dart';
+import 'package:hive_ce/hive.dart';
+import 'package:kazumi/bean/appbar/sys_app_bar.dart';
+import 'package:kazumi/bean/dialog/dialog_helper.dart';
+import 'package:kazumi/utils/storage.dart';
+
+class InterfaceSettingsPage extends StatefulWidget {
+ const InterfaceSettingsPage({super.key});
+
+ @override
+ State<InterfaceSettingsPage> createState() => _InterfaceSettingsPageState();
+}
+
+class _InterfaceSettingsPageState extends State<InterfaceSettingsPage> {
+ Box setting = GStorage.setting;
+ late bool showRating;
+ late String defaultPage;
+
+ static const List<DropdownMenuItem> defaultPageSettingList = [
+ DropdownMenuItem(
+ value: "/tab/popular/",
+ child: Text('推荐'),
+ ),
+ DropdownMenuItem(
+ value: "/tab/timeline/",
+ child: Text('时间表'),
+ ),
+ DropdownMenuItem(
+ value: "/tab/collect/",
+ child: Text('追番'),
+ ),
+ DropdownMenuItem(
+ value: "/tab/my/",
+ child: Text('我的'),
+ ),
+ ];
+
+ @override
+ void initState() {
+ super.initState();
+ showRating = setting.get(SettingBoxKey.showRating, defaultValue: true);
+ defaultPage = setting.get(SettingBoxKey.defaultStartupPage,
+ defaultValue: '/tab/popular/');
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;
+
+ return Scaffold(
+ appBar: SysAppBar(
+ title: Text('界面设置'),
+ ),
+ body: SettingsList(
+ sections: [
+ SettingsSection(tiles: [
+ SettingsTile.navigation(
+ title: Text('启动界面设置', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('设置应用开启时的默认页面',
+ style: TextStyle(fontFamily: fontFamily)),
+ trailing: DropdownButton(
+ value: defaultPage,
+ items: defaultPageSettingList,
+ onChanged: (value) async {
+ await setting.put(SettingBoxKey.defaultStartupPage, value);
+ setState(() {
+ defaultPage = value;
+ });
+ },
+ ),
+ ),
+ ]),
+ SettingsSection(tiles: [
+ SettingsTile.switchTile(
+ onToggle: (value) async {
+ showRating = value ?? !showRating;
+ await setting.put(SettingBoxKey.showRating, showRating);
+ setState(() {});
+ },
+ title: Text('显示评分', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('关闭后将在概览中隐藏评分信息',
+ style: TextStyle(fontFamily: fontFamily)),
+ initialValue: showRating,
+ ),
+ ]),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/pages/settings/settings_module.dart b/lib/pages/settings/settings_module.dart
index 8cd805ec..703cdeab 100644
--- a/lib/pages/settings/settings_module.dart
+++ b/lib/pages/settings/settings_module.dart
@@ -3,6 +3,7 @@ import 'package:kazumi/pages/about/about_module.dart';
import 'package:kazumi/pages/plugin_editor/plugin_module.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/pages/history/history_module.dart';
+import 'package:kazumi/pages/settings/interface_settings.dart';
import 'package:kazumi/pages/settings/theme_settings_page.dart';
import 'package:kazumi/pages/settings/player_settings.dart';
import 'package:kazumi/pages/settings/displaymode_settings.dart';
@@ -25,6 +26,7 @@ class SettingsModule extends Module {
r.child("/keyboard", child: (_) => const KeyboardSettingsPage());
r.child("/player", child: (_) => const PlayerSettingsPage());
r.child("/player/decoder", child: (_) => const DecoderSettings());
+ r.child("/interface", child: (_) => const InterfaceSettingsPage());
r.module("/proxy", module: ProxyModule());
r.child("/player/super", child: (_) => const SuperResolutionSettings());
r.module("/webdav", module: WebDavModule());
diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart
index 6df7b725..37fcef2b 100644
--- a/lib/utils/storage.dart
+++ b/lib/utils/storage.dart
@@ -131,7 +131,8 @@ class GStorage {
final tempBox =
await Hive.openBox('tempCollectiblesBox', bytes: backupContent);
final tempBoxItems = tempBox.toMap().entries;
- KazumiLogger().i('WebDav: restoring collectibles. tempCollectiblesBox length ${tempBoxItems.length}');
+ KazumiLogger().i(
+ 'WebDav: restoring collectibles. tempCollectiblesBox length ${tempBoxItems.length}');
await collectibles.clear();
for (var tempBoxItem in tempBoxItems) {
@@ -147,7 +148,8 @@ class GStorage {
final tempBox =
await Hive.openBox('tempCollectiblesBox', bytes: backupContent);
final tempBoxItems = tempBox.toMap().entries;
- KazumiLogger().i('WebDav: get collectibles from file. tempCollectiblesBox length ${tempBoxItems.length}');
+ KazumiLogger().i(
+ 'WebDav: get collectibles from file. tempCollectiblesBox length ${tempBoxItems.length}');
final List<CollectedBangumi> collectibles = [];
for (var tempBoxItem in tempBoxItems) {
@@ -164,7 +166,8 @@ class GStorage {
final tempBox =
await Hive.openBox('tempCollectChangesBox', bytes: backupContent);
final tempBoxItems = tempBox.toMap().entries;
- KazumiLogger().i('WebDav: get collectChanges from file. tempCollectChangesBox length ${tempBoxItems.length}');
+ KazumiLogger().i(
+ 'WebDav: get collectChanges from file. tempCollectChangesBox length ${tempBoxItems.length}');
final List<CollectedBangumiChange> collectChanges = [];
for (var tempBoxItem in tempBoxItems) {
@@ -194,8 +197,8 @@ class GStorage {
// We can directly remove the item from the remote list.
if (change.action == 3) {
// Action 3: delete
- remoteCollectibles.removeWhere(
- (b) => b.bangumiItem.id == change.bangumiID);
+ remoteCollectibles
+ .removeWhere((b) => b.bangumiItem.id == change.bangumiID);
} else {
// For add/update, we still need to look up the local collectible.
final changedBangumiID = change.bangumiID.toString();
@@ -299,6 +302,7 @@ class SettingBoxKey {
displayMode = 'displayMode',
enableGitProxy = 'enableGitProxy',
enableSystemProxy = 'enableSystemProxy',
+ defaultStartupPage = 'defaultStartupPage',
/// Deprecated
isWideScreen = 'isWideScreen',
webDavEnable = 'webDavEnable',