setting right click pop

This commit is contained in:
niuhuan 2022-03-25 22:57:30 +08:00
parent e1e4dfffeb
commit 9dc7ce03f2
40 changed files with 312 additions and 110 deletions

View File

@ -145,7 +145,7 @@ Future<T?> chooseMapDialog<T>(
/// 1 /// 1
var _controller = TextEditingController.fromValue(TextEditingValue(text: '')); var _controller = TextEditingController.fromValue(const TextEditingValue(text: ''));
Future<String?> displayTextInputDialog(BuildContext context, Future<String?> displayTextInputDialog(BuildContext context,
{String? title, {String? title,
@ -190,7 +190,7 @@ Future<String?> displayTextInputDialog(BuildContext context,
), ),
actions: <Widget>[ actions: <Widget>[
MaterialButton( MaterialButton(
child: Text('取消'), child: const Text('取消'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },

View File

@ -51,5 +51,5 @@ IconButton chooseLayoutActionButton(BuildContext context) => IconButton(
onPressed: () { onPressed: () {
_chooseListLayout(context); _chooseListLayout(context);
}, },
icon: Icon(Icons.view_quilt), icon: const Icon(Icons.view_quilt),
); );

View File

@ -61,7 +61,7 @@ Widget shadowCategoriesActionButton(BuildContext context) {
onPressed: () { onPressed: () {
_chooseShadowCategories(context); _chooseShadowCategories(context);
}, },
icon: Icon(Icons.hide_source), icon: const Icon(Icons.hide_source),
); );
} }

View File

@ -99,7 +99,7 @@ class _PinkTheme extends _ThemePackage {
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
systemOverlayStyle: SystemUiOverlayStyle.light, systemOverlayStyle: SystemUiOverlayStyle.light,
color: Colors.pink.shade200, color: Colors.pink.shade200,
iconTheme: IconThemeData( iconTheme: const IconThemeData(
color: Colors.white, color: Colors.white,
), ),
), ),
@ -141,7 +141,7 @@ class _BlackTheme extends _ThemePackage {
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
systemOverlayStyle: SystemUiOverlayStyle.light, systemOverlayStyle: SystemUiOverlayStyle.light,
color: Colors.grey.shade800, color: Colors.grey.shade800,
iconTheme: IconThemeData( iconTheme: const IconThemeData(
color: Colors.white, color: Colors.white,
), ),
), ),
@ -238,11 +238,11 @@ class _DustyBlueTheme extends _ThemePackage {
color: Colors.white, color: Colors.white,
), ),
), ),
dialogTheme: DialogTheme( dialogTheme: const DialogTheme(
backgroundColor: Color(0xff20253b), backgroundColor: Color(0xff20253b),
), ),
bottomNavigationBarTheme: BottomNavigationBarThemeData( bottomNavigationBarTheme: BottomNavigationBarThemeData(
backgroundColor: Color(0xff191b26), backgroundColor: const Color(0xff191b26),
selectedItemColor: Colors.blue.shade200, selectedItemColor: Colors.blue.shade200,
unselectedItemColor: Colors.grey.shade500, unselectedItemColor: Colors.grey.shade500,
), ),

View File

@ -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<void> initUsingRightClickPop() async {
_usingRightClickPop =
(await method.loadProperty(_propertyName, "false")) == "true";
}
bool currentUsingRightClickPop() {
return _usingRightClickPop;
}
Future<void> _chooseUsingRightClickPop(BuildContext context) async {
String? result =
await chooseListDialog<String>(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(() {});
},
);
},
);
}

View File

