From bc0bbc6ede60446bf6f76103da5757c23e9df8a3 Mon Sep 17 00:00:00 2001 From: chen08209 Date: Wed, 11 Mar 2026 17:19:32 +0800 Subject: [PATCH] cache --- lib/views/profiles/overwrite/custom.dart | 2 +- .../profiles/overwrite/custom_proxies.dart | 79 ++++++++++++------- lib/views/profiles/overwrite/overwrite.dart | 1 + 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/lib/views/profiles/overwrite/custom.dart b/lib/views/profiles/overwrite/custom.dart index 84a4776..cc3cb17 100644 --- a/lib/views/profiles/overwrite/custom.dart +++ b/lib/views/profiles/overwrite/custom.dart @@ -45,7 +45,7 @@ class _CustomContent extends ConsumerWidget { SliverToBoxAdapter(child: SizedBox(height: 8)), SliverToBoxAdapter( child: _MoreActionButton( - label: '代理组', + label: '策略组', onPressed: () { _handleToProxyGroupsView(context, profileId); }, diff --git a/lib/views/profiles/overwrite/custom_proxies.dart b/lib/views/profiles/overwrite/custom_proxies.dart index 1e51d1b..4c00da0 100644 --- a/lib/views/profiles/overwrite/custom_proxies.dart +++ b/lib/views/profiles/overwrite/custom_proxies.dart @@ -70,6 +70,10 @@ class _CustomProxyGroupsView extends ConsumerWidget { ), ); }, + itemExtent: + 28 + + globalState.measure.bodyMediumHeight + + globalState.measure.bodyLargeHeight, itemCount: proxyGroups.length, onReorder: (oldIndex, newIndex) { _handleReorder(ref, profileId, oldIndex, newIndex); @@ -82,7 +86,7 @@ class _CustomProxyGroupsView extends ConsumerWidget { class _EditProxyGroupNestedSheet extends StatelessWidget { const _EditProxyGroupNestedSheet(); - Future _handlePop( + Future _handleClose( BuildContext context, NavigatorState? navigatorState, ) async { @@ -99,6 +103,17 @@ class _EditProxyGroupNestedSheet extends StatelessWidget { } } + Future _handlePop( + BuildContext context, + NavigatorState? navigatorState, + ) async { + if (navigatorState != null && navigatorState.canPop()) { + navigatorState.pop(); + } else { + Navigator.of(context).pop(); + } + } + @override Widget build(BuildContext context) { final GlobalKey nestedNavigatorKey = GlobalKey(); @@ -115,39 +130,45 @@ class _EditProxyGroupNestedSheet extends StatelessWidget { }, ); final sheetProvider = SheetProvider.of(context); - return CommonPopScope( - onPop: (_) async { - _handlePop(context, nestedNavigatorKey.currentState); - return false; - }, - child: sheetProvider!.copyWith( - nestedNavigatorPopCallback: () { - Navigator.of(context).pop(); + return BackButtonListener( + child: CommonPopScope( + onPop: (_) async { + _handleClose(context, nestedNavigatorKey.currentState); + return false; }, - child: Stack( - children: [ - Positioned.fill( - child: GestureDetector( - onTap: () async { - _handlePop(context, nestedNavigatorKey.currentState); - }, - ), - ), - SheetViewport( - child: PagedSheet( - decoration: MaterialSheetDecoration( - size: SheetSize.stretch, - borderRadius: sheetProvider.type == SheetType.bottomSheet - ? BorderRadius.vertical(top: Radius.circular(28)) - : BorderRadius.zero, - clipBehavior: Clip.antiAlias, + child: sheetProvider!.copyWith( + nestedNavigatorPopCallback: () { + Navigator.of(context).pop(); + }, + child: Stack( + children: [ + Positioned.fill( + child: GestureDetector( + onTap: () async { + _handlePop(context, nestedNavigatorKey.currentState); + }, ), - navigator: nestedNavigator, ), - ), - ], + SheetViewport( + child: PagedSheet( + decoration: MaterialSheetDecoration( + size: SheetSize.stretch, + borderRadius: sheetProvider.type == SheetType.bottomSheet + ? BorderRadius.vertical(top: Radius.circular(28)) + : BorderRadius.zero, + clipBehavior: Clip.antiAlias, + ), + navigator: nestedNavigator, + ), + ), + ], + ), ), ), + onBackButtonPressed: () async { + _handlePop(context, nestedNavigatorKey.currentState); + return true; + }, ); } } diff --git a/lib/views/profiles/overwrite/overwrite.dart b/lib/views/profiles/overwrite/overwrite.dart index b54ea29..534e80d 100644 --- a/lib/views/profiles/overwrite/overwrite.dart +++ b/lib/views/profiles/overwrite/overwrite.dart @@ -13,6 +13,7 @@ import 'package:fl_clash/views/config/scripts.dart'; import 'package:fl_clash/views/profiles/preview.dart'; import 'package:fl_clash/widgets/widgets.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:smooth_sheets/smooth_sheets.dart';