mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
@@ -7,7 +7,6 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||||||
import 'package:icons_plus/icons_plus.dart';
|
import 'package:icons_plus/icons_plus.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:server_box/core/extension/context/locale.dart';
|
import 'package:server_box/core/extension/context/locale.dart';
|
||||||
import 'package:server_box/data/res/provider.dart';
|
|
||||||
import 'package:server_box/data/res/rebuild.dart';
|
import 'package:server_box/data/res/rebuild.dart';
|
||||||
import 'package:server_box/data/res/store.dart';
|
import 'package:server_box/data/res/store.dart';
|
||||||
import 'package:server_box/data/res/url.dart';
|
import 'package:server_box/data/res/url.dart';
|
||||||
@@ -737,47 +736,29 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
leading: const Icon(Icons.delete_forever),
|
leading: const Icon(Icons.delete_forever),
|
||||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
context.showRoundDialog<List<String>>(
|
final keys = Stores.server.box.keys.toList();
|
||||||
title: l10n.choose,
|
keys.removeWhere((element) => element == BoxX.lastModifiedKey);
|
||||||
child: SingleChildScrollView(
|
final strKeys = List<String>.empty(growable: true);
|
||||||
child: StatefulBuilder(builder: (ctx, setState) {
|
for (final key in keys) {
|
||||||
final keys = Stores.server.box.keys.toList();
|
if (key is String) strKeys.add(key);
|
||||||
keys.removeWhere((element) => element == BoxX.lastModifiedKey);
|
}
|
||||||
final all = keys.map(
|
final deleteKeys = await context.showPickDialog<String>(
|
||||||
(e) {
|
clearable: true,
|
||||||
final name = Pros.server.pick(id: e)?.spi.name;
|
items: strKeys,
|
||||||
return ListTile(
|
|
||||||
title: Text(name ?? e),
|
|
||||||
subtitle: name != null ? Text(e) : null,
|
|
||||||
onTap: () => context.showRoundDialog(
|
|
||||||
title: l10n.attention,
|
|
||||||
child: Text(l10n.askContinue(
|
|
||||||
'${l10n.delete} ${l10n.server}($e)',
|
|
||||||
)),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Pros.server.delServer(e);
|
|
||||||
ctx.pop();
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
child: Text(l10n.ok),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxHeight: 377),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: all.toList(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
if (deleteKeys == null) return;
|
||||||
|
|
||||||
|
final md = deleteKeys.map((e) => '- $e').join('\n');
|
||||||
|
final sure = await context.showRoundDialog(
|
||||||
|
title: l10n.attention,
|
||||||
|
child: SimpleMarkdown(data: md),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (sure != true) return;
|
||||||
|
for (final key in deleteKeys) {
|
||||||
|
Stores.server.box.delete(key);
|
||||||
|
}
|
||||||
|
context.showSnackBar(l10n.success);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user