From 9dc7ce03f27c38d8f6df901d056f113d33020e9f Mon Sep 17 00:00:00 2001 From: niuhuan Date: Fri, 25 Mar 2022 22:57:30 +0800 Subject: [PATCH] setting right click pop --- lib/basic/Common.dart | 4 +- lib/basic/config/ListLayout.dart | 2 +- lib/basic/config/ShadowCategories.dart | 2 +- lib/basic/config/Themes.dart | 8 +-- lib/basic/config/UsingRightClickPop.dart | 48 +++++++++++++ lib/screens/AboutScreen.dart | 8 ++- lib/screens/AccountScreen.dart | 18 +++-- lib/screens/CategoriesScreen.dart | 8 +-- lib/screens/CleanScreen.dart | 11 ++- lib/screens/ComicInfoScreen.dart | 6 +- lib/screens/ComicReaderScreen.dart | 6 +- lib/screens/ComicsScreen.dart | 6 +- lib/screens/CommentScreen.dart | 6 +- lib/screens/DownloadConfirmScreen.dart | 6 +- lib/screens/DownloadExportToFileScreen.dart | 11 ++- lib/screens/DownloadExportToSocketScreen.dart | 11 ++- lib/screens/DownloadImportScreen.dart | 11 ++- lib/screens/DownloadListScreen.dart | 18 +++-- lib/screens/DownloadReaderScreen.dart | 13 +++- lib/screens/FavouritePaperScreen.dart | 6 +- lib/screens/FilePhotoViewScreen.dart | 10 ++- lib/screens/GameDownloadScreen.dart | 6 +- lib/screens/GameInfoScreen.dart | 6 +- lib/screens/GamesScreen.dart | 16 +++-- lib/screens/MigrateScreen.dart | 6 +- lib/screens/ModifyPasswordScreen.dart | 6 +- lib/screens/NetworkSettingsScreen.dart | 6 +- lib/screens/RandomComicsScreen.dart | 6 +- lib/screens/RankingsScreen.dart | 6 +- lib/screens/RegisterScreen.dart | 6 +- lib/screens/SearchScreen.dart | 6 +- lib/screens/SettingsScreen.dart | 8 ++- lib/screens/ThemeScreen.dart | 6 +- lib/screens/ViewLogsScreen.dart | 6 +- lib/screens/components/ComicTagsCard.dart | 4 +- lib/screens/components/CommentList.dart | 8 +-- lib/screens/components/ContentBuilder.dart | 2 +- lib/screens/components/ImageReader.dart | 69 ++++++++++--------- lib/screens/components/Images.dart | 2 +- lib/screens/components/RightClickPop.dart | 28 ++++---- 40 files changed, 312 insertions(+), 110 deletions(-) create mode 100644 lib/basic/config/UsingRightClickPop.dart diff --git a/lib/basic/Common.dart b/lib/basic/Common.dart index 14bb59a..2e202e6 100644 --- a/lib/basic/Common.dart +++ b/lib/basic/Common.dart @@ -145,7 +145,7 @@ Future chooseMapDialog( /// 输入对话框1 -var _controller = TextEditingController.fromValue(TextEditingValue(text: '')); +var _controller = TextEditingController.fromValue(const TextEditingValue(text: '')); Future displayTextInputDialog(BuildContext context, {String? title, @@ -190,7 +190,7 @@ Future displayTextInputDialog(BuildContext context, ), actions: [ MaterialButton( - child: Text('取消'), + child: const Text('取消'), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/basic/config/ListLayout.dart b/lib/basic/config/ListLayout.dart index 6e75a58..9644506 100644 --- a/lib/basic/config/ListLayout.dart +++ b/lib/basic/config/ListLayout.dart @@ -51,5 +51,5 @@ IconButton chooseLayoutActionButton(BuildContext context) => IconButton( onPressed: () { _chooseListLayout(context); }, - icon: Icon(Icons.view_quilt), + icon: const Icon(Icons.view_quilt), ); diff --git a/lib/basic/config/ShadowCategories.dart b/lib/basic/config/ShadowCategories.dart index d5a0db6..7afaa66 100644 --- a/lib/basic/config/ShadowCategories.dart +++ b/lib/basic/config/ShadowCategories.dart @@ -61,7 +61,7 @@ Widget shadowCategoriesActionButton(BuildContext context) { onPressed: () { _chooseShadowCategories(context); }, - icon: Icon(Icons.hide_source), + icon: const Icon(Icons.hide_source), ); } diff --git a/lib/basic/config/Themes.dart b/lib/basic/config/Themes.dart index 7197fbf..97faa9b 100644 --- a/lib/basic/config/Themes.dart +++ b/lib/basic/config/Themes.dart @@ -99,7 +99,7 @@ class _PinkTheme extends _ThemePackage { appBarTheme: AppBarTheme( systemOverlayStyle: SystemUiOverlayStyle.light, color: Colors.pink.shade200, - iconTheme: IconThemeData( + iconTheme: const IconThemeData( color: Colors.white, ), ), @@ -141,7 +141,7 @@ class _BlackTheme extends _ThemePackage { appBarTheme: AppBarTheme( systemOverlayStyle: SystemUiOverlayStyle.light, color: Colors.grey.shade800, - iconTheme: IconThemeData( + iconTheme: const IconThemeData( color: Colors.white, ), ), @@ -238,11 +238,11 @@ class _DustyBlueTheme extends _ThemePackage { color: Colors.white, ), ), - dialogTheme: DialogTheme( + dialogTheme: const DialogTheme( backgroundColor: Color(0xff20253b), ), bottomNavigationBarTheme: BottomNavigationBarThemeData( - backgroundColor: Color(0xff191b26), + backgroundColor: const Color(0xff191b26), selectedItemColor: Colors.blue.shade200, unselectedItemColor: Colors.grey.shade500, ), diff --git a/lib/basic/config/UsingRightClickPop.dart b/lib/basic/config/UsingRightClickPop.dart new file mode 100644 index 0000000..ccfc0ea --- /dev/null +++ b/lib/basic/config/UsingRightClickPop.dart @@ -0,0 +1,48 @@ +/// 自动全屏 + +import 'dart:io'; + +import 'package:flutter/material.dart'; + +import '../Common.dart'; +import '../Method.dart'; + +const _propertyName = "usingRightClickPop"; +late bool _usingRightClickPop; + +Future initUsingRightClickPop() async { + _usingRightClickPop = + (await method.loadProperty(_propertyName, "false")) == "true"; +} + +bool currentUsingRightClickPop() { + return _usingRightClickPop; +} + +Future _chooseUsingRightClickPop(BuildContext context) async { + String? result = + await chooseListDialog(context, "鼠标右键返回上一页", ["是", "否"]); + if (result != null) { + var target = result == "是"; + await method.saveProperty(_propertyName, "$target"); + _usingRightClickPop = target; + } +} + +Widget usingRightClickPopSetting() { + if (!(Platform.isWindows || Platform.isMacOS || Platform.isLinux)) { + return Container(); + } + return StatefulBuilder( + builder: (BuildContext context, void Function(void Function()) setState) { + return ListTile( + title: const Text("鼠标右键返回上一页"), + subtitle: Text(_usingRightClickPop ? "是" : "否"), + onTap: () async { + await _chooseUsingRightClickPop(context); + setState(() {}); + }, + ); + }, + ); +} diff --git a/lib/screens/AboutScreen.dart b/lib/screens/AboutScreen.dart index c76abc1..b410a36 100644 --- a/lib/screens/AboutScreen.dart +++ b/lib/screens/AboutScreen.dart @@ -35,8 +35,12 @@ class _AboutScreenState extends State { } @override - Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + Widget build(BuildContext context) { + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/AccountScreen.dart b/lib/screens/AccountScreen.dart index 461c1e1..4bd39bd 100644 --- a/lib/screens/AccountScreen.dart +++ b/lib/screens/AccountScreen.dart @@ -9,6 +9,7 @@ import 'package:pikapika/screens/components/NetworkSetting.dart'; import 'AppScreen.dart'; import 'DownloadListScreen.dart'; +import 'ThemeScreen.dart'; import 'components/ContentLoading.dart'; // 账户设置 @@ -48,7 +49,7 @@ class _AccountScreenState extends State { } Widget _buildLogging() { - return Scaffold( + return const Scaffold( body: ContentLoading(label: '登录中'), ); } @@ -56,11 +57,18 @@ class _AccountScreenState extends State { Widget _buildGui() { return Scaffold( appBar: AppBar( - title: Text('配置选项'), + title: const Text('配置选项'), actions: [ IconButton( onPressed: () { - // todo : chooseTheme(context); + if (androidNightModeDisplay) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const ThemeScreen()), + ); + } else { + chooseLightTheme(context); + } }, icon: const Text('主题'), ), @@ -130,7 +138,7 @@ class _AccountScreenState extends State { context, MaterialPageRoute( builder: (BuildContext context) => - RegisterScreen()), + const RegisterScreen()), ).then((value) => _loadProperties()), )), ), @@ -150,7 +158,7 @@ class _AccountScreenState extends State { await method.login(); Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) => AppScreen()), + MaterialPageRoute(builder: (context) => const AppScreen()), ); } catch (e, s) { print("$e\n$s"); diff --git a/lib/screens/CategoriesScreen.dart b/lib/screens/CategoriesScreen.dart index e9c892a..96ca3d9 100644 --- a/lib/screens/CategoriesScreen.dart +++ b/lib/screens/CategoriesScreen.dart @@ -147,7 +147,7 @@ class _CategoriesScreenState extends State { List list = []; - var append = (Widget widget, String title, Function() onTap) { + append(Widget widget, String title, Function() onTap) { list.add( GestureDetector( onTap: onTap, @@ -174,7 +174,7 @@ class _CategoriesScreenState extends State { ), ), ); - }; + } append( buildSvg('lib/assets/books.svg', imageSize, imageSize, margin: 20), @@ -217,7 +217,7 @@ class _CategoriesScreenState extends State { List list = []; - var append = (Widget widget, String title, Function() onTap) { + append(Widget widget, String title, Function() onTap) { list.add( GestureDetector( onTap: onTap, @@ -244,7 +244,7 @@ class _CategoriesScreenState extends State { ), ), ); - }; + } append( buildSvg('lib/assets/rankings.svg', imageSize, imageSize, diff --git a/lib/screens/CleanScreen.dart b/lib/screens/CleanScreen.dart index f460b04..3a1c840 100644 --- a/lib/screens/CleanScreen.dart +++ b/lib/screens/CleanScreen.dart @@ -5,6 +5,7 @@ import 'package:pikapika/basic/Channels.dart'; import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/screens/components/FitButton.dart'; import 'components/ContentLoading.dart'; +import 'components/RightClickPop.dart'; // 清理 class CleanScreen extends StatefulWidget { @@ -38,7 +39,15 @@ class _CleanScreenState extends State { } @override - Widget build(BuildContext context) { + Widget build(BuildContext context){ + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); + } + + Widget buildScreen(BuildContext context) { if (_cleaning) { return Scaffold( body: ContentLoading(label: _cleaningMessage), diff --git a/lib/screens/ComicInfoScreen.dart b/lib/screens/ComicInfoScreen.dart index ed54c2a..3d6082c 100644 --- a/lib/screens/ComicInfoScreen.dart +++ b/lib/screens/ComicInfoScreen.dart @@ -75,7 +75,11 @@ class _ComicInfoScreenState extends State with RouteAware { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/ComicReaderScreen.dart b/lib/screens/ComicReaderScreen.dart index fa99aee..dda2943 100644 --- a/lib/screens/ComicReaderScreen.dart +++ b/lib/screens/ComicReaderScreen.dart @@ -144,7 +144,11 @@ class _ComicReaderScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/ComicsScreen.dart b/lib/screens/ComicsScreen.dart index 255b5e4..123b211 100644 --- a/lib/screens/ComicsScreen.dart +++ b/lib/screens/ComicsScreen.dart @@ -113,7 +113,11 @@ class _ComicsScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/CommentScreen.dart b/lib/screens/CommentScreen.dart index 784f8e9..571b963 100644 --- a/lib/screens/CommentScreen.dart +++ b/lib/screens/CommentScreen.dart @@ -79,7 +79,11 @@ class _CommentScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/DownloadConfirmScreen.dart b/lib/screens/DownloadConfirmScreen.dart index 897cae8..411c77a 100644 --- a/lib/screens/DownloadConfirmScreen.dart +++ b/lib/screens/DownloadConfirmScreen.dart @@ -101,7 +101,11 @@ class _DownloadConfirmScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/DownloadExportToFileScreen.dart b/lib/screens/DownloadExportToFileScreen.dart index fd36919..7461cf5 100644 --- a/lib/screens/DownloadExportToFileScreen.dart +++ b/lib/screens/DownloadExportToFileScreen.dart @@ -14,6 +14,7 @@ import 'package:pikapika/screens/DownloadExportToSocketScreen.dart'; import 'components/ContentError.dart'; import 'components/ContentLoading.dart'; import 'components/DownloadInfoCard.dart'; +import 'components/RightClickPop.dart'; // 导出 class DownloadExportToFileScreen extends StatefulWidget { @@ -61,7 +62,15 @@ class _DownloadExportToFileScreenState } @override - Widget build(BuildContext context) { + Widget build(BuildContext context){ + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: !exporting, + ); + } + + Widget buildScreen(BuildContext context) { if (exporting) { return Scaffold( body: ContentLoading(label: exportMessage), diff --git a/lib/screens/DownloadExportToSocketScreen.dart b/lib/screens/DownloadExportToSocketScreen.dart index 5a02f24..f20940b 100644 --- a/lib/screens/DownloadExportToSocketScreen.dart +++ b/lib/screens/DownloadExportToSocketScreen.dart @@ -8,6 +8,7 @@ import 'package:pikapika/basic/Method.dart'; import 'components/ContentError.dart'; import 'components/ContentLoading.dart'; import 'components/DownloadInfoCard.dart'; +import 'components/RightClickPop.dart'; // 传输到其他设备 class DownloadExportToSocketScreen extends StatefulWidget { @@ -55,7 +56,15 @@ class _DownloadExportToSocketScreenState } @override - Widget build(BuildContext context) { + Widget build(BuildContext context){ + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); + } + + Widget buildScreen(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("网络导出 - " + widget.comicTitle), diff --git a/lib/screens/DownloadImportScreen.dart b/lib/screens/DownloadImportScreen.dart index effb094..4337a68 100644 --- a/lib/screens/DownloadImportScreen.dart +++ b/lib/screens/DownloadImportScreen.dart @@ -8,6 +8,7 @@ import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/basic/config/ChooserRoot.dart'; import 'components/ContentLoading.dart'; +import 'components/RightClickPop.dart'; // 导入 class DownloadImportScreen extends StatefulWidget { @@ -42,7 +43,15 @@ class _DownloadImportScreenState extends State { } @override - Widget build(BuildContext context) { + Widget build(BuildContext context){ + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: !_importing, + ); + } + + Widget buildScreen(BuildContext context) { if (_importing) { return Scaffold( body: ContentLoading(label: _importMessage), diff --git a/lib/screens/DownloadListScreen.dart b/lib/screens/DownloadListScreen.dart index 2b43c41..6438650 100644 --- a/lib/screens/DownloadListScreen.dart +++ b/lib/screens/DownloadListScreen.dart @@ -107,7 +107,11 @@ class _DownloadListScreenState extends State { }, ), ); - return RightClickPop(screen); + return rightClickPop( + child: screen, + context: context, + canPop: true, + ); } Widget downloadWidget(DownloadComic e) { @@ -147,7 +151,7 @@ class _DownloadListScreenState extends State { await Navigator.push( context, MaterialPageRoute( - builder: (context) => DownloadImportScreen(), + builder: (context) => const DownloadImportScreen(), ), ); setState(() { @@ -179,7 +183,7 @@ class _DownloadListScreenState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - title: Text('下载任务'), + title: const Text('下载任务'), content: Text( _downloadRunning ? "暂停下载吗?" : "启动下载吗?", ), @@ -188,7 +192,7 @@ class _DownloadListScreenState extends State { onPressed: () async { Navigator.pop(context); }, - child: Text('取消'), + child: const Text('取消'), ), MaterialButton( onPressed: () async { @@ -218,7 +222,7 @@ class _DownloadListScreenState extends State { ), Text( _downloadRunning ? '下载中' : '暂停中', - style: TextStyle(fontSize: 14, color: Colors.white), + style: const TextStyle(fontSize: 14, color: Colors.white), ), Expanded(child: Container()), ], @@ -238,12 +242,12 @@ class _DownloadListScreenState extends State { child: Column( children: [ Expanded(child: Container()), - Icon( + const Icon( Icons.sync_problem, size: 18, color: Colors.white, ), - Text( + const Text( '恢复', style: TextStyle(fontSize: 14, color: Colors.white), ), diff --git a/lib/screens/DownloadReaderScreen.dart b/lib/screens/DownloadReaderScreen.dart index 853dab6..122394c 100644 --- a/lib/screens/DownloadReaderScreen.dart +++ b/lib/screens/DownloadReaderScreen.dart @@ -13,6 +13,7 @@ import 'package:pikapika/basic/Method.dart'; import 'components/ContentError.dart'; import 'components/ContentLoading.dart'; import 'components/ImageReader.dart'; +import 'components/RightClickPop.dart'; // 阅读下载的内容 class DownloadReaderScreen extends StatefulWidget { @@ -133,7 +134,15 @@ class _DownloadReaderScreenState extends State { } @override - Widget build(BuildContext context) { + Widget build(BuildContext context){ + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); + } + + Widget buildScreen(BuildContext context) { return readerKeyboardHolder(_build(context)); } @@ -166,7 +175,7 @@ class _DownloadReaderScreenState extends State { : AppBar( title: Text("${_ep.title} - ${widget.comicInfo.title}"), ), - body: ContentLoading(label: '加载中'), + body: const ContentLoading(label: '加载中'), ); } var epNameMap = {}; diff --git a/lib/screens/FavouritePaperScreen.dart b/lib/screens/FavouritePaperScreen.dart index dd35d79..11f6a77 100644 --- a/lib/screens/FavouritePaperScreen.dart +++ b/lib/screens/FavouritePaperScreen.dart @@ -19,7 +19,11 @@ class _FavouritePaperScreen extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/FilePhotoViewScreen.dart b/lib/screens/FilePhotoViewScreen.dart index dd0c9bb..a06b3b8 100644 --- a/lib/screens/FilePhotoViewScreen.dart +++ b/lib/screens/FilePhotoViewScreen.dart @@ -14,7 +14,11 @@ class FilePhotoViewScreen extends StatelessWidget { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) => Scaffold( @@ -41,12 +45,12 @@ class FilePhotoViewScreen extends StatelessWidget { padding: const EdgeInsets.only(left: 4, right: 4), decoration: BoxDecoration( color: Colors.black.withOpacity(.75), - borderRadius: BorderRadius.only( + borderRadius: const BorderRadius.only( topRight: Radius.circular(8), bottomRight: Radius.circular(8), ), ), - child: Icon(Icons.keyboard_backspace, color: Colors.white), + child: const Icon(Icons.keyboard_backspace, color: Colors.white), ), ), ], diff --git a/lib/screens/GameDownloadScreen.dart b/lib/screens/GameDownloadScreen.dart index b8d04be..64afb16 100644 --- a/lib/screens/GameDownloadScreen.dart +++ b/lib/screens/GameDownloadScreen.dart @@ -23,7 +23,11 @@ class _GameDownloadScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/GameInfoScreen.dart b/lib/screens/GameInfoScreen.dart index 1c80d42..9598679 100644 --- a/lib/screens/GameInfoScreen.dart +++ b/lib/screens/GameInfoScreen.dart @@ -26,7 +26,11 @@ class _GameInfoScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/GamesScreen.dart b/lib/screens/GamesScreen.dart index a977c0d..4ccfcdb 100644 --- a/lib/screens/GamesScreen.dart +++ b/lib/screens/GamesScreen.dart @@ -33,7 +33,11 @@ class _GamesScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { @@ -146,7 +150,7 @@ class _GamesScreenState extends State { _onPageChange(page.page - 1); } }, - child: Text('上一页'), + child: const Text('上一页'), ), MaterialButton( minWidth: 0, @@ -155,7 +159,7 @@ class _GamesScreenState extends State { _onPageChange(page.page + 1); } }, - child: Text('下一页'), + child: const Text('下一页'), ) ], ), @@ -174,7 +178,7 @@ class _GamesScreenState extends State { }, child: Container( padding: const EdgeInsets.only(top: 30, bottom: 30), - child: Text('下一页'), + child: const Text('下一页'), ), ), ] @@ -235,8 +239,8 @@ class GameCard extends StatelessWidget { info.title + '\n', maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle(height: 1.4), - strutStyle: StrutStyle(height: 1.4), + style: const TextStyle(height: 1.4), + strutStyle: const StrutStyle(height: 1.4), ), Text( info.publisher, diff --git a/lib/screens/MigrateScreen.dart b/lib/screens/MigrateScreen.dart index 007c856..58b6f88 100644 --- a/lib/screens/MigrateScreen.dart +++ b/lib/screens/MigrateScreen.dart @@ -34,7 +34,11 @@ class _MigrateScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/ModifyPasswordScreen.dart b/lib/screens/ModifyPasswordScreen.dart index 99c6863..dd1a980 100644 --- a/lib/screens/ModifyPasswordScreen.dart +++ b/lib/screens/ModifyPasswordScreen.dart @@ -20,7 +20,11 @@ class _ModifyPasswordScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/NetworkSettingsScreen.dart b/lib/screens/NetworkSettingsScreen.dart index e4577b0..b2a1c08 100644 --- a/lib/screens/NetworkSettingsScreen.dart +++ b/lib/screens/NetworkSettingsScreen.dart @@ -8,7 +8,11 @@ class NetworkSettingsScreen extends StatelessWidget { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) => Scaffold( diff --git a/lib/screens/RandomComicsScreen.dart b/lib/screens/RandomComicsScreen.dart index 8e8496e..8e0f33c 100644 --- a/lib/screens/RandomComicsScreen.dart +++ b/lib/screens/RandomComicsScreen.dart @@ -26,7 +26,11 @@ class _RandomComicsScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/RankingsScreen.dart b/lib/screens/RankingsScreen.dart index 033e4c1..c1075eb 100644 --- a/lib/screens/RankingsScreen.dart +++ b/lib/screens/RankingsScreen.dart @@ -13,7 +13,11 @@ class RankingsScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/RegisterScreen.dart b/lib/screens/RegisterScreen.dart index 69871c9..d6cc636 100644 --- a/lib/screens/RegisterScreen.dart +++ b/lib/screens/RegisterScreen.dart @@ -89,7 +89,11 @@ class _RegisterScreenState extends State { @override Widget build(BuildContext context) { - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/SearchScreen.dart b/lib/screens/SearchScreen.dart index 706322a..099b51b 100644 --- a/lib/screens/SearchScreen.dart +++ b/lib/screens/SearchScreen.dart @@ -99,7 +99,11 @@ class _SearchScreenState extends State { @override Widget build(BuildContext context){ - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/SettingsScreen.dart b/lib/screens/SettingsScreen.dart index 1943d5d..5902a73 100644 --- a/lib/screens/SettingsScreen.dart +++ b/lib/screens/SettingsScreen.dart @@ -30,6 +30,7 @@ import 'package:pikapika/basic/config/shadowCategoriesMode.dart'; import 'package:pikapika/screens/components/NetworkSetting.dart'; import 'package:pikapika/screens/components/RightClickPop.dart'; +import '../basic/config/UsingRightClickPop.dart'; import 'CleanScreen.dart'; import 'MigrateScreen.dart'; import 'ModifyPasswordScreen.dart'; @@ -39,7 +40,11 @@ class SettingsScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) => Scaffold( @@ -97,6 +102,7 @@ class SettingsScreen extends StatelessWidget { downloadAndExportPathSetting(), exportRenameSetting(), fontSetting(), + usingRightClickPopSetting(), const Divider(), migrate(context), const Divider(), diff --git a/lib/screens/ThemeScreen.dart b/lib/screens/ThemeScreen.dart index 79f4224..d349339 100644 --- a/lib/screens/ThemeScreen.dart +++ b/lib/screens/ThemeScreen.dart @@ -13,7 +13,11 @@ class ThemeScreen extends StatefulWidget { class _ThemeScreenState extends State { @override Widget build(BuildContext context) { - return RightClickPop(buildScreen(context)); + return rightClickPop( + child: buildScreen(context), + context: context, + canPop: true, + ); } Widget buildScreen(BuildContext context) { diff --git a/lib/screens/ViewLogsScreen.dart b/lib/screens/ViewLogsScreen.dart index 910cf4e..a1423ec 100644 --- a/lib/screens/ViewLogsScreen.dart +++ b/lib/screens/ViewLogsScreen.dart @@ -134,7 +134,11 @@ class _ViewLogsScreenState extends State { return true; }, ); - return RightClickPop(screen); + return rightClickPop( + child: screen, + context: context, + canPop: true, + ); } void _chooseComic(String comicId) { diff --git a/lib/screens/components/ComicTagsCard.dart b/lib/screens/components/ComicTagsCard.dart index 788420a..c56305b 100644 --- a/lib/screens/components/ComicTagsCard.dart +++ b/lib/screens/components/ComicTagsCard.dart @@ -45,7 +45,7 @@ class ComicTagsCard extends StatelessWidget { style: BorderStyle.solid, color: Colors.pink.shade400, ), - borderRadius: BorderRadius.all(Radius.circular(30)), + borderRadius: const BorderRadius.all(Radius.circular(30)), ), child: Text( e, @@ -53,7 +53,7 @@ class ComicTagsCard extends StatelessWidget { color: Colors.pink.shade500, height: 1.4, ), - strutStyle: StrutStyle( + strutStyle: const StrutStyle( height: 1.4, ), ), diff --git a/lib/screens/components/CommentList.dart b/lib/screens/components/CommentList.dart index a009dba..10b56cd 100644 --- a/lib/screens/components/CommentList.dart +++ b/lib/screens/components/CommentList.dart @@ -29,7 +29,7 @@ class CommentList extends StatefulWidget { final CommentMainType mainType; final String mainId; - CommentList(this.mainType, this.mainId); + const CommentList(this.mainType, this.mainId, {Key? key}) : super(key: key); @override State createState() => _CommentListState(); @@ -130,7 +130,7 @@ class _CommentListState extends State { ), ), padding: const EdgeInsets.all(30), - child: Center( + child: const Center( child: Text('我有话要讲'), ), ), @@ -148,7 +148,7 @@ class _CommentListState extends State { }, child: Container( padding: const EdgeInsets.all(30), - child: Center( + child: const Center( child: Text('上一页'), ), ), @@ -168,7 +168,7 @@ class _CommentListState extends State { }, child: Container( padding: const EdgeInsets.all(30), - child: Center( + child: const Center( child: Text('下一页'), ), ), diff --git a/lib/screens/components/ContentBuilder.dart b/lib/screens/components/ContentBuilder.dart index daf96da..83676ce 100644 --- a/lib/screens/components/ContentBuilder.dart +++ b/lib/screens/components/ContentBuilder.dart @@ -27,7 +27,7 @@ class ContentBuilder extends StatelessWidget { ); } if (snapshot.connectionState != ConnectionState.done) { - return ContentLoading(label: '加载中'); + return const ContentLoading(label: '加载中'); } return successBuilder(context, snapshot); }, diff --git a/lib/screens/components/ImageReader.dart b/lib/screens/components/ImageReader.dart index 065d986..0d5cf4a 100644 --- a/lib/screens/components/ImageReader.dart +++ b/lib/screens/components/ImageReader.dart @@ -71,7 +71,7 @@ var _volumeListenCount = 0; // 监听后会拦截安卓手机音量键 // 仅最后一次监听生效 // event可能为DOWN/UP -EventChannel volumeButtonChannel = EventChannel("volume_button"); +EventChannel volumeButtonChannel = const EventChannel("volume_button"); StreamSubscription? volumeS; void addVolumeListen() { @@ -308,13 +308,13 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { ? Container() : Container( height: 45, - color: Color(0x88000000), + color: const Color(0x88000000), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Container(width: 15), IconButton( - icon: Icon(Icons.fullscreen), + icon: const Icon(Icons.fullscreen), color: Colors.white, onPressed: () { widget.struct @@ -330,7 +330,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { ), Container(width: 10), IconButton( - icon: Icon(Icons.skip_next_outlined), + icon: const Icon(Icons.skip_next_outlined), color: Colors.white, onPressed: _onNextAction, ), @@ -379,11 +379,11 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { actions: [ IconButton( onPressed: _onChooseEp, - icon: Icon(Icons.menu_open), + icon: const Icon(Icons.menu_open), ), IconButton( onPressed: _onMoreSetting, - icon: Icon(Icons.more_horiz), + icon: const Icon(Icons.more_horiz), ), ], ); @@ -410,14 +410,15 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { child: Container( width: 35, height: 300, - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Color(0x66000000), borderRadius: BorderRadius.only( topRight: Radius.circular(10), bottomRight: Radius.circular(10), ), ), - padding: const EdgeInsets.only(top: 10, bottom: 10, left: 6, right: 5), + padding: + const EdgeInsets.only(top: 10, bottom: 10, left: 6, right: 5), child: Center( child: _buildSliderWidget(Axis.vertical), ), @@ -434,14 +435,15 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { child: Container( width: 35, height: 300, - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Color(0x66000000), borderRadius: BorderRadius.only( topLeft: Radius.circular(10), bottomLeft: Radius.circular(10), ), ), - padding: const EdgeInsets.only(top: 10, bottom: 10, left: 5, right: 6), + padding: + const EdgeInsets.only(top: 10, bottom: 10, left: 5, right: 6), child: Center( child: _buildSliderWidget(Axis.vertical), ), @@ -474,7 +476,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { color: Theme.of(context).colorScheme.secondary, ), ), - step: FlutterSliderStep( + step: const FlutterSliderStep( step: 1, isPercentRange: false, ), @@ -489,7 +491,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { ), child: Text( '${a.toInt()}', - style: TextStyle( + style: const TextStyle( color: Colors.white, fontSize: 18, ), @@ -526,9 +528,10 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { child: Material( color: Colors.transparent, child: Container( - padding: const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), + padding: + const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), margin: const EdgeInsets.only(bottom: 10), - decoration: BoxDecoration( + decoration: const BoxDecoration( borderRadius: BorderRadius.only( topRight: Radius.circular(10), bottomRight: Radius.circular(10), @@ -652,7 +655,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { Future _onChooseEp() async { showMaterialModalBottomSheet( context: context, - backgroundColor: Color(0xAA000000), + backgroundColor: const Color(0xAA000000), builder: (context) { return SizedBox( height: MediaQuery.of(context).size.height * (.45), @@ -673,7 +676,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { // await showMaterialModalBottomSheet( context: context, - backgroundColor: Color(0xAA000000), + backgroundColor: const Color(0xAA000000), builder: (context) { return SizedBox( height: MediaQuery.of(context).size.height * (.45), @@ -885,7 +888,7 @@ class _SettingPanelState extends State<_SettingPanel> { Container(height: 3), Text( title, - style: TextStyle(color: Colors.white, fontSize: 10), + style: const TextStyle(color: Colors.white, fontSize: 10), maxLines: 1, textAlign: TextAlign.center, ), @@ -951,7 +954,7 @@ class _WebToonReaderState extends _ImageReaderContentState { _controllerTime = DateTime.now().millisecondsSinceEpoch + 400; _itemScrollController.scrollTo( index: index, // 减1 当前position 再减少1 前一个 - duration: Duration(milliseconds: 400), + duration: const Duration(milliseconds: 400), ); } } @@ -959,7 +962,7 @@ class _WebToonReaderState extends _ImageReaderContentState { @override Widget _buildViewer() { return Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.black, ), child: _buildList(), @@ -1005,11 +1008,12 @@ class _WebToonReaderState extends _ImageReaderContentState { } } var currentIndex = index; - var onTrueSize = (Size size) { + onTrueSize(Size size) { setState(() { _trueSizes[currentIndex] = size; }); - }; + } + var e = widget.struct.images[index]; if (e.downloadLocalPath != null) { _images.add(_WebToonDownloadImage( @@ -1260,7 +1264,7 @@ class _ListViewReaderState extends _ImageReaderContentState @override Widget _buildViewer() { return Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.black, ), child: _buildList(), @@ -1306,11 +1310,12 @@ class _ListViewReaderState extends _ImageReaderContentState } } var currentIndex = index; - var onTrueSize = (Size size) { + onTrueSize(Size size) { setState(() { _trueSizes[currentIndex] = size; }); - }; + } + var e = widget.struct.images[index]; if (e.downloadLocalPath != null) { _images.add(_WebToonDownloadImage( @@ -1448,7 +1453,7 @@ class _GalleryReaderState extends _ImageReaderContentState { } else { _pageController.animateToPage( index, - duration: Duration(milliseconds: 400), + duration: const Duration(milliseconds: 400), curve: Curves.ease, ); } @@ -1468,7 +1473,7 @@ class _GalleryReaderState extends _ImageReaderContentState { ? Axis.vertical : Axis.horizontal, reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT, - backgroundDecoration: BoxDecoration(color: Colors.black), + backgroundDecoration: const BoxDecoration(color: Colors.black), loadingBuilder: (context, event) => LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { return buildLoading(constraints.maxWidth, constraints.maxHeight); @@ -1515,14 +1520,15 @@ class _GalleryReaderState extends _ImageReaderContentState { child: gallery, onLongPress: () async { if (_current >= 0 && _current < widget.struct.images.length) { - Future Function() load = () async { + Future load() async { var item = widget.struct.images[_current]; if (item.downloadLocalPath != null) { return method.downloadImagePath(item.downloadLocalPath!); } var data = await method.remoteImageData(item.fileServer, item.path); return data.finalPath; - }; + } + String? choose = await chooseListDialog(context, '请选择', ['预览图片', '保存图片']); switch (choose) { @@ -1572,8 +1578,9 @@ class _GalleryReaderState extends _ImageReaderContentState { color: Colors.transparent, child: Container( margin: const EdgeInsets.only(bottom: 10), - padding: const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), - decoration: BoxDecoration( + padding: + const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), + decoration: const BoxDecoration( borderRadius: BorderRadius.only( topLeft: Radius.circular(10), bottomLeft: Radius.circular(10), @@ -1589,7 +1596,7 @@ class _GalleryReaderState extends _ImageReaderContentState { } }, child: Text(_hasNextEp() ? '下一章' : '结束阅读', - style: TextStyle(color: Colors.white)), + style: const TextStyle(color: Colors.white)), ), ), ), diff --git a/lib/screens/components/Images.dart b/lib/screens/components/Images.dart index 4971753..c18c0a0 100644 --- a/lib/screens/components/Images.dart +++ b/lib/screens/components/Images.dart @@ -308,7 +308,7 @@ Widget buildMock(double? width, double? height) { Widget buildError(double? width, double? height) { return Image( - image: AssetImage('lib/assets/error.png'), + image: const AssetImage('lib/assets/error.png'), width: width, height: height, ); diff --git a/lib/screens/components/RightClickPop.dart b/lib/screens/components/RightClickPop.dart index 7b65468..88a3a64 100644 --- a/lib/screens/components/RightClickPop.dart +++ b/lib/screens/components/RightClickPop.dart @@ -1,15 +1,19 @@ import 'package:flutter/material.dart'; -class RightClickPop extends StatelessWidget { - final Widget child; +import '../../basic/config/UsingRightClickPop.dart'; - const RightClickPop(this.child, {Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return GestureDetector( - onSecondaryTap: () => Navigator.of(context).pop(), - child: child, - ); - } -} +Widget rightClickPop({ + required Widget child, + required BuildContext context, + bool canPop = true, +}) => + currentUsingRightClickPop() + ? GestureDetector( + onSecondaryTap: () { + if (canPop) { + Navigator.of(context).pop(); + } + }, + child: child, + ) + : child;