@ -35,8 +35,12 @@ class _AboutScreenState extends State<AboutScreen> {
} }
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context) {
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -9,6 +9,7 @@ import 'package:pikapika/screens/components/NetworkSetting.dart';
import 'AppScreen.dart'; import 'AppScreen.dart';
import 'DownloadListScreen.dart'; import 'DownloadListScreen.dart';
import 'ThemeScreen.dart';
import 'components/ContentLoading.dart'; import 'components/ContentLoading.dart';
// //
@ -48,7 +49,7 @@ class _AccountScreenState extends State<AccountScreen> {
} }
Widget _buildLogging() { Widget _buildLogging() {
return Scaffold( return const Scaffold(
body: ContentLoading(label: '登录中'), body: ContentLoading(label: '登录中'),
); );
} }
@ -56,11 +57,18 @@ class _AccountScreenState extends State<AccountScreen> {
Widget _buildGui() { Widget _buildGui() {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('配置选项'), title: const Text('配置选项'),
actions: [ actions: [
IconButton( IconButton(
onPressed: () { onPressed: () {
// todo : chooseTheme(context); if (androidNightModeDisplay) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const ThemeScreen()),
);
} else {
chooseLightTheme(context);
}
}, },
icon: const Text('主题'), icon: const Text('主题'),
), ),
@ -130,7 +138,7 @@ class _AccountScreenState extends State<AccountScreen> {
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => builder: (BuildContext context) =>
RegisterScreen()), const RegisterScreen()),
).then((value) => _loadProperties()), ).then((value) => _loadProperties()),
)), )),
), ),
@ -150,7 +158,7 @@ class _AccountScreenState extends State<AccountScreen> {
await method.login(); await method.login();
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
MaterialPageRoute(builder: (context) => AppScreen()), MaterialPageRoute(builder: (context) => const AppScreen()),
); );
} catch (e, s) { } catch (e, s) {
print("$e\n$s"); print("$e\n$s");

View File

@ -147,7 +147,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
List<Widget> list = []; List<Widget> list = [];
var append = (Widget widget, String title, Function() onTap) { append(Widget widget, String title, Function() onTap) {
list.add( list.add(
GestureDetector( GestureDetector(
onTap: onTap, onTap: onTap,
@ -174,7 +174,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
), ),
), ),
); );
}; }
append( append(
buildSvg('lib/assets/books.svg', imageSize, imageSize, margin: 20), buildSvg('lib/assets/books.svg', imageSize, imageSize, margin: 20),
@ -217,7 +217,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
List<Widget> list = []; List<Widget> list = [];
var append = (Widget widget, String title, Function() onTap) { append(Widget widget, String title, Function() onTap) {
list.add( list.add(
GestureDetector( GestureDetector(
onTap: onTap, onTap: onTap,
@ -244,7 +244,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
), ),
), ),
); );
}; }
append( append(
buildSvg('lib/assets/rankings.svg', imageSize, imageSize, buildSvg('lib/assets/rankings.svg', imageSize, imageSize,

View File

@ -5,6 +5,7 @@ import 'package:pikapika/basic/Channels.dart';
import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/basic/Method.dart';
import 'package:pikapika/screens/components/FitButton.dart'; import 'package:pikapika/screens/components/FitButton.dart';
import 'components/ContentLoading.dart'; import 'components/ContentLoading.dart';
import 'components/RightClickPop.dart';
// //
class CleanScreen extends StatefulWidget { class CleanScreen extends StatefulWidget {
@ -38,7 +39,15 @@ class _CleanScreenState extends State<CleanScreen> {
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context){
return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
}
Widget buildScreen(BuildContext context) {
if (_cleaning) { if (_cleaning) {
return Scaffold( return Scaffold(
body: ContentLoading(label: _cleaningMessage), body: ContentLoading(label: _cleaningMessage),

View File

@ -75,7 +75,11 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -144,7 +144,11 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -113,7 +113,11 @@ class _ComicsScreenState extends State<ComicsScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -79,7 +79,11 @@ class _CommentScreenState extends State<CommentScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -101,7 +101,11 @@ class _DownloadConfirmScreenState extends State<DownloadConfirmScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -14,6 +14,7 @@ import 'package:pikapika/screens/DownloadExportToSocketScreen.dart';
import 'components/ContentError.dart'; import 'components/ContentError.dart';
import 'components/ContentLoading.dart'; import 'components/ContentLoading.dart';
import 'components/DownloadInfoCard.dart'; import 'components/DownloadInfoCard.dart';
import 'components/RightClickPop.dart';
// //
class DownloadExportToFileScreen extends StatefulWidget { class DownloadExportToFileScreen extends StatefulWidget {
@ -61,7 +62,15 @@ class _DownloadExportToFileScreenState
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context){
return rightClickPop(
child: buildScreen(context),
context: context,
canPop: !exporting,
);
}
Widget buildScreen(BuildContext context) {
if (exporting) { if (exporting) {
return Scaffold( return Scaffold(
body: ContentLoading(label: exportMessage), body: ContentLoading(label: exportMessage),

View File

@ -8,6 +8,7 @@ import 'package:pikapika/basic/Method.dart';
import 'components/ContentError.dart'; import 'components/ContentError.dart';
import 'components/ContentLoading.dart'; import 'components/ContentLoading.dart';
import 'components/DownloadInfoCard.dart'; import 'components/DownloadInfoCard.dart';
import 'components/RightClickPop.dart';
// //
class DownloadExportToSocketScreen extends StatefulWidget { class DownloadExportToSocketScreen extends StatefulWidget {
@ -55,7 +56,15 @@ class _DownloadExportToSocketScreenState
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context){
return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
}
Widget buildScreen(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("网络导出 - " + widget.comicTitle), title: Text("网络导出 - " + widget.comicTitle),

View File

@ -8,6 +8,7 @@ import 'package:pikapika/basic/Method.dart';
import 'package:pikapika/basic/config/ChooserRoot.dart'; import 'package:pikapika/basic/config/ChooserRoot.dart';
import 'components/ContentLoading.dart'; import 'components/ContentLoading.dart';
import 'components/RightClickPop.dart';
// //
class DownloadImportScreen extends StatefulWidget { class DownloadImportScreen extends StatefulWidget {
@ -42,7 +43,15 @@ class _DownloadImportScreenState extends State<DownloadImportScreen> {
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context){
return rightClickPop(
child: buildScreen(context),
context: context,
canPop: !_importing,
);
}
Widget buildScreen(BuildContext context) {
if (_importing) { if (_importing) {
return Scaffold( return Scaffold(
body: ContentLoading(label: _importMessage), body: ContentLoading(label: _importMessage),

View File

@ -107,7 +107,11 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
}, },
), ),
); );
return RightClickPop(screen); return rightClickPop(
child: screen,
context: context,
canPop: true,
);
} }
Widget downloadWidget(DownloadComic e) { Widget downloadWidget(DownloadComic e) {
@ -147,7 +151,7 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => DownloadImportScreen(), builder: (context) => const DownloadImportScreen(),
), ),
); );
setState(() { setState(() {
@ -179,7 +183,7 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: Text('下载任务'), title: const Text('下载任务'),
content: Text( content: Text(
_downloadRunning ? "暂停下载吗?" : "启动下载吗?", _downloadRunning ? "暂停下载吗?" : "启动下载吗?",
), ),
@ -188,7 +192,7 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
onPressed: () async { onPressed: () async {
Navigator.pop(context); Navigator.pop(context);
}, },
child: Text('取消'), child: const Text('取消'),
), ),
MaterialButton( MaterialButton(
onPressed: () async { onPressed: () async {
@ -218,7 +222,7 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
), ),
Text( Text(
_downloadRunning ? '下载中' : '暂停中', _downloadRunning ? '下载中' : '暂停中',
style: TextStyle(fontSize: 14, color: Colors.white), style: const TextStyle(fontSize: 14, color: Colors.white),
), ),
Expanded(child: Container()), Expanded(child: Container()),
], ],
@ -238,12 +242,12 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
child: Column( child: Column(
children: [ children: [
Expanded(child: Container()), Expanded(child: Container()),
Icon( const Icon(
Icons.sync_problem, Icons.sync_problem,
size: 18, size: 18,
color: Colors.white, color: Colors.white,
), ),
Text( const Text(
'恢复', '恢复',
style: TextStyle(fontSize: 14, color: Colors.white), style: TextStyle(fontSize: 14, color: Colors.white),
), ),

View File

@ -13,6 +13,7 @@ import 'package:pikapika/basic/Method.dart';
import 'components/ContentError.dart'; import 'components/ContentError.dart';
import 'components/ContentLoading.dart'; import 'components/ContentLoading.dart';
import 'components/ImageReader.dart'; import 'components/ImageReader.dart';
import 'components/RightClickPop.dart';
// //
class DownloadReaderScreen extends StatefulWidget { class DownloadReaderScreen extends StatefulWidget {
@ -133,7 +134,15 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
} }
@override @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)); return readerKeyboardHolder(_build(context));
} }
@ -166,7 +175,7 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
: AppBar( : AppBar(
title: Text("${_ep.title} - ${widget.comicInfo.title}"), title: Text("${_ep.title} - ${widget.comicInfo.title}"),
), ),
body: ContentLoading(label: '加载中'), body: const ContentLoading(label: '加载中'),
); );
} }
var epNameMap = <int, String>{}; var epNameMap = <int, String>{};

View File

@ -19,7 +19,11 @@ class _FavouritePaperScreen extends State<FavouritePaperScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -14,7 +14,11 @@ class FilePhotoViewScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) => Scaffold( Widget buildScreen(BuildContext context) => Scaffold(
@ -41,12 +45,12 @@ class FilePhotoViewScreen extends StatelessWidget {
padding: const EdgeInsets.only(left: 4, right: 4), padding: const EdgeInsets.only(left: 4, right: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(.75), color: Colors.black.withOpacity(.75),
borderRadius: BorderRadius.only( borderRadius: const BorderRadius.only(
topRight: Radius.circular(8), topRight: Radius.circular(8),
bottomRight: Radius.circular(8), bottomRight: Radius.circular(8),
), ),
), ),
child: Icon(Icons.keyboard_backspace, color: Colors.white), child: const Icon(Icons.keyboard_backspace, color: Colors.white),
), ),
), ),
], ],

View File

@ -23,7 +23,11 @@ class _GameDownloadScreenState extends State<GameDownloadScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -26,7 +26,11 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -33,7 +33,11 @@ class _GamesScreenState extends State<GamesScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {
@ -146,7 +150,7 @@ class _GamesScreenState extends State<GamesScreen> {
_onPageChange(page.page - 1); _onPageChange(page.page - 1);
} }
}, },
child: Text('上一页'), child: const Text('上一页'),
), ),
MaterialButton( MaterialButton(
minWidth: 0, minWidth: 0,
@ -155,7 +159,7 @@ class _GamesScreenState extends State<GamesScreen> {
_onPageChange(page.page + 1); _onPageChange(page.page + 1);
} }
}, },
child: Text('下一页'), child: const Text('下一页'),
) )
], ],
), ),
@ -174,7 +178,7 @@ class _GamesScreenState extends State<GamesScreen> {
}, },
child: Container( child: Container(
padding: const EdgeInsets.only(top: 30, bottom: 30), padding: const EdgeInsets.only(top: 30, bottom: 30),
child: Text('下一页'), child: const Text('下一页'),
), ),
), ),
] ]
@ -235,8 +239,8 @@ class GameCard extends StatelessWidget {
info.title + '\n', info.title + '\n',
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(height: 1.4), style: const TextStyle(height: 1.4),
strutStyle: StrutStyle(height: 1.4), strutStyle: const StrutStyle(height: 1.4),
), ),
Text( Text(
info.publisher, info.publisher,

View File

@ -34,7 +34,11 @@ class _MigrateScreenState extends State<MigrateScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -20,7 +20,11 @@ class _ModifyPasswordScreenState extends State<ModifyPasswordScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -8,7 +8,11 @@ class NetworkSettingsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) => Scaffold( Widget buildScreen(BuildContext context) => Scaffold(

View File

@ -26,7 +26,11 @@ class _RandomComicsScreenState extends State<RandomComicsScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -13,7 +13,11 @@ class RankingsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -89,7 +89,11 @@ class _RegisterScreenState extends State<RegisterScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -99,7 +99,11 @@ class _SearchScreenState extends State<SearchScreen> {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -30,6 +30,7 @@ import 'package:pikapika/basic/config/shadowCategoriesMode.dart';
import 'package:pikapika/screens/components/NetworkSetting.dart'; import 'package:pikapika/screens/components/NetworkSetting.dart';
import 'package:pikapika/screens/components/RightClickPop.dart'; import 'package:pikapika/screens/components/RightClickPop.dart';
import '../basic/config/UsingRightClickPop.dart';
import 'CleanScreen.dart'; import 'CleanScreen.dart';
import 'MigrateScreen.dart'; import 'MigrateScreen.dart';
import 'ModifyPasswordScreen.dart'; import 'ModifyPasswordScreen.dart';
@ -39,7 +40,11 @@ class SettingsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) => Scaffold( Widget buildScreen(BuildContext context) => Scaffold(
@ -97,6 +102,7 @@ class SettingsScreen extends StatelessWidget {
downloadAndExportPathSetting(), downloadAndExportPathSetting(),
exportRenameSetting(), exportRenameSetting(),
fontSetting(), fontSetting(),
usingRightClickPopSetting(),
const Divider(), const Divider(),
migrate(context), migrate(context),
const Divider(), const Divider(),

View File

@ -13,7 +13,11 @@ class ThemeScreen extends StatefulWidget {
class _ThemeScreenState extends State<ThemeScreen> { class _ThemeScreenState extends State<ThemeScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RightClickPop(buildScreen(context)); return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
} }
Widget buildScreen(BuildContext context) { Widget buildScreen(BuildContext context) {

View File

@ -134,7 +134,11 @@ class _ViewLogsScreenState extends State<ViewLogsScreen> {
return true; return true;
}, },
); );
return RightClickPop(screen); return rightClickPop(
child: screen,
context: context,
canPop: true,
);
} }
void _chooseComic(String comicId) { void _chooseComic(String comicId) {

View File

@ -45,7 +45,7 @@ class ComicTagsCard extends StatelessWidget {
style: BorderStyle.solid, style: BorderStyle.solid,
color: Colors.pink.shade400, color: Colors.pink.shade400,
), ),
borderRadius: BorderRadius.all(Radius.circular(30)), borderRadius: const BorderRadius.all(Radius.circular(30)),
), ),
child: Text( child: Text(
e, e,
@ -53,7 +53,7 @@ class ComicTagsCard extends StatelessWidget {
color: Colors.pink.shade500, color: Colors.pink.shade500,
height: 1.4, height: 1.4,
), ),
strutStyle: StrutStyle( strutStyle: const StrutStyle(
height: 1.4, height: 1.4,
), ),
), ),

View File

@ -29,7 +29,7 @@ class CommentList extends StatefulWidget {
final CommentMainType mainType; final CommentMainType mainType;
final String mainId; final String mainId;
CommentList(this.mainType, this.mainId); const CommentList(this.mainType, this.mainId, {Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _CommentListState(); State<StatefulWidget> createState() => _CommentListState();
@ -130,7 +130,7 @@ class _CommentListState extends State<CommentList> {
), ),
), ),
padding: const EdgeInsets.all(30), padding: const EdgeInsets.all(30),
child: Center( child: const Center(
child: Text('我有话要讲'), child: Text('我有话要讲'),
), ),
), ),
@ -148,7 +148,7 @@ class _CommentListState extends State<CommentList> {
}, },
child: Container( child: Container(
padding: const EdgeInsets.all(30), padding: const EdgeInsets.all(30),
child: Center( child: const Center(
child: Text('上一页'), child: Text('上一页'),
), ),
), ),
@ -168,7 +168,7 @@ class _CommentListState extends State<CommentList> {
}, },
child: Container( child: Container(
padding: const EdgeInsets.all(30), padding: const EdgeInsets.all(30),
child: Center( child: const Center(
child: Text('下一页'), child: Text('下一页'),
), ),
), ),

