fix: batch delete servers (#772)
This commit is contained in:
@@ -144,7 +144,12 @@ class _ServerDetailPageState extends State<ServerDetailPage> with SingleTickerPr
|
|||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (_, cons) {
|
builder: (_, cons) {
|
||||||
if (logoUrl == null) return UIs.placeholder;
|
if (logoUrl == null) return UIs.placeholder;
|
||||||
return ExtendedImage.network(logoUrl, cache: true, height: cons.maxWidth * 0.2);
|
return ExtendedImage.network(
|
||||||
|
logoUrl,
|
||||||
|
cache: true,
|
||||||
|
height: cons.maxHeight * 0.2,
|
||||||
|
width: cons.maxWidth,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ extension _Server on _AppSettingsPageState {
|
|||||||
title: Text(l10n.netViewType),
|
title: Text(l10n.netViewType),
|
||||||
trailing: ValBuilder(
|
trailing: ValBuilder(
|
||||||
listenable: _setting.netViewType.listenable(),
|
listenable: _setting.netViewType.listenable(),
|
||||||
builder: (val) => Text(
|
builder: (val) => Text(val.toStr, style: UIs.text15),
|
||||||
val.toStr,
|
|
||||||
style: UIs.text15,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final selected = await context.showPickSingleDialog(
|
final selected = await context.showPickSingleDialog(
|
||||||
@@ -48,21 +45,26 @@ extension _Server on _AppSettingsPageState {
|
|||||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final keys = Stores.server.keys();
|
final keys = Stores.server.keys();
|
||||||
|
final names = Map.fromEntries(
|
||||||
|
keys.map((e) => MapEntry(e, ServerProvider.pick(id: e)?.value.spi.name ?? e)),
|
||||||
|
);
|
||||||
final deleteKeys = await context.showPickDialog<String>(
|
final deleteKeys = await context.showPickDialog<String>(
|
||||||
clearable: true,
|
clearable: true,
|
||||||
items: keys.toList(),
|
items: keys.toList(),
|
||||||
|
display: (p0) => names[p0] ?? p0,
|
||||||
);
|
);
|
||||||
if (deleteKeys == null) return;
|
if (deleteKeys == null || deleteKeys.isEmpty) return;
|
||||||
|
|
||||||
final md = deleteKeys.map((e) => '- $e').join('\n');
|
final md = deleteKeys.map((e) => '- ${names[e] ?? e}').join('\n');
|
||||||
final sure = await context.showRoundDialog(
|
final sure = await context.showRoundDialog(
|
||||||
title: libL10n.attention,
|
title: libL10n.attention,
|
||||||
child: SimpleMarkdown(data: md),
|
child: SimpleMarkdown(data: md),
|
||||||
|
actions: Btnx.cancelRedOk,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (sure != true) return;
|
if (sure != true) return;
|
||||||
for (final key in deleteKeys) {
|
for (final key in deleteKeys) {
|
||||||
Stores.server.box.delete(key);
|
Stores.server.remove(key);
|
||||||
}
|
}
|
||||||
context.showSnackBar(libL10n.success);
|
context.showSnackBar(libL10n.success);
|
||||||
},
|
},
|
||||||
@@ -77,10 +79,7 @@ extension _Server on _AppSettingsPageState {
|
|||||||
title: TipText(l10n.textScaler, l10n.textScalerTip),
|
title: TipText(l10n.textScaler, l10n.textScalerTip),
|
||||||
trailing: ValBuilder(
|
trailing: ValBuilder(
|
||||||
listenable: _setting.textFactor.listenable(),
|
listenable: _setting.textFactor.listenable(),
|
||||||
builder: (val) => Text(
|
builder: (val) => Text(val.toString(), style: UIs.text15),
|
||||||
val.toString(),
|
|
||||||
style: UIs.text15,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onTap: () => context.showRoundDialog(
|
onTap: () => context.showRoundDialog(
|
||||||
title: l10n.textScaler,
|
title: l10n.textScaler,
|
||||||
@@ -113,10 +112,7 @@ extension _Server on _AppSettingsPageState {
|
|||||||
return ExpandTile(
|
return ExpandTile(
|
||||||
leading: const Icon(BoxIcons.bxs_joystick_button, size: _kIconSize),
|
leading: const Icon(BoxIcons.bxs_joystick_button, size: _kIconSize),
|
||||||
title: Text(l10n.serverFuncBtns),
|
title: Text(l10n.serverFuncBtns),
|
||||||
children: [
|
children: [_buildServerFuncBtnsSwitch(), _buildServerFuncBtnsOrder()],
|
||||||
_buildServerFuncBtnsSwitch(),
|
|
||||||
_buildServerFuncBtnsOrder(),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,10 +207,7 @@ extension _Server on _AppSettingsPageState {
|
|||||||
|
|
||||||
void onSave(EditorPageRet ret) {
|
void onSave(EditorPageRet ret) {
|
||||||
if (ret.typ != EditorPageRetType.text) {
|
if (ret.typ != EditorPageRetType.text) {
|
||||||
context.showRoundDialog(
|
context.showRoundDialog(title: libL10n.fail, child: Text(l10n.invalid));
|
||||||
title: libL10n.fail,
|
|
||||||
child: Text(l10n.invalid),
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -226,10 +219,7 @@ extension _Server on _AppSettingsPageState {
|
|||||||
Stores.setting.box.delete(key);
|
Stores.setting.box.delete(key);
|
||||||
}
|
}
|
||||||
} catch (e, trace) {
|
} catch (e, trace) {
|
||||||
context.showRoundDialog(
|
context.showRoundDialog(title: libL10n.error, child: Text('${l10n.save}:\n$e'));
|
||||||
title: libL10n.error,
|
|
||||||
child: Text('${l10n.save}:\n$e'),
|
|
||||||
);
|
|
||||||
Loggers.app.warning('Update json settings failed', e, trace);
|
Loggers.app.warning('Update json settings failed', e, trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,11 +261,7 @@ extension _Server on _AppSettingsPageState {
|
|||||||
Widget _buildServerLogoUrl() {
|
Widget _buildServerLogoUrl() {
|
||||||
void onSave(String url) {
|
void onSave(String url) {
|
||||||
if (url.isEmpty || !url.startsWith('http')) {
|
if (url.isEmpty || !url.startsWith('http')) {
|
||||||
context.showRoundDialog(
|
context.showRoundDialog(title: libL10n.fail, child: Text('${l10n.invalid} URL'), actions: Btnx.oks);
|
||||||
title: libL10n.fail,
|
|
||||||
child: Text('${l10n.invalid} URL'),
|
|
||||||
actions: Btnx.oks,
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_setting.serverLogoUrl.put(url);
|
_setting.serverLogoUrl.put(url);
|
||||||
@@ -287,8 +273,7 @@ extension _Server on _AppSettingsPageState {
|
|||||||
title: const Text('Logo URL'),
|
title: const Text('Logo URL'),
|
||||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
final ctrl =
|
final ctrl = TextEditingController(text: _setting.serverLogoUrl.fetch());
|
||||||
TextEditingController(text: _setting.serverLogoUrl.fetch());
|
|
||||||
context.showRoundDialog(
|
context.showRoundDialog(
|
||||||
title: 'Logo URL',
|
title: 'Logo URL',
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:flutter_highlight/theme_map.dart';
|
|||||||
import 'package:icons_plus/icons_plus.dart';
|
import 'package:icons_plus/icons_plus.dart';
|
||||||
import 'package:server_box/core/extension/context/locale.dart';
|
import 'package:server_box/core/extension/context/locale.dart';
|
||||||
import 'package:server_box/data/model/app/net_view.dart';
|
import 'package:server_box/data/model/app/net_view.dart';
|
||||||
|
import 'package:server_box/data/provider/server.dart';
|
||||||
import 'package:server_box/data/res/build_data.dart';
|
import 'package:server_box/data/res/build_data.dart';
|
||||||
import 'package:server_box/data/res/github_id.dart';
|
import 'package:server_box/data/res/github_id.dart';
|
||||||
import 'package:server_box/data/res/store.dart';
|
import 'package:server_box/data/res/store.dart';
|
||||||
|
|||||||
Reference in New Issue
Block a user