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