View File

@ -27,7 +27,7 @@ class ContentBuilder<T> extends StatelessWidget {
); );
} }
if (snapshot.connectionState != ConnectionState.done) { if (snapshot.connectionState != ConnectionState.done) {
return ContentLoading(label: '加载中'); return const ContentLoading(label: '加载中');
} }
return successBuilder(context, snapshot); return successBuilder(context, snapshot);
}, },

View File

@ -71,7 +71,7 @@ var _volumeListenCount = 0;
// //
// //
// event可能为DOWN/UP // event可能为DOWN/UP
EventChannel volumeButtonChannel = EventChannel("volume_button"); EventChannel volumeButtonChannel = const EventChannel("volume_button");
StreamSubscription? volumeS; StreamSubscription? volumeS;
void addVolumeListen() { void addVolumeListen() {
@ -308,13 +308,13 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
? Container() ? Container()
: Container( : Container(
height: 45, height: 45,
color: Color(0x88000000), color: const Color(0x88000000),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container(width: 15), Container(width: 15),
IconButton( IconButton(
icon: Icon(Icons.fullscreen), icon: const Icon(Icons.fullscreen),
color: Colors.white, color: Colors.white,
onPressed: () { onPressed: () {
widget.struct widget.struct
@ -330,7 +330,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
), ),
Container(width: 10), Container(width: 10),
IconButton( IconButton(
icon: Icon(Icons.skip_next_outlined), icon: const Icon(Icons.skip_next_outlined),
color: Colors.white, color: Colors.white,
onPressed: _onNextAction, onPressed: _onNextAction,
), ),
@ -379,11 +379,11 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
actions: [ actions: [
IconButton( IconButton(
onPressed: _onChooseEp, onPressed: _onChooseEp,
icon: Icon(Icons.menu_open), icon: const Icon(Icons.menu_open),
), ),
IconButton( IconButton(
onPressed: _onMoreSetting, 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( child: Container(
width: 35, width: 35,
height: 300, height: 300,
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Color(0x66000000), color: Color(0x66000000),
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topRight: Radius.circular(10), topRight: Radius.circular(10),
bottomRight: 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: Center(
child: _buildSliderWidget(Axis.vertical), child: _buildSliderWidget(Axis.vertical),
), ),
@ -434,14 +435,15 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
child: Container( child: Container(
width: 35, width: 35,
height: 300, height: 300,
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Color(0x66000000), color: Color(0x66000000),
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(10), topLeft: Radius.circular(10),
bottomLeft: 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: Center(
child: _buildSliderWidget(Axis.vertical), child: _buildSliderWidget(Axis.vertical),
), ),
@ -474,7 +476,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
color: Theme.of(context).colorScheme.secondary, color: Theme.of(context).colorScheme.secondary,
), ),
), ),
step: FlutterSliderStep( step: const FlutterSliderStep(
step: 1, step: 1,
isPercentRange: false, isPercentRange: false,
), ),
@ -489,7 +491,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
), ),
child: Text( child: Text(
'${a.toInt()}', '${a.toInt()}',
style: TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 18, fontSize: 18,
), ),
@ -526,9 +528,10 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,
child: Container( 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), margin: const EdgeInsets.only(bottom: 10),
decoration: BoxDecoration( decoration: const BoxDecoration(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topRight: Radius.circular(10), topRight: Radius.circular(10),
bottomRight: Radius.circular(10), bottomRight: Radius.circular(10),
@ -652,7 +655,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
Future _onChooseEp() async { Future _onChooseEp() async {
showMaterialModalBottomSheet( showMaterialModalBottomSheet(
context: context, context: context,
backgroundColor: Color(0xAA000000), backgroundColor: const Color(0xAA000000),
builder: (context) { builder: (context) {
return SizedBox( return SizedBox(
height: MediaQuery.of(context).size.height * (.45), height: MediaQuery.of(context).size.height * (.45),
@ -673,7 +676,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
// //
await showMaterialModalBottomSheet( await showMaterialModalBottomSheet(
context: context, context: context,
backgroundColor: Color(0xAA000000), backgroundColor: const Color(0xAA000000),
builder: (context) { builder: (context) {
return SizedBox( return SizedBox(
height: MediaQuery.of(context).size.height * (.45), height: MediaQuery.of(context).size.height * (.45),
@ -885,7 +888,7 @@ class _SettingPanelState extends State<_SettingPanel> {
Container(height: 3), Container(height: 3),
Text( Text(
title, title,
style: TextStyle(color: Colors.white, fontSize: 10), style: const TextStyle(color: Colors.white, fontSize: 10),
maxLines: 1, maxLines: 1,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
@ -951,7 +954,7 @@ class _WebToonReaderState extends _ImageReaderContentState {
_controllerTime = DateTime.now().millisecondsSinceEpoch + 400; _controllerTime = DateTime.now().millisecondsSinceEpoch + 400;
_itemScrollController.scrollTo( _itemScrollController.scrollTo(
index: index, // 1 position 1 index: index, // 1 position 1
duration: Duration(milliseconds: 400), duration: const Duration(milliseconds: 400),
); );
} }
} }
@ -959,7 +962,7 @@ class _WebToonReaderState extends _ImageReaderContentState {
@override @override
Widget _buildViewer() { Widget _buildViewer() {
return Container( return Container(
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Colors.black, color: Colors.black,
), ),
child: _buildList(), child: _buildList(),
@ -1005,11 +1008,12 @@ class _WebToonReaderState extends _ImageReaderContentState {
} }
} }
var currentIndex = index; var currentIndex = index;
var onTrueSize = (Size size) { onTrueSize(Size size) {
setState(() { setState(() {
_trueSizes[currentIndex] = size; _trueSizes[currentIndex] = size;
}); });
}; }
var e = widget.struct.images[index]; var e = widget.struct.images[index];
if (e.downloadLocalPath != null) { if (e.downloadLocalPath != null) {
_images.add(_WebToonDownloadImage( _images.add(_WebToonDownloadImage(
@ -1260,7 +1264,7 @@ class _ListViewReaderState extends _ImageReaderContentState
@override @override
Widget _buildViewer() { Widget _buildViewer() {
return Container( return Container(
decoration: BoxDecoration( decoration: const BoxDecoration(
color: Colors.black, color: Colors.black,
), ),
child: _buildList(), child: _buildList(),
@ -1306,11 +1310,12 @@ class _ListViewReaderState extends _ImageReaderContentState
} }
} }
var currentIndex = index; var currentIndex = index;
var onTrueSize = (Size size) { onTrueSize(Size size) {
setState(() { setState(() {
_trueSizes[currentIndex] = size; _trueSizes[currentIndex] = size;
}); });
}; }
var e = widget.struct.images[index]; var e = widget.struct.images[index];
if (e.downloadLocalPath != null) { if (e.downloadLocalPath != null) {
_images.add(_WebToonDownloadImage( _images.add(_WebToonDownloadImage(
@ -1448,7 +1453,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
} else { } else {
_pageController.animateToPage( _pageController.animateToPage(
index, index,
duration: Duration(milliseconds: 400), duration: const Duration(milliseconds: 400),
curve: Curves.ease, curve: Curves.ease,
); );
} }
@ -1468,7 +1473,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
? Axis.vertical ? Axis.vertical
: Axis.horizontal, : Axis.horizontal,
reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT, reverse: widget.pagerDirection == ReaderDirection.RIGHT_TO_LEFT,
backgroundDecoration: BoxDecoration(color: Colors.black), backgroundDecoration: const BoxDecoration(color: Colors.black),
loadingBuilder: (context, event) => LayoutBuilder( loadingBuilder: (context, event) => LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
return buildLoading(constraints.maxWidth, constraints.maxHeight); return buildLoading(constraints.maxWidth, constraints.maxHeight);
@ -1515,14 +1520,15 @@ class _GalleryReaderState extends _ImageReaderContentState {
child: gallery, child: gallery,
onLongPress: () async { onLongPress: () async {
if (_current >= 0 && _current < widget.struct.images.length) { if (_current >= 0 && _current < widget.struct.images.length) {
Future<String> Function() load = () async { Future<String> load() async {
var item = widget.struct.images[_current]; var item = widget.struct.images[_current];
if (item.downloadLocalPath != null) { if (item.downloadLocalPath != null) {
return method.downloadImagePath(item.downloadLocalPath!); return method.downloadImagePath(item.downloadLocalPath!);
} }
var data = await method.remoteImageData(item.fileServer, item.path); var data = await method.remoteImageData(item.fileServer, item.path);
return data.finalPath; return data.finalPath;
}; }
String? choose = String? choose =
await chooseListDialog(context, '请选择', ['预览图片', '保存图片']); await chooseListDialog(context, '请选择', ['预览图片', '保存图片']);
switch (choose) { switch (choose) {
@ -1572,8 +1578,9 @@ class _GalleryReaderState extends _ImageReaderContentState {
color: Colors.transparent, color: Colors.transparent,
child: Container( child: Container(
margin: const EdgeInsets.only(bottom: 10), margin: const EdgeInsets.only(bottom: 10),
padding: const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), padding:
decoration: BoxDecoration( const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(10), topLeft: Radius.circular(10),
bottomLeft: Radius.circular(10), bottomLeft: Radius.circular(10),
@ -1589,7 +1596,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
} }
}, },
child: Text(_hasNextEp() ? '下一章' : '结束阅读', child: Text(_hasNextEp() ? '下一章' : '结束阅读',
style: TextStyle(color: Colors.white)), style: const TextStyle(color: Colors.white)),
), ),
), ),
), ),

View File

@ -308,7 +308,7 @@ Widget buildMock(double? width, double? height) {
Widget buildError(double? width, double? height) { Widget buildError(double? width, double? height) {
return Image( return Image(
image: AssetImage('lib/assets/error.png'), image: const AssetImage('lib/assets/error.png'),
width: width, width: width,
height: height, height: height,
); );

View File

@ -1,15 +1,19 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class RightClickPop extends StatelessWidget { import '../../basic/config/UsingRightClickPop.dart';
final Widget child;
const RightClickPop(this.child, {Key? key}) : super(key: key); Widget rightClickPop({
required Widget child,
@override required BuildContext context,
Widget build(BuildContext context) { bool canPop = true,
return GestureDetector( }) =>
onSecondaryTap: () => Navigator.of(context).pop(), currentUsingRightClickPop()
child: child, ? GestureDetector(
); onSecondaryTap: () {
if (canPop) {
Navigator.of(context).pop();
} }
} },
child: child,
)
: child;