cache
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/database/database.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -315,6 +316,15 @@ class ProxyGroups extends _$ProxyGroups with AsyncNotifierMixin {
|
||||
return !proxyGroupsEquality.equals(previous.value, next.value);
|
||||
}
|
||||
|
||||
void del(String name) {
|
||||
database.proxyGroups.remove(
|
||||
(t) => t.profileId.equals(profileId) & t.name.equals(name),
|
||||
);
|
||||
List<ProxyGroup> newList = List.from(value);
|
||||
newList = newList.where((item) => item.name != name).toList();
|
||||
value = newList;
|
||||
}
|
||||
|
||||
void order(int oldIndex, int newIndex) {
|
||||
if (oldIndex < newIndex) {
|
||||
newIndex -= 1;
|
||||
|
||||
@@ -563,12 +563,19 @@ class _EditProxyGroupViewState extends ConsumerState<_EditProxyGroupView> {
|
||||
);
|
||||
}
|
||||
|
||||
void _handleDelete() {}
|
||||
void _handleDelete(int profileId, String name) {
|
||||
ref.read(proxyGroupsProvider(profileId).notifier).del(name);
|
||||
final popCb = SheetProvider.of(context)?.nestedNavigatorPopCallback;
|
||||
if (popCb != null) {
|
||||
popCb();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isBottomSheet =
|
||||
SheetProvider.of(context)?.type == SheetType.bottomSheet;
|
||||
final profileId = ProfileIdProvider.of(context)!.profileId;
|
||||
final proxyGroup = ref.watch(proxyGroupProvider);
|
||||
return AdaptiveSheetScaffold(
|
||||
sheetTransparentToolBar: true,
|
||||
@@ -628,7 +635,9 @@ class _EditProxyGroupViewState extends ConsumerState<_EditProxyGroupView> {
|
||||
color: context.colorScheme.error,
|
||||
),
|
||||
),
|
||||
onPressed: _handleDelete,
|
||||
onPressed: () {
|
||||
_handleDelete(profileId, proxyGroup.name);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user