基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
fix(settings): prevent duplicate window controls in nested (#2589)
Prediditd163d2a47b94
diff --git a/lib/bean/appbar/sys_app_bar.dart b/lib/bean/appbar/sys_app_bar.dartindex 1e2e4cf1..8d799a54 100644--- a/lib/bean/appbar/sys_app_bar.dart+++ b/lib/bean/appbar/sys_app_bar.dart@@ -9,57 +9,46 @@ import 'package:kazumi/utils/device.dart';class SysAppBar extends StatelessWidget implements PreferredSizeWidget {final double? toolbarHeight;-final Widget? title;-final Color? backgroundColor;-- final double? elevation;-- final ShapeBorder? shape;-final List<Widget>? actions;-final Widget? leading;-- final double? leadingWidth;-- final PreferredSizeWidget? bottom;-final bool needTopOffset;- const SysAppBar(- {super.key,- this.toolbarHeight,- this.title,- this.backgroundColor,- this.elevation,- this.shape,- this.actions,- this.leading,- this.leadingWidth,- this.bottom,- this.needTopOffset = true});+ const SysAppBar({+ super.key,+ this.toolbarHeight,+ this.title,+ this.backgroundColor,+ this.actions,+ this.leading,+ this.needTopOffset = true,+ });- bool showWindowButton() {- return GStorage.getSetting(SettingsKeys.showWindowButton);- }+ bool get _showWindowButton =>+ GStorage.getSetting(SettingsKeys.showWindowButton);@overrideWidget build(BuildContext context) {- List<Widget> acs = [];- if (actions != null) {- acs.addAll(actions!);- }- if (isDesktop()) {- // acs.add(IconButton(onPressed: () => windowManager.minimize(), icon: const Icon(Icons.minimize)));- if (!showWindowButton()) {- acs.add(CloseButton(onPressed: () => windowManager.close()));+ final desktop = isDesktop();+ final appBarActions = <Widget>[...?actions];+ if (desktop) {+ if (!_showWindowButton) {+ appBarActions.add(CloseButton(onPressed: () => windowManager.close()));}- acs.add(const SizedBox(width: 8));+ appBarActions.add(const SizedBox(width: 8));}+ final appBarLeading =+ leading ??+ ((ModalRoute.of(context)?.impliesAppBarDismissal ?? false)+ ? IconButton(+ onPressed: () => context.maybePop(),+ icon: const Icon(Icons.arrow_back),+ )+ : null);+return GestureDetector(- onPanStart: (_) => (isDesktop()) ? windowManager.startDragging() : null,+ onPanStart: desktop ? (_) => windowManager.startDragging() : null,child: AppBar(toolbarHeight: preferredSize.height,scrolledUnderElevation: 0.0,@@ -69,41 +58,27 @@ class SysAppBar extends StatelessWidget implements PreferredSizeWidget {child: title!,): null,- centerTitle: Platform.isIOS ? true : false,- actions: acs.map((e) {+ centerTitle: Platform.isIOS,+ actions: appBarActions.map((action) {return EmbeddedNativeControlArea(requireOffset: needTopOffset,- child: e,+ child: action,);}).toList(),- leading: leading != null+ leading: appBarLeading != null? EmbeddedNativeControlArea(requireOffset: needTopOffset,- child: leading!,+ child: appBarLeading,)- : (ModalRoute.of(context)?.impliesAppBarDismissal ?? false)- ? EmbeddedNativeControlArea(- requireOffset: needTopOffset,- child: IconButton(- onPressed: () {- context.maybePop();- },- icon: Icon(Icons.arrow_back),- ),- )- : null,- leadingWidth: leadingWidth,+ : null,backgroundColor: backgroundColor,- elevation: elevation,- shape: shape,- bottom: bottom,automaticallyImplyLeading: false,systemOverlayStyle: SystemUiOverlayStyle(statusBarColor: Colors.transparent,statusBarIconBrightness:Theme.of(context).brightness == Brightness.light- ? Brightness.dark- : Brightness.light,+ ? Brightness.dark+ : Brightness.light,systemNavigationBarColor: Colors.transparent,systemNavigationBarDividerColor: Colors.transparent,),@@ -113,16 +88,10 @@ class SysAppBar extends StatelessWidget implements PreferredSizeWidget {@overrideSize get preferredSize {- // macOS needs to add 22(macOS title bar height)- // to default toolbar height to build appbar like normal- if (Platform.isMacOS && needTopOffset && showWindowButton()) {- if (toolbarHeight != null) {- return Size.fromHeight(toolbarHeight! + 22);- } else {- return const Size.fromHeight(kToolbarHeight + 22);- }- } else {- return Size.fromHeight(toolbarHeight ?? kToolbarHeight);- }+ // Reserve space for native macOS window controls.+ final topOffset = Platform.isMacOS && needTopOffset && _showWindowButton+ ? 22.0+ : 0.0;+ return Size.fromHeight((toolbarHeight ?? kToolbarHeight) + topOffset);}}diff --git a/lib/bean/settings/settings_detail_scaffold.dart b/lib/bean/settings/settings_detail_scaffold.dartindex cdaea812..a7803f24 100644--- a/lib/bean/settings/settings_detail_scaffold.dart+++ b/lib/bean/settings/settings_detail_scaffold.dart@@ -34,6 +34,7 @@ class SettingsDetailScaffold extends StatelessWidget {this.actions,this.leading,this.floatingActionButton,+ this.bottomNavigationBar,});final Widget title;@@ -41,6 +42,7 @@ class SettingsDetailScaffold extends StatelessWidget {final List<Widget>? actions;final Widget? leading;final Widget? floatingActionButton;+ final Widget? bottomNavigationBar;@overrideWidget build(BuildContext context) {@@ -48,7 +50,8 @@ class SettingsDetailScaffold extends StatelessWidget {final PreferredSizeWidget appBar;if (scope != null && scope.embedded) {- final paneLeading = leading ??+ final paneLeading =+ leading ??((scope.showBackButton ||(ModalRoute.of(context)?.impliesAppBarDismissal ?? false))? BackButton(onPressed: scope.onBack)@@ -58,33 +61,30 @@ class SettingsDetailScaffold extends StatelessWidget {scrolledUnderElevation: 0,automaticallyImplyLeading: false,toolbarHeight: 64,- titleSpacing:- paneLeading == null ? 24 : NavigationToolbar.kMiddleSpacing,+ titleSpacing: paneLeading == null+ ? 24+ : NavigationToolbar.kMiddleSpacing,leading: paneLeading,title: title,titleTextStyle: Theme.of(context).textTheme.headlineSmall,actions: actions,);} else {- final onBack = scope?.onBack;appBar = SysAppBar(title: title,actions: actions,- leading: leading ??- (onBack == null- ? null- : IconButton(- onPressed: onBack,- icon: const Icon(Icons.arrow_back),- )),+ leading:+ leading ??+ (scope == null ? null : BackButton(onPressed: scope.onBack)),);}- // Routed panes must paint an opaque surface for page transitions.+ // Keep routed panes opaque during transitions.return Scaffold(appBar: appBar,body: body,floatingActionButton: floatingActionButton,+ bottomNavigationBar: bottomNavigationBar,);}}diff --git a/lib/pages/logs/logs_page.dart b/lib/pages/logs/logs_page.dartindex 900f6b94..9e0591a0 100644--- a/lib/pages/logs/logs_page.dart+++ b/lib/pages/logs/logs_page.dart@@ -5,8 +5,8 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:path_provider/path_provider.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/bean/widget/empty_state_widget.dart';import 'package:kazumi/bean/widget/error_widget.dart';import 'package:kazumi/bean/widget/loading_indicator.dart';@@ -160,16 +160,14 @@ class _LogsPageState extends State<LogsPage> {@overrideWidget build(BuildContext context) {- return Scaffold(- appBar: const SysAppBar(- title: Text('日志'),- ),- body: buildBody,- floatingActionButton: buildFloatingButtons,+ return SettingsDetailScaffold(+ title: const Text('日志'),+ body: _buildBody(),+ floatingActionButton: _buildFloatingButtons(),);}- Widget get buildBody {+ Widget _buildBody() {if (_isLoading) {return const Center(child: LoadingIndicator(),@@ -222,7 +220,7 @@ class _LogsPageState extends State<LogsPage> {);}- Widget get buildFloatingButtons {+ Widget _buildFloatingButtons() {return Row(mainAxisAlignment: MainAxisAlignment.end,children: [diff --git a/lib/pages/plugin_editor/plugin_editor_page.dart b/lib/pages/plugin_editor/plugin_editor_page.dartindex 20c21a82..276b4a83 100644--- a/lib/pages/plugin_editor/plugin_editor_page.dart+++ b/lib/pages/plugin_editor/plugin_editor_page.dart@@ -3,7 +3,7 @@ import 'dart:convert';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/settings/settings_detail_scaffold.dart';import 'package:kazumi/bean/widget/loading_indicator.dart';import 'package:kazumi/pages/plugin_editor/rule_management_widgets.dart';import 'package:kazumi/pages/plugin_editor/editor_form_widgets.dart';@@ -221,7 +221,7 @@ class _PluginEditorPageState extends State<PluginEditorPage> {String chapterApiMethod = 'GET';String chapterApiBodyType = ApiBodyType.none;String chapterApiFormat = ApiChapterFormat.nested;- // Preserve legacy schema values on save, even when no longer editable.+ // Preserve legacy fields that the editor no longer exposes.late String _api;late String _type;late bool _muliSources;@@ -431,8 +431,8 @@ class _PluginEditorPageState extends State<PluginEditorPage> {@overrideWidget build(BuildContext context) {final colors = Theme.of(context).colorScheme;- return Scaffold(- appBar: const SysAppBar(title: Text(_RuleEditorText.pageTitle)),+ return SettingsDetailScaffold(+ title: const Text(_RuleEditorText.pageTitle),body: SafeArea(top: false,bottom: false,diff --git a/lib/pages/plugin_editor/plugin_shop_page.dart b/lib/pages/plugin_editor/plugin_shop_page.dartindex d1f31ad8..a09c0901 100644--- a/lib/pages/plugin_editor/plugin_shop_page.dart+++ b/lib/pages/plugin_editor/plugin_shop_page.dart@@ -1,5 +1,5 @@import 'package:flutter/material.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/pages/plugin_editor/plugin_catalog_view.dart';import 'package:kazumi/plugins/plugins_controller.dart';@@ -8,8 +8,8 @@ class PluginShopPage extends StatelessWidget {final PluginsController controller;@override- Widget build(BuildContext context) => Scaffold(- appBar: const SysAppBar(title: Text('规则仓库')),+ Widget build(BuildContext context) => SettingsDetailScaffold(+ title: const Text('规则仓库'),body: SafeArea(top: false,child: Align(diff --git a/lib/pages/plugin_editor/plugin_test_page.dart b/lib/pages/plugin_editor/plugin_test_page.dartindex bbde1a3c..463e452f 100644--- a/lib/pages/plugin_editor/plugin_test_page.dart+++ b/lib/pages/plugin_editor/plugin_test_page.dart@@ -3,8 +3,8 @@ import 'dart:convert';import 'package:dio/dio.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/bean/widget/loading_indicator.dart';import 'package:kazumi/modules/roads/road_module.dart';import 'package:kazumi/modules/search/plugin_search_module.dart';@@ -105,7 +105,7 @@ class _PluginTestPageState extends State<PluginTestPage> {return;}_resetState();- // Ignore late responses from requests that do not honor cancellation.+ // Ignore late responses when cancellation is not honored.final runId = _runId;final cancelToken = _testCancelToken = CancelToken();setState(() {@@ -148,18 +148,16 @@ class _PluginTestPageState extends State<PluginTestPage> {@overrideWidget build(BuildContext context) {final theme = Theme.of(context);- return Scaffold(- appBar: SysAppBar(- title: const Text('规则测试'),- actions: [- IconButton(- onPressed: _resetState,- icon: const Icon(Icons.restart_alt_rounded),- tooltip: '重置测试',- ),- const SizedBox(width: 8),- ],- ),+ return SettingsDetailScaffold(+ title: const Text('规则测试'),+ actions: [+ IconButton(+ onPressed: _resetState,+ icon: const Icon(Icons.restart_alt_rounded),+ tooltip: '重置测试',+ ),+ const SizedBox(width: 8),+ ],body: SafeArea(top: false,child: SingleChildScrollView(diff --git a/lib/pages/route_error_page.dart b/lib/pages/route_error_page.dartindex 0e1b92f8..eb10ca33 100644--- a/lib/pages/route_error_page.dart+++ b/lib/pages/route_error_page.dart@@ -1,6 +1,6 @@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/settings/settings_detail_scaffold.dart';import 'package:kazumi/bean/widget/error_widget.dart';import 'package:kazumi/bean/widget/state_presentation.dart';@@ -14,8 +14,8 @@ class RouteErrorPage extends StatelessWidget {@overrideWidget build(BuildContext context) {- return Scaffold(- appBar: const SysAppBar(title: Text('Kazumi')),+ return SettingsDetailScaffold(+ title: const Text('Kazumi'),body: GeneralErrorWidget(title: '无法打开页面',errMsg: message,