From ccae23ed752fc2109eaa4681ae19de4ea0fe0230 Mon Sep 17 00:00:00 2001 From: niuhuan Date: Fri, 7 Apr 2023 09:56:11 +0800 Subject: [PATCH] :recycle: (Gui) Modify menu and icons --- lib/basic/config/Address.dart | 47 +++++++++++++-- lib/screens/CategoriesScreen.dart | 4 +- lib/screens/ComicsScreen.dart | 8 +-- lib/screens/RandomComicsScreen.dart | 4 +- lib/screens/RankingsScreen.dart | 4 +- lib/screens/SearchScreen.dart | 4 +- lib/screens/components/Common.dart | 2 +- lib/screens/components/ImageReader.dart | 76 ++++++++++++++----------- 8 files changed, 96 insertions(+), 53 deletions(-) diff --git a/lib/basic/config/Address.dart b/lib/basic/config/Address.dart index 4f8236b..0aea081 100644 --- a/lib/basic/config/Address.dart +++ b/lib/basic/config/Address.dart @@ -6,6 +6,8 @@ import 'package:flutter/material.dart'; import 'package:pikapika/basic/Common.dart'; +import 'package:pikapika/basic/config/ImageAddress.dart'; +import 'package:pikapika/basic/config/UseApiLoadImage.dart'; import '../Method.dart'; @@ -89,7 +91,7 @@ Future chooseAddressAndSwitch(BuildContext context) async { title: const Text('选择分流'), children: [ ..._addresses.entries.map( - (e) => SimpleDialogOption( + (e) => SimpleDialogOption( child: ApiOptionRow( e.value, e.key, @@ -126,12 +128,45 @@ Future chooseAddressAndSwitch(BuildContext context) async { } } -Widget addressActionButton(BuildContext context) { - return IconButton( - onPressed: () { - chooseAddressAndSwitch(context); +Widget addressPopMenu(BuildContext context) { + return PopupMenuButton( + icon: const Icon(Icons.webhook), + itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + value: 0, + child: ListTile( + leading: const Icon(Icons.share), + title: Text("分流 (${currentAddressName()})"), + ), + ), + PopupMenuItem( + value: 1, + child: ListTile( + leading: const Icon(Icons.image_search), + title: Text("图片分流 (${currentImageAddressName()})"), + ), + ), + PopupMenuItem( + value: 2, + child: ListTile( + leading: const Icon(Icons.network_ping), + title: Text("用API加载图片 (${currentUseApiLoadImageName()})"), + ), + ), + ], + onSelected: (int value) { + switch (value) { + case 0: + chooseAddressAndSwitch(context); + break; + case 1: + chooseImageAddress(context); + break; + case 2: + chooseUseApiLoadImage(context); + break; + } }, - icon: const Icon(Icons.network_ping), ); } diff --git a/lib/screens/CategoriesScreen.dart b/lib/screens/CategoriesScreen.dart index 27de4e6..b3ffdab 100644 --- a/lib/screens/CategoriesScreen.dart +++ b/lib/screens/CategoriesScreen.dart @@ -48,8 +48,8 @@ class _CategoriesScreenState extends State { return AppBar( title: const Text('分类'), actions: [ - aPopMenu(context), - addressActionButton(context), + commonPopMenu(context), + addressPopMenu(context), _searchBar.getSearchAction(context), ], ); diff --git a/lib/screens/ComicsScreen.dart b/lib/screens/ComicsScreen.dart index 1c38e6f..c452616 100644 --- a/lib/screens/ComicsScreen.dart +++ b/lib/screens/ComicsScreen.dart @@ -55,8 +55,8 @@ class _ComicsScreenState extends State { return AppBar( title: Text(categoryTitle(widget.category)), actions: [ - aPopMenu(context), - addressActionButton(context), + commonPopMenu(context), + addressPopMenu(context), _chooseCategoryAction(), _categorySearchBar.getSearchAction(context), ], @@ -147,8 +147,8 @@ class _ComicsScreenState extends State { appBar = AppBar( title: Text(title), actions: [ - aPopMenu(context), - addressActionButton(context), + commonPopMenu(context), + addressPopMenu(context), _chooseCategoryAction(), ], ); diff --git a/lib/screens/RandomComicsScreen.dart b/lib/screens/RandomComicsScreen.dart index 002e7e8..e725126 100644 --- a/lib/screens/RandomComicsScreen.dart +++ b/lib/screens/RandomComicsScreen.dart @@ -33,8 +33,8 @@ class _RandomComicsScreenState extends State { appBar: AppBar( title: const Text('随机本子'), actions: [ - aPopMenu(context), - addressActionButton(context), + commonPopMenu(context), + addressPopMenu(context), ], ), body: ComicListBuilder(method.randomComics), diff --git a/lib/screens/RankingsScreen.dart b/lib/screens/RankingsScreen.dart index 3a3524c..87e53cb 100644 --- a/lib/screens/RankingsScreen.dart +++ b/lib/screens/RankingsScreen.dart @@ -34,8 +34,8 @@ class RankingsScreen extends StatelessWidget { appBar: AppBar( title: const Text('排行榜'), actions: [ - aPopMenu(context), - addressActionButton(context), + commonPopMenu(context), + addressPopMenu(context), ], ), body: DefaultTabController( diff --git a/lib/screens/SearchScreen.dart b/lib/screens/SearchScreen.dart index 6b7923a..b7433c1 100644 --- a/lib/screens/SearchScreen.dart +++ b/lib/screens/SearchScreen.dart @@ -51,8 +51,8 @@ class _SearchScreenState extends State { return AppBar( title: Text("${categoryTitle(widget.category)} ${widget.keyword}"), actions: [ - aPopMenu(context), - addressActionButton(context), + commonPopMenu(context), + addressPopMenu(context), _chooseCategoryAction(), _searchBar.getSearchAction(context), ], diff --git a/lib/screens/components/Common.dart b/lib/screens/components/Common.dart index 0e13b99..dd8b7ae 100644 --- a/lib/screens/components/Common.dart +++ b/lib/screens/components/Common.dart @@ -4,7 +4,7 @@ import '../../basic/config/ListLayout.dart'; import '../../basic/config/ShadowCategories.dart'; import '../../basic/config/ShadowCategoriesMode.dart'; -Widget aPopMenu(BuildContext context) { +Widget commonPopMenu(BuildContext context) { return PopupMenuButton( itemBuilder: (BuildContext context) => >[ const PopupMenuItem( diff --git a/lib/screens/components/ImageReader.dart b/lib/screens/components/ImageReader.dart index e22fe98..06f56bf 100644 --- a/lib/screens/components/ImageReader.dart +++ b/lib/screens/components/ImageReader.dart @@ -24,6 +24,7 @@ import 'package:pikapika/basic/config/VolumeController.dart'; import 'package:pikapika/screens/components/PkzImages.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import '../../basic/config/IconLoading.dart'; +import '../../basic/config/UseApiLoadImage.dart'; import '../FilePhotoViewScreen.dart'; import 'gesture_zoom_box.dart'; @@ -560,38 +561,38 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { !widget.struct.fullScreen) { return Container(); } - if (widget.readerSliderPosition == ReaderSliderPosition.RIGHT ) { + if (widget.readerSliderPosition == ReaderSliderPosition.RIGHT) { return SafeArea( child: Align( - alignment: Alignment.bottomRight, - child: Material( - color: Colors.transparent, - child: Container( - padding: + alignment: Alignment.bottomRight, + child: Material( + color: Colors.transparent, + child: Container( + padding: const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), - margin: const EdgeInsets.only(bottom: 10), - decoration: const BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - bottomLeft: Radius.circular(10), - ), - color: Color(0x88000000), - ), - child: GestureDetector( - onTap: () { - widget.struct.onFullScreenChange(!widget.struct.fullScreen); - }, - child: Icon( - widget.struct.fullScreen - ? Icons.fullscreen_exit - : Icons.fullscreen_outlined, - size: 30, - color: Colors.white, - ), - ), + margin: const EdgeInsets.only(bottom: 10), + decoration: const BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + bottomLeft: Radius.circular(10), + ), + color: Color(0x88000000), + ), + child: GestureDetector( + onTap: () { + widget.struct.onFullScreenChange(!widget.struct.fullScreen); + }, + child: Icon( + widget.struct.fullScreen + ? Icons.fullscreen_exit + : Icons.fullscreen_outlined, + size: 30, + color: Colors.white, ), ), - )); + ), + ), + )); } return SafeArea( child: Align( @@ -903,7 +904,7 @@ class _SettingPanelState extends State<_SettingPanel> { Row( children: [ _bottomIcon( - icon: Icons.shuffle, + icon: Icons.share, title: currentAddressName(), onPressed: () async { await chooseAddressAndSwitch(context); @@ -911,13 +912,20 @@ class _SettingPanelState extends State<_SettingPanel> { }, ), _bottomIcon( - icon: Icons.repeat_one, + icon: Icons.image_search, title: currentImageAddressName(), onPressed: () async { await chooseImageAddress(context); setState(() {}); }, ), + _bottomIcon( + icon: Icons.network_ping, + title: currentUseApiLoadImageName(), + onPressed: () { + chooseUseApiLoadImage(context); + }, + ), _bottomIcon( icon: Icons.refresh, title: "重载页面", @@ -926,11 +934,11 @@ class _SettingPanelState extends State<_SettingPanel> { widget.onReloadEp(); }, ), - _bottomIcon( - icon: Icons.file_download, - title: "下载本作", - onPressed: widget.onDownload, - ), + // _bottomIcon( + // icon: Icons.file_download, + // title: "下载本作", + // onPressed: widget.onDownload, + // ), ], ), ],