Skip to content

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

feat: onboard screen (#2354)

Predidit41814e39b671
diff --git a/lib/bean/card/rule_card.dart b/lib/bean/card/rule_card.dart
new file mode 100644
index 00000000..dbfb69f4
--- /dev/null
+++ b/lib/bean/card/rule_card.dart
@@ -0,0 +1,122 @@
+import 'package:flutter/material.dart';
+
+/// Rounded tonal card for a rule entry, shared by the rule manage page,
+/// the rule shop page and the onboarding rule step.
+class RuleCard extends StatelessWidget {
+ const RuleCard({
+ super.key,
+ required this.title,
+ this.tags = const [],
+ this.caption,
+ this.trailing,
+ this.onTap,
+ this.onLongPress,
+ this.selected = false,
+ });
+
+ final String title;
+ final List<Widget> tags;
+
+ /// Plain text shown after [tags], e.g. the last update date.
+ final String? caption;
+ final Widget? trailing;
+ final VoidCallback? onTap;
+ final VoidCallback? onLongPress;
+ final bool selected;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ final textTheme = Theme.of(context).textTheme;
+ return Card(
+ elevation: 0,
+ margin: const EdgeInsets.only(bottom: 8),
+ color: selected
+ ? colorScheme.primaryContainer
+ : colorScheme.surfaceContainerLow,
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
+ clipBehavior: Clip.antiAlias,
+ child: ListTile(
+ onTap: onTap,
+ onLongPress: onLongPress,
+ selected: selected,
+ title: Text(title, style: textTheme.titleMedium),
+ subtitle: tags.isEmpty && caption == null
+ ? null
+ : Padding(
+ padding: const EdgeInsets.only(top: 4),
+ child: Wrap(
+ spacing: 6,
+ runSpacing: 4,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ ...tags,
+ if (caption != null)
+ Text(
+ caption!,
+ style: textTheme.bodySmall
+ ?.copyWith(color: colorScheme.onSurfaceVariant),
+ ),
+ ],
+ ),
+ ),
+ trailing: trailing,
+ ),
+ );
+ }
+}
+
+/// Fixed-width tonal action button for [RuleCard] trailing slots, so the
+/// button edge stays aligned across rows regardless of label length
+/// (e.g. 安装 / 更新 / 已安装). Pass null [onPressed] for the disabled state.
+class RuleCardActionButton extends StatelessWidget {
+ const RuleCardActionButton({
+ super.key,
+ required this.label,
+ this.onPressed,
+ });
+
+ final String label;
+ final VoidCallback? onPressed;
+
+ @override
+ Widget build(BuildContext context) {
+ return SizedBox(
+ width: 96,
+ child: FilledButton.tonal(
+ onPressed: onPressed,
+ child: Text(label, maxLines: 1, overflow: TextOverflow.ellipsis),
+ ),
+ );
+ }
+}
+
+/// Small tonal label used inside [RuleCard], e.g. version or captcha tags.
+class RuleTag extends StatelessWidget {
+ const RuleTag({
+ super.key,
+ required this.label,
+ required this.background,
+ required this.foreground,
+ });
+
+ final String label;
+ final Color background;
+ final Color foreground;
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
+ decoration: BoxDecoration(
+ color: background,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ child: Text(
+ label,
+ style:
+ Theme.of(context).textTheme.labelSmall?.copyWith(color: foreground),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/index_module.dart b/lib/pages/index_module.dart
index 2b5aaa45..e7eb5ad1 100644
--- a/lib/pages/index_module.dart
+++ b/lib/pages/index_module.dart
@@ -6,6 +6,7 @@ import 'package:kazumi/pages/index_page.dart';
import 'package:kazumi/pages/info/info_module.dart';
import 'package:kazumi/pages/init_page.dart';
import 'package:kazumi/pages/my/my_module.dart';
+import 'package:kazumi/pages/onboarding/onboarding_page.dart';
import 'package:kazumi/pages/popular/popular_controller.dart';
import 'package:kazumi/pages/popular/popular_module.dart';
import 'package:kazumi/pages/route_error_page.dart';
@@ -78,6 +79,14 @@ final indexModule = createModule(
),
transition: TransitionType.none,
)
+ ..route(
+ '/onboarding',
+ child: (context, state) => OnboardingPage(
+ pluginsController: inject<PluginsController>(),
+ myController: inject<MyController>(),
+ ),
+ transition: TransitionType.none,
+ )
..route(
'/error',
child: (context, state) => Scaffold(
diff --git a/lib/pages/init_page.dart b/lib/pages/init_page.dart
index 41663692..6e1ab818 100644
--- a/lib/pages/init_page.dart
+++ b/lib/pages/init_page.dart
@@ -9,7 +9,6 @@ import 'package:kazumi/services/storage/storage.dart';
import 'package:kazumi/plugins/plugins_controller.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/pages/collect/collect_controller.dart';
-import 'package:flutter/services.dart' show rootBundle;
import 'package:kazumi/services/logging/logger.dart';
import 'package:kazumi/services/shaders/shader_asset_service.dart';
import 'package:kazumi/pages/download/download_controller.dart';
@@ -66,8 +65,19 @@ class _InitPageState extends State<InitPage> {
}
await _checkRunningOnX11();
- await _pluginInit();
await _showShortcutDialog();
+ await _pluginInit();
+
+ if (!mounted) {
+ return;
+ }
+ // First launch: no installed rules yet, hand over to the onboarding flow.
+ // OnboardingPage takes care of navigating to the default page and
+ // triggering the auto update check afterwards.
+ if (pluginsController.pluginList.isEmpty) {
+ context.navigate('/onboarding');
+ return;
+ }
if (!mounted) {
return;
@@ -274,11 +284,8 @@ class _InitPageState extends State<InitPage> {
}
Future<void> _pluginInit() async {
- String statementsText = '';
try {
await pluginsController.init();
- statementsText =
- await rootBundle.loadString("assets/statements/statements.txt");
unawaited(_pluginUpdate());
} catch (error, stackTrace) {
KazumiLogger().e(
@@ -287,113 +294,6 @@ class _InitPageState extends State<InitPage> {
stackTrace: stackTrace,
);
}
- if (pluginsController.pluginList.isEmpty) {
- await KazumiDialog.show(
- clickMaskDismiss: false,
- builder: (context) {
- return PopScope(
- canPop: false,
- child: AlertDialog(
- title: const Text('免责声明'),
- scrollable: true,
- content: Text(statementsText),
- actions: [
- TextButton(
- onPressed: () {
- exit(0);
- },
- child: Text(
- '退出',
- style:
- TextStyle(color: Theme.of(context).colorScheme.outline),
- ),
- ),
- TextButton(
- onPressed: () async {
- try {
- await pluginsController.copyPluginsToExternalDirectory();
- } catch (error, stackTrace) {
- KazumiLogger().e(
- 'Plugin: failed to install bundled rules',
- error: error,
- stackTrace: stackTrace,
- );
- KazumiDialog.dismiss();
- KazumiDialog.showToast(message: '初始化规则失败');
- return;
- }
- KazumiDialog.dismiss();
- if (!Platform.isAndroid) {
- return;
- }
- await _switchUpdateMirror();
- },
- child: const Text('已阅读并同意'),
- ),
- ],
- ),
- );
- },
- );
- }
- }
-
- // Selecting F-Droid delegates application updates to the store and disables
- // Kazumi's in-app application update checks.
- Future<void> _switchUpdateMirror() async {
- await KazumiDialog.show(
- clickMaskDismiss: false,
- builder: (context) {
- return PopScope(
- canPop: false,
- child: AlertDialog(
- title: const Text('更新来源'),
- content: const Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: EdgeInsets.symmetric(vertical: 8),
- child: Text(
- '您希望从哪里获取应用更新?',
- textAlign: TextAlign.left,
- ),
- ),
- Padding(
- padding: EdgeInsets.symmetric(vertical: 8),
- child: Text(
- 'Github 检查更新为大多数情况下的最佳选择。如果您使用 F-Droid 应用商店,请选择 F-Droid。',
- textAlign: TextAlign.left,
- ),
- ),
- ],
- ),
- actions: [
- TextButton(
- onPressed: () {
- GStorage.putSetting(SettingsKeys.autoUpdate, true);
- KazumiDialog.dismiss();
- },
- child: const Text(
- 'Github',
- ),
- ),
- TextButton(
- onPressed: () {
- GStorage.putSetting(SettingsKeys.autoUpdate, false);
- KazumiDialog.dismiss();
- },
- child: Text(
- 'F-Droid',
- style:
- TextStyle(color: Theme.of(context).colorScheme.outline),
- ),
- ),
- ],
- ),
- );
- },
- );
}
Future<void> _update() async {
diff --git a/lib/pages/onboarding/onboarding_page.dart b/lib/pages/onboarding/onboarding_page.dart
new file mode 100644
index 00000000..5798d255
--- /dev/null
+++ b/lib/pages/onboarding/onboarding_page.dart
@@ -0,0 +1,270 @@
+import 'dart:async';
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter_modular/flutter_modular.dart';
+import 'package:kazumi/bean/appbar/sys_app_bar.dart';
+import 'package:kazumi/bean/dialog/dialog_helper.dart';
+import 'package:kazumi/pages/my/my_controller.dart';
+import 'package:kazumi/pages/onboarding/steps/disclaimer_step.dart';
+import 'package:kazumi/pages/onboarding/steps/mirror_settings_step.dart';
+import 'package:kazumi/pages/onboarding/steps/plugin_shop_step.dart';
+import 'package:kazumi/pages/onboarding/steps/update_source_step.dart';
+import 'package:kazumi/plugins/plugins_controller.dart';
+import 'package:kazumi/services/logging/logger.dart';
+import 'package:kazumi/services/storage/storage.dart';
+
+class OnboardingPage extends StatefulWidget {
+ const OnboardingPage({
+ super.key,
+ required this.pluginsController,
+ required this.myController,
+ });
+
+ final PluginsController pluginsController;
+ final MyController myController;
+
+ @override
+ State<OnboardingPage> createState() => _OnboardingPageState();
+}
+
+class _OnboardingPageState extends State<OnboardingPage> {
+ final PageController pageController = PageController();
+ int currentIndex = 0;
+ bool agreed = false;
+ bool installingBundled = false;
+ bool useGithubUpdate = true;
+
+ PluginsController get pluginsController => widget.pluginsController;
+
+ int get stepCount => Platform.isAndroid ? 4 : 3;
+
+ @override
+ void dispose() {
+ pageController.dispose();
+ super.dispose();
+ }
+
+ List<Widget> _buildStepBodies() {
+ return [
+ const DisclaimerStep(),
+ if (Platform.isAndroid)
+ UpdateSourceStep(
+ useGithubUpdate: useGithubUpdate,
+ onChanged: (value) {
+ GStorage.putSetting(SettingsKeys.autoUpdate, value);
+ setState(() {
+ useGithubUpdate = value;
+ });
+ },
+ ),
+ const MirrorSettingsStep(),
+ PluginShopStep(controller: pluginsController),
+ ];
+ }
+
+ String get primaryLabel {
+ if (currentIndex == 0 && !agreed) {
+ return '同意并继续';
+ }
+ return currentIndex == stepCount - 1 ? '完成' : '下一步';
+ }
+
+ void _goToPage(int index) {
+ pageController.animateToPage(
+ index,
+ duration: const Duration(milliseconds: 300),
+ curve: Curves.easeOutCubic,
+ );
+ }
+
+ void _previousPage() {
+ if (currentIndex > 0) {
+ _goToPage(currentIndex - 1);
+ }
+ }
+
+ void _nextPage() {
+ if (currentIndex < stepCount - 1) {
+ _goToPage(currentIndex + 1);
+ } else {
+ _finish();
+ }
+ }
+
+ Future<void> _agree() async {
+ if (agreed) {
+ _nextPage();
+ return;
+ }
+ setState(() {
+ installingBundled = true;
+ });
+ try {
+ await pluginsController.copyPluginsToExternalDirectory();
+ } catch (error, stackTrace) {
+ KazumiLogger().e(
+ 'Plugin: failed to install bundled rules',
+ error: error,
+ stackTrace: stackTrace,
+ );
+ if (mounted) {
+ setState(() {
+ installingBundled = false;
+ });
+ }
+ KazumiDialog.showToast(message: '初始化规则失败');
+ return;
+ }
+ if (!mounted) {
+ return;
+ }
+ setState(() {
+ agreed = true;
+ installingBundled = false;
+ });
+ _nextPage();
+ }
+
+ void _handlePrimary() {
+ if (currentIndex == 0) {
+ unawaited(_agree());
+ } else {
+ _nextPage();
+ }
+ }
+
+ void _finish() {
+ final myController = widget.myController;
+ // delay to ensure that the default page is fully loaded
+ unawaited(Future.delayed(const Duration(milliseconds: 500)).then((_) {
+ if (GStorage.getSetting(SettingsKeys.autoUpdate)) {
+ myController.checkUpdate(type: 'auto');
+ }
+ }));
+ context.navigate(GStorage.getSetting(SettingsKeys.defaultStartupPage));
+ }
+
+ Widget _buildBottomBar(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ return SafeArea(
+ top: false,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(24, 8, 24, 24),
+ child: Row(
+ children: [
+ if (currentIndex == 0)
+ TextButton(
+ onPressed: () => exit(0),
+ child: Text(
+ '退出',
+ style: TextStyle(color: colorScheme.outline),
+ ),
+ )
+ else
+ TextButton(
+ onPressed: _previousPage,
+ child: const Text('上一步'),
+ ),
+ Expanded(
+ child: Center(
+ child: _PageIndicator(
+ count: stepCount,
+ currentIndex: currentIndex,
+ ),
+ ),
+ ),
+ FilledButton(
+ onPressed: installingBundled ? null : _handlePrimary,
+ child: installingBundled
+ ? const SizedBox(
+ width: 18,
+ height: 18,
+ child: CircularProgressIndicator(strokeWidth: 2),
+ )
+ : Text(primaryLabel),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return PopScope(
+ canPop: false,
+ onPopInvokedWithResult: (bool didPop, Object? result) {
+ if (didPop) {
+ return;
+ }
+ _previousPage();
+ },
+ child: Scaffold(
+ appBar: const SysAppBar(),
+ body: Column(
+ children: [
+ Expanded(
+ child: PageView(
+ controller: pageController,
+ physics: agreed ? null : const NeverScrollableScrollPhysics(),
+ onPageChanged: (index) {
+ setState(() {
+ currentIndex = index;
+ });
+ },
+ children: [
+ for (final body in _buildStepBodies())
+ Center(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 600),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 24),
+ child: body,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ _buildBottomBar(context),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class _PageIndicator extends StatelessWidget {
+ const _PageIndicator({
+ required this.count,
+ required this.currentIndex,
+ });
+
+ final int count;
+ final int currentIndex;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ return Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (int i = 0; i < count; i++)
+ AnimatedContainer(
+ duration: const Duration(milliseconds: 250),
+ curve: Curves.easeOutCubic,
+ margin: const EdgeInsets.symmetric(horizontal: 4),
+ width: i == currentIndex ? 24 : 8,
+ height: 8,
+ decoration: BoxDecoration(
+ color: i == currentIndex
+ ? colorScheme.primary
+ : colorScheme.surfaceContainerHighest,
+ borderRadius: BorderRadius.circular(4),
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/lib/pages/onboarding/onboarding_step_layout.dart b/lib/pages/onboarding/onboarding_step_layout.dart
new file mode 100644
index 00000000..92ccb077
--- /dev/null
+++ b/lib/pages/onboarding/onboarding_step_layout.dart
@@ -0,0 +1,66 @@
+import 'package:flutter/material.dart';
+
+/// Shared visual skeleton for onboarding steps: a leading badge, a headline,
+/// a one-line supporting text and the step content below.
+class OnboardingStepLayout extends StatelessWidget {
+ const OnboardingStepLayout({
+ super.key,
+ required this.leading,
+ required this.title,
+ required this.subtitle,
+ required this.child,
+ });
+
+ final Widget leading;
+ final String title;
+ final String subtitle;
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ final textTheme = Theme.of(context).textTheme;
+ return Column(
+ children: [
+ const SizedBox(height: 24),
+ leading,
+ const SizedBox(height: 20),
+ Text(
+ title,
+ style: textTheme.headlineSmall,
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: 8),
+ Text(
+ subtitle,
+ style:
+ textTheme.bodyMedium?.copyWith(color: colorScheme.onSurfaceVariant),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: 24),
+ Expanded(child: child),
+ ],
+ );
+ }
+}
+
+/// Circular tonal badge holding the step icon.
+class OnboardingStepIcon extends StatelessWidget {
+ const OnboardingStepIcon({super.key, required this.icon});
+
+ final IconData icon;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ return Container(
+ width: 64,
+ height: 64,
+ decoration: BoxDecoration(
+ color: colorScheme.secondaryContainer,
+ shape: BoxShape.circle,
+ ),
+ child: Icon(icon, size: 32, color: colorScheme.onSecondaryContainer),
+ );
+ }
+}
diff --git a/lib/pages/onboarding/steps/disclaimer_step.dart b/lib/pages/onboarding/steps/disclaimer_step.dart
new file mode 100644
index 00000000..9792bf29
--- /dev/null
+++ b/lib/pages/onboarding/steps/disclaimer_step.dart
@@ -0,0 +1,67 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart' show rootBundle;
+import 'package:kazumi/pages/onboarding/onboarding_step_layout.dart';
+import 'package:kazumi/services/logging/logger.dart';
+
+class DisclaimerStep extends StatefulWidget {
+ const DisclaimerStep({super.key});
+
+ @override
+ State<DisclaimerStep> createState() => _DisclaimerStepState();
+}
+
+class _DisclaimerStepState extends State<DisclaimerStep> {
+ String? statementsText;
+
+ @override
+ void initState() {
+ super.initState();
+ _loadStatements();
+ }
+
+ Future<void> _loadStatements() async {
+ String text;
+ try {
+ text = await rootBundle.loadString('assets/statements/statements.txt');
+ } catch (error, stackTrace) {
+ KazumiLogger().e(
+ 'Onboarding: failed to load statements',
+ error: error,
+ stackTrace: stackTrace,
+ );
+ text = '免责声明加载失败,请退出后重试。';
+ }
+ if (!mounted) {
+ return;
+ }
+ setState(() {
+ statementsText = text;
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ final textTheme = Theme.of(context).textTheme;
+ return OnboardingStepLayout(
+ leading: const OnboardingStepIcon(icon: Icons.waving_hand_rounded),
+ title: '欢迎使用',
+ subtitle: '请阅读并同意免责声明',
+ child: Card(
+ elevation: 0,
+ margin: EdgeInsets.zero,
+ color: colorScheme.surfaceContainerLow,
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
+ child: statementsText == null
+ ? const Center(child: CircularProgressIndicator())
+ : SingleChildScrollView(
+ padding: const EdgeInsets.all(20),
+ child: Text(
+ statementsText!,
+ style: textTheme.bodyMedium?.copyWith(height: 1.7),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/onboarding/steps/mirror_settings_step.dart b/lib/pages/onboarding/steps/mirror_settings_step.dart
new file mode 100644
index 00000000..7f094477
--- /dev/null
+++ b/lib/pages/onboarding/steps/mirror_settings_step.dart
@@ -0,0 +1,94 @@
+import 'package:flutter/material.dart';
+import 'package:kazumi/pages/onboarding/onboarding_step_layout.dart';
+import 'package:kazumi/services/storage/storage.dart';
+
+class MirrorSettingsStep extends StatefulWidget {
+ const MirrorSettingsStep({super.key});
+
+ @override
+ State<MirrorSettingsStep> createState() => _MirrorSettingsStepState();
+}
+
+class _MirrorSettingsStepState extends State<MirrorSettingsStep> {
+ late bool enableGitProxy;
+ late bool enableBangumiProxy;
+
+ @override
+ void initState() {
+ super.initState();
+ enableGitProxy = GStorage.getSetting(SettingsKeys.enableGitProxy);
+ enableBangumiProxy = GStorage.getSetting(SettingsKeys.enableBangumiProxy);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ return OnboardingStepLayout(
+ leading: const OnboardingStepIcon(icon: Icons.public_rounded),
+ title: '网络镜像',
+ subtitle: '中国大陆用户推荐启用,提升访问速度',
+ child: Align(
+ alignment: Alignment.topCenter,
+ child: Card(
+ elevation: 0,
+ margin: EdgeInsets.zero,
+ color: colorScheme.surfaceContainerLow,
+ shape:
+ RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
+ clipBehavior: Clip.antiAlias,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ SwitchListTile(
+ secondary: const Icon(Icons.travel_explore_rounded),
+ title: const Text('Bangumi 镜像'),
+ subtitle: const Text('加速热门与时间表加载'),
+ value: enableBangumiProxy,
+ onChanged: (value) async {
+ enableBangumiProxy = value;
+ await GStorage.putSetting(
+ SettingsKeys.enableBangumiProxy, value);
+ if (mounted) {
+ setState(() {});
+ }
+ },
+ ),
+ SwitchListTile(
+ secondary: const Icon(Icons.extension_rounded),
+ title: const Text('规则仓库镜像'),
+ subtitle: const Text('加速规则的下载与更新'),
+ value: enableGitProxy,
+ onChanged: (value) async {
+ enableGitProxy = value;
+ await GStorage.putSetting(SettingsKeys.enableGitProxy, value);
+ if (mounted) {
+ setState(() {});
+ }
+ },
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 4, 16, 12),
+ child: Row(
+ children: [
+ Icon(Icons.info_outline_rounded,
+ size: 16, color: colorScheme.onSurfaceVariant),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ '可稍后在 设置 → 同步设置 中修改',
+ style: Theme.of(context)
+ .textTheme
+ .bodySmall
+ ?.copyWith(color: colorScheme.onSurfaceVariant),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/onboarding/steps/plugin_shop_step.dart b/lib/pages/onboarding/steps/plugin_shop_step.dart
new file mode 100644
index 00000000..f4862365
--- /dev/null
+++ b/lib/pages/onboarding/steps/plugin_shop_step.dart
@@ -0,0 +1,28 @@
+import 'package:flutter/material.dart';
+import 'package:kazumi/pages/onboarding/onboarding_step_layout.dart';
+import 'package:kazumi/pages/plugin_editor/plugin_catalog_view.dart';
+import 'package:kazumi/plugins/plugins_controller.dart';
+
+class PluginShopStep extends StatelessWidget {
+ const PluginShopStep({
+ super.key,
+ required this.controller,
+ });
+
+ final PluginsController controller;
+
+ @override
+ Widget build(BuildContext context) {
+ return OnboardingStepLayout(
+ leading: const OnboardingStepIcon(icon: Icons.travel_explore_rounded),
+ title: '添加规则',
+ subtitle: '规则提供番剧搜索源,可稍后在 设置 → 规则管理 中调整',
+ child: PluginCatalogView(
+ controller: controller,
+ listPadding: EdgeInsets.zero,
+ showRefreshButton: true,
+ compactLastUpdate: true,
+ ),
+ );
+ }
+}
diff --git a/lib/pages/onboarding/steps/update_source_step.dart b/lib/pages/onboarding/steps/update_source_step.dart
new file mode 100644
index 00000000..080d3b38
--- /dev/null
+++ b/lib/pages/onboarding/steps/update_source_step.dart
@@ -0,0 +1,114 @@
+import 'package:flutter/material.dart';
+import 'package:kazumi/pages/onboarding/onboarding_step_layout.dart';
+
+class UpdateSourceStep extends StatelessWidget {
+ const UpdateSourceStep({
+ super.key,
+ required this.useGithubUpdate,
+ required this.onChanged,
+ });
+
+ /// true = Github 应用内检查更新,false = 交由 F-Droid 商店更新
+ final bool useGithubUpdate;
+ final ValueChanged<bool> onChanged;
+
+ @override
+ Widget build(BuildContext context) {
+ return OnboardingStepLayout(
+ leading: const OnboardingStepIcon(icon: Icons.system_update_rounded),
+ title: '更新来源',
+ subtitle: '选择获取应用更新的方式',
+ child: Align(
+ alignment: Alignment.topCenter,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _OptionCard(
+ icon: Icons.rocket_launch_rounded,
+ title: 'Github',
+ description: '应用内检查更新,适合大多数用户',
+ selected: useGithubUpdate,
+ onTap: () => onChanged(true),
+ ),
+ _OptionCard(
+ icon: Icons.storefront_rounded,
+ title: 'F-Droid',
+ description: '由 F-Droid 商店管理更新',
+ selected: !useGithubUpdate,
+ onTap: () => onChanged(false),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class _OptionCard extends StatelessWidget {
+ const _OptionCard({
+ required this.icon,
+ required this.title,
+ required this.description,
+ required this.selected,
+ required this.onTap,
+ });
+
+ final IconData icon;
+ final String title;
+ final String description;
+ final bool selected;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ final textTheme = Theme.of(context).textTheme;
+ return Card(
+ elevation: 0,
+ margin: const EdgeInsets.only(bottom: 12),
+ color: selected
+ ? colorScheme.secondaryContainer
+ : colorScheme.surfaceContainerLow,
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ onTap: onTap,
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: Row(
+ children: [
+ Icon(
+ icon,
+ color: selected
+ ? colorScheme.onSecondaryContainer
+ : colorScheme.onSurfaceVariant,
+ ),
+ const SizedBox(width: 16),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(title, style: textTheme.titleMedium),
+ const SizedBox(height: 2),
+ Text(
+ description,
+ style: textTheme.bodyMedium
+ ?.copyWith(color: colorScheme.onSurfaceVariant),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(width: 16),
+ Icon(
+ selected
+ ? Icons.check_circle_rounded
+ : Icons.circle_outlined,
+ color: selected ? colorScheme.primary : colorScheme.outline,
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/plugin_editor/plugin_catalog_view.dart b/lib/pages/plugin_editor/plugin_catalog_view.dart
new file mode 100644
index 00000000..d317fd5a
--- /dev/null
+++ b/lib/pages/plugin_editor/plugin_catalog_view.dart
@@ -0,0 +1,216 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:flutter_mobx/flutter_mobx.dart';
+import 'package:kazumi/bean/card/rule_card.dart';
+import 'package:kazumi/bean/widget/error_widget.dart';
+import 'package:kazumi/modules/plugin/plugin_http_module.dart';
+import 'package:kazumi/pages/plugin_editor/plugin_update_actions.dart';
+import 'package:kazumi/plugins/plugins_controller.dart';
+import 'package:kazumi/services/storage/storage.dart';
+
+enum PluginCatalogSort { lastUpdate, name }
+
+class PluginCatalogView extends StatefulWidget {
+ const PluginCatalogView({
+ super.key,
+ required this.controller,
+ this.sort = PluginCatalogSort.lastUpdate,
+ this.listPadding = const EdgeInsets.symmetric(horizontal: 8),
+ this.showRefreshButton = false,
+ this.compactLastUpdate = false,
+ this.errorMessage = '无法访问规则仓库',
+ });
+
+ final PluginsController controller;
+ final PluginCatalogSort sort;
+ final EdgeInsetsGeometry listPadding;
+ final bool showRefreshButton;
+ final bool compactLastUpdate;
+ final String errorMessage;
+
+ @override
+ State<PluginCatalogView> createState() => PluginCatalogViewState();
+}
+
+class PluginCatalogViewState extends State<PluginCatalogView> {
+ bool _loading = true;
+ bool _loadFailed = false;
+
+ PluginsController get _controller => widget.controller;
+
+ @override
+ void initState() {
+ super.initState();
+ if (_controller.isPluginCatalogFresh) {
+ _loading = false;
+ } else {
+ unawaited(_loadPluginCatalog());
+ }
+ }
+
+ Future<void> _loadPluginCatalog({bool forceRefresh = false}) async {
+ try {
+ if (forceRefresh) {
+ await _controller.refreshPluginCatalog();
+ } else {
+ await _controller.ensurePluginCatalog();
+ }
+ if (!mounted) return;
+ setState(() {
+ _loading = false;
+ _loadFailed = false;
+ });
+ } catch (_) {
+ if (!mounted) return;
+ setState(() {
+ _loading = false;
+ _loadFailed = true;
+ });
+ }
+ }
+
+ void refresh() {
+ if (_loading) return;
+ setState(() {
+ _loading = true;
+ _loadFailed = false;
+ });
+ unawaited(_loadPluginCatalog(forceRefresh: true));
+ }
+
+ Future<void> _toggleGitProxyAndRefresh() async {
+ final enableGitProxy = GStorage.getSetting(SettingsKeys.enableGitProxy);
+ await GStorage.putSetting(SettingsKeys.enableGitProxy, !enableGitProxy);
+ if (!mounted) return;
+ refresh();
+ }
+
+ List<PluginHTTPItem> _sortedItems() {
+ final items = _controller.pluginHTTPList.toList();
+ switch (widget.sort) {
+ case PluginCatalogSort.lastUpdate:
+ items.sort((a, b) => b.lastUpdate.compareTo(a.lastUpdate));
+ case PluginCatalogSort.name:
+ items.sort(
+ (a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()),
+ );
+ }
+ return items;
+ }
+
+ Widget _buildPluginList() {
+ return Observer(builder: (context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ final items = _sortedItems();
+
+ return ListView.builder(
+ padding: widget.listPadding,
+ itemCount: items.length,
+ itemBuilder: (context, index) {
+ final item = items[index];
+ final status = _controller.pluginStatus(item);
+ return RuleCard(
+ title: item.name,
+ tags: [
+ RuleTag(
+ label: item.version,
+ background: colorScheme.secondaryContainer,
+ foreground: colorScheme.onSecondaryContainer,
+ ),
+ if (item.antiCrawlerEnabled)
+ RuleTag(
+ label: 'captcha',
+ background: colorScheme.tertiaryContainer,
+ foreground: colorScheme.onTertiaryContainer,
+ ),
+ ],
+ caption:
+ item.lastUpdate > 0 ? _formatLastUpdate(item.lastUpdate) : null,
+ trailing: RuleCardActionButton(
+ label: switch (status) {
+ PluginCatalogItemStatus.install => '安装',
+ PluginCatalogItemStatus.installed => '已安装',
+ PluginCatalogItemStatus.update => '更新',
+ },
+ onPressed: status == PluginCatalogItemStatus.installed
+ ? null
+ : () async {
+ final result = await updatePluginWithFeedback(
+ _controller,
+ item.name,
+ installing: status == PluginCatalogItemStatus.install,
+ );
+ if (result == PluginUpdateResult.updated && mounted) {
+ setState(() {});
+ }
+ },
+ ),
+ );
+ },
+ );
+ });
+ }
+
+ String _formatLastUpdate(int millisecondsSinceEpoch) {
+ final value =
+ DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch).toString();
+ if (widget.compactLastUpdate) {
+ return value.split(' ')[0];
+ }
+ return '更新时间: ${value.split('.')[0]}';
+ }
+
+ Widget _buildLoadError() {
+ final enableGitProxy = GStorage.getSetting(SettingsKeys.enableGitProxy);
+ return Center(
+ child: GeneralErrorWidget(
+ errMsg:
+ '${widget.errorMessage}\n${enableGitProxy ? '规则仓库镜像已启用' : '规则仓库镜像已禁用'}',
+ actions: [
+ GeneralErrorButton(
+ onPressed: () => unawaited(_toggleGitProxyAndRefresh()),
+ text: enableGitProxy ? '禁用规则镜像' : '启用规则镜像',
+ ),
+ GeneralErrorButton(onPressed: refresh, text: '刷新'),
+ ],
+ ),
+ );
+ }
+
+ Widget _buildBody() {
+ if (_loading) {
+ return const Center(child: CircularProgressIndicator());
+ }
+ if (_loadFailed) {
+ return _buildLoadError();
+ }
+ if (_controller.pluginHTTPList.isEmpty) {
+ return const Center(child: Text('规则仓库中暂无规则'));
+ }
+ return _buildPluginList();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ if (!widget.showRefreshButton) {
+ return _buildBody();
+ }
+ return Column(
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ IconButton(
+ onPressed: refresh,
+ tooltip: '刷新规则列表',
+ icon: const Icon(Icons.refresh_rounded),
+ ),
+ ],
+ ),
+ const SizedBox(height: 4),
+ Expanded(child: _buildBody()),
+ ],
+ );
+ }
+}
diff --git a/lib/pages/plugin_editor/plugin_shop_page.dart b/lib/pages/plugin_editor/plugin_shop_page.dart
index cec2feb2..f1a39569 100644
--- a/lib/pages/plugin_editor/plugin_shop_page.dart
+++ b/lib/pages/plugin_editor/plugin_shop_page.dart
@@ -1,14 +1,7 @@
-import 'dart:async';
-
import 'package:flutter/material.dart';
-import 'package:flutter_mobx/flutter_mobx.dart';
-import 'package:flutter_modular/flutter_modular.dart';
-import 'package:kazumi/bean/dialog/dialog_helper.dart';
-import 'package:kazumi/bean/widget/error_widget.dart';
-import 'package:kazumi/plugins/plugins_controller.dart';
-import 'package:kazumi/pages/plugin_editor/plugin_update_actions.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
-import 'package:kazumi/services/storage/storage.dart';
+import 'package:kazumi/pages/plugin_editor/plugin_catalog_view.dart';
+import 'package:kazumi/plugins/plugins_controller.dart';
class PluginShopPage extends StatefulWidget {
const PluginShopPage({
@@ -23,233 +16,37 @@ class PluginShopPage extends StatefulWidget {
}
class _PluginShopPageState extends State<PluginShopPage> {
- bool loadFailed = false;
- bool loading = true;
- late bool enableGitProxy;
-
- // 排序方式状态:false=按更新时间排序,true=按名称排序
+ final catalogKey = GlobalKey<PluginCatalogViewState>();
bool sortByName = false;
- PluginsController get pluginsController => widget.controller;
-
- void onBackPressed(BuildContext context) {
- if (KazumiDialog.observer.hasKazumiDialog) {
- KazumiDialog.dismiss();
- return;
- }
- }
-
- @override
- void initState() {
- super.initState();
- enableGitProxy = GStorage.getSetting(SettingsKeys.enableGitProxy);
- if (pluginsController.isPluginCatalogFresh) {
- loading = false;
- } else {
- unawaited(_loadPluginCatalog());
- }
- }
-
- Future<void> _loadPluginCatalog({bool forceRefresh = false}) async {
- try {
- if (forceRefresh) {
- await pluginsController.refreshPluginCatalog();
- } else {
- await pluginsController.ensurePluginCatalog();
- }
- if (!mounted) return;
- setState(() {
- loading = false;
- loadFailed = false;
- });
- } catch (_) {
- if (!mounted) return;
- setState(() {
- loading = false;
- loadFailed = true;
- });
- }
- }
- // 刷新规则列表
- void _handleRefresh() {
- if (loading) return;
- setState(() {
- loading = true;
- loadFailed = false;
- enableGitProxy = GStorage.getSetting(SettingsKeys.enableGitProxy);
- });
- unawaited(_loadPluginCatalog(forceRefresh: true));
- }
-
- // 切换排序方式
void _toggleSort() {
setState(() {
sortByName = !sortByName;
});
}
- Widget get pluginHTTPListBody {
- return Observer(builder: (context) {
- // 创建列表副本用于排序
- final sortedList = pluginsController.pluginHTTPList.toList();
-
- // 排序规则:
- // 1. 按名称排序:忽略大小写的字母顺序
- // 2. 按时间排序:更新时间降序(最新的在前面)
- if (sortByName) {
- sortedList.sort(
- (a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
- } else {
- sortedList.sort((a, b) => b.lastUpdate.compareTo(a.lastUpdate));
- }
-
- return ListView.builder(
- itemCount: sortedList.length,
- itemBuilder: (context, index) {
- final item = sortedList[index];
- final status = pluginsController.pluginStatus(item);
- return Card(
- margin: const EdgeInsets.fromLTRB(8, 0, 8, 8),
- child: ListTile(
- title: Row(
- children: [
- Text(
- item.name,
- style: const TextStyle(fontWeight: FontWeight.bold),
- ),
- ],
- ),
- subtitle: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 8.0, vertical: 1.0),
- decoration: BoxDecoration(
- color: Theme.of(context).colorScheme.secondary,
- borderRadius: BorderRadius.circular(16.0),
- ),
- child: Text(
- item.version,
- style: TextStyle(
- color: Theme.of(context).colorScheme.surface),
- ),
- ),
- if (item.antiCrawlerEnabled) ...[
- const SizedBox(width: 5),
- Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 8.0, vertical: 1.0),
- decoration: BoxDecoration(
- color: Theme.of(context).colorScheme.tertiary,
- borderRadius: BorderRadius.circular(16.0),
- ),
- child: Text(
- 'captcha',
- style: TextStyle(
- color:
- Theme.of(context).colorScheme.onTertiary),
- ),
- ),
- ],
- ],
- ),
- if (item.lastUpdate > 0) ...[
- const SizedBox(height: 4),
- Text(
- '更新时间: ${DateTime.fromMillisecondsSinceEpoch(item.lastUpdate).toString().split('.')[0]}',
- style: const TextStyle(color: Colors.grey),
- ),
- ],
- ],
- ),
- trailing: TextButton(
- onPressed: status == PluginCatalogItemStatus.installed
- ? null
- : () async {
- final result = await updatePluginWithFeedback(
- pluginsController,
- item.name,
- installing:
- status == PluginCatalogItemStatus.install,
- );
- if (result == PluginUpdateResult.updated && mounted) {
- setState(() {});
- }
- },
- child: Text(
- switch (status) {
- PluginCatalogItemStatus.install => '安装',
- PluginCatalogItemStatus.installed => '已安装',
- PluginCatalogItemStatus.update => '更新',
- },
- ),
- )),
- );
- },
- );
- });
- }
-
- Widget get loadErrorWidget {
- return Center(
- child: GeneralErrorWidget(
- errMsg:
- '啊咧(⊙.⊙) 无法访问规则仓库\n${enableGitProxy ? '规则仓库镜像已启用' : '规则仓库镜像已禁用'}',
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: SysAppBar(
+ title: const Text('规则仓库'),
actions: [
- GeneralErrorButton(
- onPressed: () {
- context.pushNamed('/settings/webdav/');
- },
- text: enableGitProxy ? '禁用规则镜像' : '启用规则镜像',
- ),
- GeneralErrorButton(
- onPressed: () {
- _handleRefresh();
- },
- text: '刷新',
- ),
+ IconButton(
+ onPressed: _toggleSort,
+ tooltip: sortByName ? '按名称排序' : '按更新时间排序',
+ icon: Icon(sortByName ? Icons.sort_by_alpha : Icons.access_time)),
+ IconButton(
+ onPressed: () => catalogKey.currentState?.refresh(),
+ tooltip: '刷新规则列表',
+ icon: const Icon(Icons.refresh))
],
),
- );
- }
-
- @override
- Widget build(BuildContext context) {
- return PopScope(
- canPop: true,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: SysAppBar(
- title: const Text('规则仓库'),
- actions: [
- IconButton(
- onPressed: _toggleSort,
- tooltip: sortByName ? '按名称排序' : '按更新时间排序',
- icon:
- Icon(sortByName ? Icons.sort_by_alpha : Icons.access_time)),
- IconButton(
- onPressed: () {
- _handleRefresh();
- },
- tooltip: '刷新规则列表',
- icon: const Icon(Icons.refresh))
- ],
- ),
- body: loading
- ? const Center(child: CircularProgressIndicator())
- : loadFailed
- ? loadErrorWidget
- : pluginsController.pluginHTTPList.isEmpty
- ? const Center(child: Text('规则仓库中暂无规则'))
- : pluginHTTPListBody,
+ body: PluginCatalogView(
+ key: catalogKey,
+ controller: widget.controller,
+ sort:
+ sortByName ? PluginCatalogSort.name : PluginCatalogSort.lastUpdate,
+ errorMessage: '啊咧(⊙.⊙) 无法访问规则仓库',
),
);
}
diff --git a/lib/pages/plugin_editor/plugin_view_page.dart b/lib/pages/plugin_editor/plugin_view_page.dart
index 5941fa33..0ac96a88 100644
--- a/lib/pages/plugin_editor/plugin_view_page.dart
+++ b/lib/pages/plugin_editor/plugin_view_page.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_modular/flutter_modular.dart';
+import 'package:kazumi/bean/card/rule_card.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/plugins/plugins.dart';
import 'package:kazumi/plugins/plugins_controller.dart';
@@ -54,7 +55,6 @@ class _PluginViewPageState extends State<PluginViewPage> {
void _handleAdd() {
KazumiDialog.show(builder: (context) {
return AlertDialog(
- // contentPadding: EdgeInsets.zero, // 设置为零以减小内边距
content: SingleChildScrollView(
// 使用可滚动的SingleChildScrollView包装Column
child: Column(
@@ -178,6 +178,9 @@ class _PluginViewPageState extends State<PluginViewPage> {
return PopScope(
canPop: !isMultiSelectMode,
onPopInvokedWithResult: (bool didPop, Object? result) {
+ if (didPop) {
+ return;
+ }
if (isMultiSelectMode) {
setState(() {
isMultiSelectMode = false;
@@ -273,8 +276,10 @@ class _PluginViewPageState extends State<PluginViewPage> {
child: Text('啊咧(⊙.⊙) 没有可用规则的说'),
)
: Builder(builder: (context) {
+ final colorScheme = Theme.of(context).colorScheme;
return ReorderableListView.builder(
buildDefaultDragHandles: false,
+ padding: const EdgeInsets.symmetric(horizontal: 8),
proxyDecorator: (child, index, animation) {
return Material(
elevation: 0,
@@ -291,106 +296,54 @@ class _PluginViewPageState extends State<PluginViewPage> {
bool canUpdate =
pluginsController.pluginUpdateStatus(plugin) ==
PluginUpdateAvailability.updatable;
- return Card(
- key: ObjectKey(plugin),
- margin: const EdgeInsets.fromLTRB(8, 0, 8, 8),
- child: ListTile(
- trailing: pluginCardTrailing(index),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12)),
- onLongPress: () {
- if (!isMultiSelectMode) {
- setState(() {
- isMultiSelectMode = true;
- selectedNames.add(plugin.name);
- });
- }
- },
- onTap: () {
- if (isMultiSelectMode) {
- setState(() {
- if (selectedNames.contains(plugin.name)) {
- selectedNames.remove(plugin.name);
- if (selectedNames.isEmpty) {
- isMultiSelectMode = false;
- }
- } else {
- selectedNames.add(plugin.name);
- }
- });
+ return RuleCard(
+ key: ObjectKey(plugin),
+ title: plugin.name,
+ selected: selectedNames.contains(plugin.name),
+ trailing: pluginCardTrailing(index),
+ onLongPress: () {
+ if (!isMultiSelectMode) {
+ setState(() {
+ isMultiSelectMode = true;
+ selectedNames.add(plugin.name);
+ });
+ }
+ },
+ onTap: () {
+ if (isMultiSelectMode) {
+ setState(() {
+ if (selectedNames.contains(plugin.name)) {
+ selectedNames.remove(plugin.name);
+ if (selectedNames.isEmpty) {
+ isMultiSelectMode = false;
+ }
+ } else {
+ selectedNames.add(plugin.name);
}
- },
- selected: selectedNames.contains(plugin.name),
- selectedTileColor: Theme.of(context)
- .colorScheme
- .primaryContainer,
- title: Text(
- plugin.name,
- style: const TextStyle(
- fontWeight: FontWeight.bold),
+ });
+ }
+ },
+ tags: [
+ RuleTag(
+ label: plugin.version,
+ background: colorScheme.secondaryContainer,
+ foreground: colorScheme.onSecondaryContainer,
+ ),
+ if (canUpdate)
+ RuleTag(
+ label: '可更新',
+ background: colorScheme.errorContainer,
+ foreground: colorScheme.onErrorContainer,
),
- subtitle: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Text(
- 'Version: ${plugin.version}',
- style:
- const TextStyle(color: Colors.grey),
- ),
- if (canUpdate) ...[
- const SizedBox(width: 8),
- Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 6, vertical: 2),
- decoration: BoxDecoration(
- color: Theme.of(context)
- .colorScheme
- .errorContainer,
- borderRadius:
- BorderRadius.circular(4),
- ),
- child: Text(
- '可更新',
- style: TextStyle(
- fontSize: 12,
- color: Theme.of(context)
- .colorScheme
- .onErrorContainer,
- ),
- ),
- ),
- ],
- if (pluginsController.validityTracker
- .isSearchValid(plugin.name)) ...[
- const SizedBox(width: 8),
- Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 6, vertical: 2),
- decoration: BoxDecoration(
- color: Theme.of(context)
- .colorScheme
- .tertiaryContainer,
- borderRadius:
- BorderRadius.circular(4),
- ),
- child: Text(
- '搜索有效',
- style: TextStyle(
- fontSize: 12,
- color: Theme.of(context)
- .colorScheme
- .onTertiaryContainer,
- ),
- ),
- ),
- ],
- ],
- ),
- ],
+ if (pluginsController.validityTracker
+ .isSearchValid(plugin.name))
+ RuleTag(
+ label: '搜索有效',
+ background: colorScheme.tertiaryContainer,
+ foreground: colorScheme.onTertiaryContainer,
),
- ));
+ ],
+ );
});
});
}),
diff --git a/lib/services/storage/settings_keys.dart b/lib/services/storage/settings_keys.dart
index 1f80e628..e81a39a7 100644
--- a/lib/services/storage/settings_keys.dart
+++ b/lib/services/storage/settings_keys.dart
@@ -248,12 +248,12 @@ class SettingsKeys {
);
static const enableGitProxy = SettingKey<bool>(
_SettingBoxKey.enableGitProxy,
- false,
+ true,
group: SettingGroup.proxy,
);
static const enableBangumiProxy = SettingKey<bool>(
_SettingBoxKey.enableBangumiProxy,
- false,
+ true,
group: SettingGroup.proxy,
);
static const enableSystemProxy = SettingKey<bool>(