mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: show loading dialog
This commit is contained in:
@@ -225,6 +225,7 @@ class BackupPage extends StatelessWidget {
|
||||
final backup = await context.showLoadingDialog(
|
||||
fn: () => Computer.shared.start(Backup.fromJsonString, text.trim()),
|
||||
);
|
||||
if (backup == null) return;
|
||||
if (backupFormatVersion != backup.version) {
|
||||
context.showSnackBar(l10n.backupVersionNotMatch);
|
||||
return;
|
||||
@@ -367,6 +368,7 @@ class BackupPage extends StatelessWidget {
|
||||
fn: () => Computer.shared.start(Backup.fromJsonString, text.trim()),
|
||||
);
|
||||
|
||||
if (backup == null) return;
|
||||
if (backupFormatVersion != backup.version) {
|
||||
context.showSnackBar(l10n.backupVersionNotMatch);
|
||||
return;
|
||||
@@ -408,6 +410,7 @@ class BackupPage extends StatelessWidget {
|
||||
return list.map((e) => ServerPrivateInfo.fromJson(e)).toList();
|
||||
}, text.trim()),
|
||||
);
|
||||
if (spis == null) return;
|
||||
final sure = await context.showRoundDialog<bool>(
|
||||
title: l10n.import,
|
||||
child: Text(l10n.askContinue('${spis.length} ${l10n.server}')),
|
||||
@@ -419,13 +422,15 @@ class BackupPage extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
if (sure == true) {
|
||||
await context.showLoadingDialog(
|
||||
final suc = await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
for (var spi in spis) {
|
||||
Stores.server.put(spi);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
);
|
||||
if (suc != true) return;
|
||||
context.showSnackBar(l10n.success);
|
||||
}
|
||||
} catch (e, s) {
|
||||
|
||||
@@ -145,10 +145,10 @@ class _EditorPageState extends State<EditorPage> {
|
||||
// If path is not null, then it's a file editor
|
||||
// save the text and return true to pop the page
|
||||
if (widget.path != null) {
|
||||
await context.showLoadingDialog(
|
||||
final res = await context.showLoadingDialog(
|
||||
fn: () => File(widget.path!).writeAsString(_controller.text),
|
||||
);
|
||||
|
||||
if (res == null) return;
|
||||
context.pop(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -430,10 +430,9 @@ final class _PvePageState extends State<PvePage> {
|
||||
],
|
||||
);
|
||||
if (sure != true) return;
|
||||
bool? suc;
|
||||
await context.showLoadingDialog(fn: () async {
|
||||
suc = await func(item.node, item.id);
|
||||
});
|
||||
|
||||
final suc =
|
||||
await context.showLoadingDialog(fn: () => func(item.node, item.id));
|
||||
if (suc == true) {
|
||||
context.showSnackBar(l10n.success);
|
||||
} else {
|
||||
|
||||
@@ -114,13 +114,8 @@ class _IOSSettingsPageState extends State<IOSSettingsPage> {
|
||||
final result = await AppRoutes.kvEditor(data: urls).go(context);
|
||||
if (result == null || result is! Map<String, String>) return;
|
||||
|
||||
try {
|
||||
await context.showLoadingDialog(fn: () async {
|
||||
await wc.updateApplicationContext({'urls': result});
|
||||
});
|
||||
} catch (e, s) {
|
||||
context.showErrDialog(e: e, s: s, operation: 'Watch Context');
|
||||
Loggers.app.warning('Update watch config failed', e, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
}
|
||||
|
||||
_status.path?.update(p);
|
||||
final suc = await _listDir();
|
||||
final suc = await _listDir() ?? false;
|
||||
if (suc && Stores.setting.recordHistory.fetch()) {
|
||||
Stores.history.sftpGoPath.add(p);
|
||||
}
|
||||
@@ -406,6 +406,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
},
|
||||
onErr: (e, s) {
|
||||
context.showErrDialog(e: e, s: s, operation: l10n.permission);
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -463,7 +464,8 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
SftpReqType.download,
|
||||
);
|
||||
Pros.sftp.add(req, completer: completer);
|
||||
await context.showLoadingDialog(fn: () => completer.future);
|
||||
final suc = await context.showLoadingDialog(fn: () => completer.future);
|
||||
if (suc == null) return;
|
||||
|
||||
final result = await AppRoutes.editor(path: localPath).go<bool>(context);
|
||||
if (result != null && result) {
|
||||
@@ -554,8 +556,8 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
try {
|
||||
await context.showLoadingDialog(
|
||||
|
||||
final suc = await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
final remotePath = _getRemotePath(file);
|
||||
if (useRmr) {
|
||||
@@ -565,13 +567,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
} else {
|
||||
await _status.client!.remove(remotePath);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onErr: (e, s) {},
|
||||
);
|
||||
if (suc == null) return;
|
||||
|
||||
_listDir();
|
||||
} catch (e, s) {
|
||||
context.showErrDialog(e: e, s: s, operation: l10n.delete);
|
||||
}
|
||||
},
|
||||
child: Text(l10n.delete, style: UIs.textRed),
|
||||
),
|
||||
@@ -597,18 +598,17 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
try {
|
||||
await context.showLoadingDialog(
|
||||
|
||||
final suc = await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
final dir = '${_status.path!.path}/${textController.text}';
|
||||
await _status.client!.mkdir(dir);
|
||||
return true;
|
||||
},
|
||||
onErr: (e, s) {},
|
||||
);
|
||||
if (suc == null) return;
|
||||
|
||||
_listDir();
|
||||
} catch (e, s) {
|
||||
context.showErrDialog(e: e, s: s, operation: l10n.createFolder);
|
||||
}
|
||||
}
|
||||
|
||||
context.showRoundDialog(
|
||||
@@ -653,18 +653,17 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
try {
|
||||
await context.showLoadingDialog(
|
||||
|
||||
final suc = await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
final path = '${_status.path!.path}/${textController.text}';
|
||||
await _client!.run('touch "$path"');
|
||||
return true;
|
||||
},
|
||||
onErr: (e, s) {},
|
||||
);
|
||||
if (suc == null) return;
|
||||
|
||||
_listDir();
|
||||
} catch (e, s) {
|
||||
context.showErrDialog(e: e, s: s, operation: l10n.createFile);
|
||||
}
|
||||
}
|
||||
|
||||
context.showRoundDialog(
|
||||
@@ -705,18 +704,17 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
try {
|
||||
await context.showLoadingDialog(
|
||||
|
||||
final suc = await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
final newName = textController.text;
|
||||
await _status.client?.rename(file.filename, newName);
|
||||
return true;
|
||||
},
|
||||
onErr: (e, s) {},
|
||||
);
|
||||
if (suc == null) return;
|
||||
|
||||
_listDir();
|
||||
} catch (e, s) {
|
||||
context.showErrDialog(e: e, s: s, operation: l10n.rename);
|
||||
}
|
||||
}
|
||||
|
||||
context.showRoundDialog(
|
||||
@@ -756,7 +754,10 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
);
|
||||
return;
|
||||
}
|
||||
await context.showLoadingDialog(fn: () async => _client?.run(cmd));
|
||||
final suc = await context.showLoadingDialog(
|
||||
fn: () => _client?.run(cmd) ?? Future.value(false),
|
||||
);
|
||||
if (suc == null) return;
|
||||
_listDir();
|
||||
}
|
||||
|
||||
@@ -771,7 +772,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
}
|
||||
|
||||
/// Only return true if the path is changed
|
||||
Future<bool> _listDir() async {
|
||||
Future<bool?> _listDir() async {
|
||||
return context.showLoadingDialog(
|
||||
fn: () async {
|
||||
_status.client ??= await _client?.sftp();
|
||||
|
||||
@@ -245,7 +245,7 @@ Future<void> _onPkg(BuildContext context, ServerPrivateInfo spi) async {
|
||||
}
|
||||
|
||||
// Update pkg list
|
||||
await context.showLoadingDialog(
|
||||
final suc = await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
final updateCmd = pkg.update;
|
||||
if (updateCmd != null) {
|
||||
@@ -258,6 +258,7 @@ Future<void> _onPkg(BuildContext context, ServerPrivateInfo spi) async {
|
||||
},
|
||||
barrierDismiss: true,
|
||||
);
|
||||
if (suc != true) return;
|
||||
|
||||
final listCmd = pkg.listUpdate;
|
||||
if (listCmd == null) {
|
||||
@@ -266,9 +267,14 @@ Future<void> _onPkg(BuildContext context, ServerPrivateInfo spi) async {
|
||||
}
|
||||
|
||||
// Get upgrade list
|
||||
final result = await context.showLoadingDialog(fn: () async {
|
||||
return await client.run(listCmd).string;
|
||||
});
|
||||
final result = await context.showLoadingDialog(
|
||||
fn: () => client.run(listCmd).string,
|
||||
);
|
||||
if (result == null || result.isEmpty) {
|
||||
context.showSnackBar(l10n.noResult);
|
||||
return;
|
||||
}
|
||||
|
||||
final list = pkg.updateListRemoveUnused(result.split('\n'));
|
||||
final upgradeable = list.map((e) => UpgradePkgInfo(e, pkg)).toList();
|
||||
if (upgradeable.isEmpty) {
|
||||
|
||||
@@ -385,8 +385,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "v1.0.79"
|
||||
resolved-ref: f1bc7dd5ec2af84813b33a9e2149e117dfea3cd0
|
||||
ref: "v1.0.80"
|
||||
resolved-ref: a31e278de69ef964e489687f4e289f18c568c91a
|
||||
url: "https://github.com/lppcg/fl_lib"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
||||
@@ -61,7 +61,7 @@ dependencies:
|
||||
fl_lib:
|
||||
git:
|
||||
url: https://github.com/lppcg/fl_lib
|
||||
ref: v1.0.79
|
||||
ref: v1.0.80
|
||||
|
||||
dependency_overrides:
|
||||
# dartssh2:
|
||||
|
||||
Reference in New Issue
Block a user