From 22c801ca361ec92272367da56a90d1e71a025efb Mon Sep 17 00:00:00 2001 From: wanghongenpin Date: Sat, 18 Jan 2025 21:34:41 +0800 Subject: [PATCH] desktop request list sort #(370) --- lib/ui/desktop/desktop.dart | 30 +++++++++++--------- lib/ui/desktop/request/list.dart | 2 +- lib/ui/desktop/request/request_sequence.dart | 4 +-- lib/ui/mobile/menu/menu.dart | 15 ++++++++++ lib/ui/mobile/mobile.dart | 30 +++++++++++--------- lib/ui/mobile/request/domians.dart | 12 +++++++- lib/ui/mobile/request/list.dart | 6 ++++ lib/ui/mobile/request/request_sequence.dart | 6 ++-- pubspec.yaml | 2 +- 9 files changed, 72 insertions(+), 35 deletions(-) diff --git a/lib/ui/desktop/desktop.dart b/lib/ui/desktop/desktop.dart index 117c339..9814fcc 100644 --- a/lib/ui/desktop/desktop.dart +++ b/lib/ui/desktop/desktop.dart @@ -156,23 +156,25 @@ class _DesktopHomePagePageState extends State implements EventL ? '提示:默认不会开启HTTPS抓包,请安装证书后再开启HTTPS抓包。\n' '点击HTTPS抓包(加锁图标),选择安装根证书,按照提示操作即可。\n\n' '1. 新增socks5代理支持, 可在设置中关闭;\n' - '2. 响应新增图片保存;\n' - '3. 请求重写新增json格式化;\n' - '4. 修复安卓首次在画中画开启VPN闪退;\n' - '5. 修复Illegal IPv6 address问题;\n' - '6. 修复Windows历史导入安卓har历史文件崩溃问题;\n' - '7. 修复复制python请求头不全问题;\n' - '8. 修复二维码保存的背景颜色问题;\n' + '2. 请求列表增加按时间排序;\n' + '3. 响应新增图片保存;\n' + '4. 请求重写新增json格式化;\n' + '5. 修复安卓首次在画中画开启VPN闪退;\n' + '6. 修复Illegal IPv6 address问题;\n' + '7. 修复Windows历史导入安卓har历史文件崩溃问题;\n' + '8. 修复复制python请求头不全问题;\n' + '9. 修复二维码保存的背景颜色问题;\n' : 'Tips:By default, HTTPS packet capture will not be enabled. Please install the certificate before enabling HTTPS packet capture。\n' 'Click HTTPS Capture packets(Lock icon),Choose to install the root certificate and follow the prompts to proceed。\n\n' '1. Added support for socks5 proxy, which can be turned off in settings;\n' - '2. Response to saving newly added images;\n' - '3. Request rewriting to add json format;\n' - '4. Fixed the issue when opening VPN in Picture-in-Picture mode on Android for the first time;\n' - '5. Fix Illegal IPv6 address issue;\n' - '6. Fix Windows history import Android har history file crash issue;\n' - '7. Fix the problem of incomplete copy of python request header;\n' - '8. Fixed the background color issue when saving QR code;\n' + '2. Add request list sorted by time;\n' + '3. Response to saving newly added images;\n' + '4. Request rewriting to add json format;\n' + '5. Fixed the issue when opening VPN in Picture-in-Picture mode on Android for the first time;\n' + '6. Fix Illegal IPv6 address issue;\n' + '7. Fix Windows history import Android har history file crash issue;\n' + '8. Fix the problem of incomplete copy of python request header;\n' + '9. Fixed the background color issue when saving QR code;\n' '', style: const TextStyle(fontSize: 14)))); }); diff --git a/lib/ui/desktop/request/list.dart b/lib/ui/desktop/request/list.dart index f3b52dd..6dbb740 100644 --- a/lib/ui/desktop/request/list.dart +++ b/lib/ui/desktop/request/list.dart @@ -141,7 +141,7 @@ class DesktopRequestListState extends State with Autom }, child: IconText( icon: const Icon(Icons.sort, size: 16), - text: sortDesc ? localizations.timeDesc : localizations.timeAsc, + text: sortDesc ? localizations.timeAsc : localizations.timeDesc, textStyle: const TextStyle(fontSize: 13))), ]; }); diff --git a/lib/ui/desktop/request/request_sequence.dart b/lib/ui/desktop/request/request_sequence.dart index 3577bc6..d4b9533 100644 --- a/lib/ui/desktop/request/request_sequence.dart +++ b/lib/ui/desktop/request/request_sequence.dart @@ -105,7 +105,7 @@ class RequestSequenceState extends State with AutomaticKeepAliv return RequestWidget( key: ValueKey(view.elementAt(index).requestId), view.elementAt(index), - index: view.length - index, + index: sortDesc ? view.length - index : index, trailing: appIcon(view.elementAt(index)), proxyServer: widget.proxyServer, displayDomain: widget.displayDomain, @@ -202,7 +202,7 @@ class RequestSequenceState extends State with AutomaticKeepAliv sort(bool desc) { sortDesc = desc; setState(() { - view = Queue.of(view.toList().reversed); + view = Queue.of(view.toList().reversed); }); } } diff --git a/lib/ui/mobile/menu/menu.dart b/lib/ui/mobile/menu/menu.dart index 548444a..41e05de 100644 --- a/lib/ui/mobile/menu/menu.dart +++ b/lib/ui/mobile/menu/menu.dart @@ -27,6 +27,8 @@ import 'package:proxypin/ui/mobile/widgets/remote_device.dart'; /// +号菜单 class MoreMenu extends StatelessWidget { + static bool sortDesc = true; + final ProxyServer proxyServer; final ValueNotifier remoteDevice; @@ -107,6 +109,19 @@ class MoreMenu extends StatelessWidget { MobileApp.requestStateKey.currentState?.export(context, 'ProxyPin$name'); }, )), + PopupMenuItem( + height: 32, + child: ListTile( + dense: true, + leading: const Icon(Icons.sort, size: 16), + title: Text(sortDesc ? localizations.timeAsc : localizations.timeDesc), + onTap: () async { + await Navigator.maybePop(context); + + sortDesc = !sortDesc; + MobileApp.requestStateKey.currentState?.sort(sortDesc); + }, + )), ]; }, ); diff --git a/lib/ui/mobile/mobile.dart b/lib/ui/mobile/mobile.dart index 24a2462..adb838d 100644 --- a/lib/ui/mobile/mobile.dart +++ b/lib/ui/mobile/mobile.dart @@ -261,23 +261,25 @@ class MobileHomeState extends State implements EventListener, Li String content = isCN ? '提示:默认不会开启HTTPS抓包,请安装证书后再开启HTTPS抓包。\n\n' '1. 新增socks5代理支持, 可在设置中关闭;\n' - '2. 响应新增图片保存;\n' - '3. 请求重写新增json格式化;\n' - '4. 修复安卓首次在画中画开启VPN闪退;\n' - '5. 修复Illegal IPv6 address问题;\n' - '6. 修复Windows历史导入安卓har历史文件崩溃问题;\n' - '7. 修复复制python请求头不全问题;\n' - '8. 修复二维码保存的背景颜色问题;\n' + '2. 请求列表增加按时间排序;\n' + '3. 响应新增图片保存;\n' + '4. 请求重写新增json格式化;\n' + '5. 修复安卓首次在画中画开启VPN闪退;\n' + '6. 修复Illegal IPv6 address问题;\n' + '7. 修复Windows历史导入安卓har历史文件崩溃问题;\n' + '8. 修复复制python请求头不全问题;\n' + '9. 修复二维码保存的背景颜色问题;\n' : 'Tips:By default, HTTPS packet capture will not be enabled. Please install the certificate before enabling HTTPS packet capture。\n\n' 'Click HTTPS Capture packets(Lock icon),Choose to install the root certificate and follow the prompts to proceed。\n\n' '1. Added support for socks5 proxy, which can be turned off in settings;\n' - '2. Response to saving newly added images;\n' - '3. Request rewriting to add json format;\n' - '4. Fixed the issue when opening VPN in Picture-in-Picture mode on Android for the first time;\n' - '5. Fix Illegal IPv6 address issue;\n' - '6. Fix Windows history import Android har history file crash issue;\n' - '7. Fix the problem of incomplete copy of python request header;\n' - '8. Fixed the background color issue when saving QR code;\n' + '2. Add request list sorted by time;\n' + '3. Response to saving newly added images;\n' + '4. Request rewriting to add json format;\n' + '5. Fixed the issue when opening VPN in Picture-in-Picture mode on Android for the first time;\n' + '6. Fix Illegal IPv6 address issue;\n' + '7. Fix Windows history import Android har history file crash issue;\n' + '8. Fix the problem of incomplete copy of python request header;\n' + '9. Fixed the background color issue when saving QR code;\n' ''; showAlertDialog(isCN ? '更新内容V1.1.7' : "Update content V1.1.7", content, () { widget.appConfiguration.upgradeNoticeV17 = false; diff --git a/lib/ui/mobile/request/domians.dart b/lib/ui/mobile/request/domians.dart index 2f5945f..06fd0c7 100644 --- a/lib/ui/mobile/request/domians.dart +++ b/lib/ui/mobile/request/domians.dart @@ -68,6 +68,8 @@ class DomainListState extends State with AutomaticKeepAliveClientMix bool changing = false; + bool sortDesc = true; + AppLocalizations get localizations => AppLocalizations.of(context)!; @override @@ -163,6 +165,11 @@ class DomainListState extends State with AutomaticKeepAliveClientMix changeState(); } + ///排序 + sort(bool desc) { + sortDesc = desc; + } + bool filter(HostAndPort hostAndPort) { if (searchText?.isNotEmpty == true) { return hostAndPort.domain.toLowerCase().contains(searchText!); @@ -222,12 +229,15 @@ class DomainListState extends State with AutomaticKeepAliveClientMix onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { showHostAndPort = view.elementAt(index); + var list = containerMap[view.elementAt(index)]; + return Scaffold( appBar: AppBar(title: Text(view.elementAt(index).domain, style: const TextStyle(fontSize: 16))), body: RequestSequence( key: requestSequenceKey, displayDomain: false, - container: ListenableList(containerMap[view.elementAt(index)]), + container: ListenableList(sortDesc ? list : list?.reversed.toList()), + sortDesc: sortDesc, onRemove: widget.onRemove, proxyServer: widget.proxyServer)); })); diff --git a/lib/ui/mobile/request/list.dart b/lib/ui/mobile/request/list.dart index 7be7f1f..8340ef8 100644 --- a/lib/ui/mobile/request/list.dart +++ b/lib/ui/mobile/request/list.dart @@ -164,6 +164,12 @@ class RequestListState extends State { fileNameOverrides: [fileName], sharePositionOrigin: box == null ? null : box.localToGlobal(Offset.zero) & box.size); } + + sort(bool sortDesc) { + requestSequenceKey.currentState?.sort(sortDesc); + domainListKey.currentState?.sort(sortDesc); + } + } class DoubleClickHandle { diff --git a/lib/ui/mobile/request/request_sequence.dart b/lib/ui/mobile/request/request_sequence.dart index 4514ba6..1f2d996 100644 --- a/lib/ui/mobile/request/request_sequence.dart +++ b/lib/ui/mobile/request/request_sequence.dart @@ -14,10 +14,11 @@ class RequestSequence extends StatefulWidget { final ListenableList container; final ProxyServer proxyServer; final bool displayDomain; + final bool? sortDesc; final Function(List)? onRemove; const RequestSequence( - {super.key, required this.container, required this.proxyServer, this.displayDomain = true, this.onRemove}); + {super.key, required this.container, required this.proxyServer, this.displayDomain = true, this.onRemove, this.sortDesc}); @override State createState() { @@ -44,6 +45,7 @@ class RequestSequenceState extends State with AutomaticKeepAliv @override initState() { super.initState(); + sortDesc = widget.sortDesc ?? true; view.addAll(widget.container.source.reversed); highlightListener = () { //回调时机在高亮设置页面dispose之后。所以需要在下一帧刷新,否则会报错 @@ -153,7 +155,7 @@ class RequestSequenceState extends State with AutomaticKeepAliv itemCount: view.length, itemBuilder: (context, index) { return RequestRow( - index: view.length - index, + index: sortDesc ? view.length - index : index, key: indexes[view.elementAt(index).requestId] ??= GlobalKey(), request: view.elementAt(index), proxyServer: widget.proxyServer, diff --git a/pubspec.yaml b/pubspec.yaml index ad972c0..e9dd1ef 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: url: https://github.com/wanghongenpin/flutter-code-editor.git ref: secure-keyboard flutter_desktop_context_menu: ^0.2.0 - device_info_plus: ^11.2.0 + device_info_plus: ^11.2.1 shared_preferences: ^2.3.5 image_pickers: ^2.0.5+2 url_launcher: ^6.3.1