opt.: no app restart required
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/data/model/sftp/req.dart';
|
||||
import 'package:toolbox/data/res/misc.dart';
|
||||
@@ -37,7 +37,6 @@ class LocalStoragePage extends StatefulWidget {
|
||||
|
||||
class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
LocalPath? _path;
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -55,12 +54,6 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -74,7 +67,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
title: Text(_s.files),
|
||||
title: Text(l10n.files),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.downloading),
|
||||
@@ -96,7 +89,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
(_path?.path ?? _s.loadingFiles).omitStartStr(),
|
||||
(_path?.path ?? l10n.loadingFiles).omitStartStr(),
|
||||
_buildBtns(),
|
||||
],
|
||||
),
|
||||
@@ -200,7 +193,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
context.pop();
|
||||
_showRenameDialog(file);
|
||||
},
|
||||
title: Text(_s.rename),
|
||||
title: Text(l10n.rename),
|
||||
leading: const Icon(Icons.abc),
|
||||
),
|
||||
ListTile(
|
||||
@@ -208,7 +201,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
context.pop();
|
||||
_showDeleteDialog(file);
|
||||
},
|
||||
title: Text(_s.delete),
|
||||
title: Text(l10n.delete),
|
||||
leading: const Icon(Icons.delete),
|
||||
),
|
||||
],
|
||||
@@ -220,7 +213,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
final fileName = file.path.split('/').last;
|
||||
if (widget.isPickFile) {
|
||||
await context.showRoundDialog(
|
||||
title: Text(_s.pickFile),
|
||||
title: Text(l10n.pickFile),
|
||||
child: Text(fileName),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -228,7 +221,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
context.pop();
|
||||
context.pop(file.path);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
]);
|
||||
return;
|
||||
@@ -239,14 +232,14 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(_s.edit),
|
||||
title: Text(l10n.edit),
|
||||
onTap: () async {
|
||||
context.pop();
|
||||
final stat = await file.stat();
|
||||
if (stat.size > Miscs.editorMaxSize) {
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.attention),
|
||||
child: Text(_s.fileTooLarge(fileName, stat.size, '1m')),
|
||||
title: Text(l10n.attention),
|
||||
child: Text(l10n.fileTooLarge(fileName, stat.size, '1m')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -256,14 +249,14 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
final f = File(file.absolute.path);
|
||||
if (result != null) {
|
||||
f.writeAsString(result);
|
||||
context.showSnackBar(_s.saved);
|
||||
context.showSnackBar(l10n.saved);
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.abc),
|
||||
title: Text(_s.rename),
|
||||
title: Text(l10n.rename),
|
||||
onTap: () {
|
||||
context.pop();
|
||||
_showRenameDialog(file);
|
||||
@@ -271,7 +264,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(_s.delete),
|
||||
title: Text(l10n.delete),
|
||||
onTap: () {
|
||||
context.pop();
|
||||
_showDeleteDialog(file);
|
||||
@@ -279,20 +272,20 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.upload),
|
||||
title: Text(_s.upload),
|
||||
title: Text(l10n.upload),
|
||||
onTap: () async {
|
||||
context.pop();
|
||||
final ids = Providers.server.serverOrder;
|
||||
var idx = 0;
|
||||
await context.showRoundDialog(
|
||||
title: Text(_s.server),
|
||||
title: Text(l10n.server),
|
||||
child: Picker(
|
||||
items: ids.map((e) => Text(e)).toList(),
|
||||
onSelected: (idx_) => idx = idx_,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(), child: Text(_s.ok)),
|
||||
onPressed: () => context.pop(), child: Text(l10n.ok)),
|
||||
],
|
||||
);
|
||||
final id = ids[idx];
|
||||
@@ -313,12 +306,12 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
file.absolute.path,
|
||||
SftpReqType.upload,
|
||||
));
|
||||
context.showSnackBar(_s.added2List);
|
||||
context.showSnackBar(l10n.added2List);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.open_in_new),
|
||||
title: Text(_s.open),
|
||||
title: Text(l10n.open),
|
||||
onTap: () {
|
||||
shareFiles(context, [file.absolute.path]);
|
||||
},
|
||||
@@ -331,7 +324,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
void _showRenameDialog(FileSystemEntity file) {
|
||||
final fileName = file.path.split('/').last;
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.rename),
|
||||
title: Text(l10n.rename),
|
||||
child: Input(
|
||||
autoFocus: true,
|
||||
controller: TextEditingController(text: fileName),
|
||||
@@ -341,7 +334,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
try {
|
||||
file.renameSync(newPath);
|
||||
} catch (e) {
|
||||
context.showSnackBar('${_s.failed}:\n$e');
|
||||
context.showSnackBar('${l10n.failed}:\n$e');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,12 +347,12 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
void _showDeleteDialog(FileSystemEntity file) {
|
||||
final fileName = file.path.split('/').last;
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.delete),
|
||||
child: Text(_s.sureDelete(fileName)),
|
||||
title: Text(l10n.delete),
|
||||
child: Text(l10n.sureDelete(fileName)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
@@ -367,12 +360,12 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
try {
|
||||
file.deleteSync(recursive: true);
|
||||
} catch (e) {
|
||||
context.showSnackBar('${_s.failed}:\n$e');
|
||||
context.showSnackBar('${l10n.failed}:\n$e');
|
||||
return;
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -3,9 +3,9 @@ import 'dart:async';
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/core/extension/sftpfile.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
@@ -49,14 +49,11 @@ class SftpPage extends StatefulWidget {
|
||||
class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
final SftpBrowserStatus _status = SftpBrowserStatus();
|
||||
|
||||
late S _s;
|
||||
|
||||
SSHClient? _client;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -130,7 +127,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
(_status.path?.path ?? _s.loadingFiles).omitStartStr(),
|
||||
(_status.path?.path ?? l10n.loadingFiles).omitStartStr(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: children,
|
||||
@@ -150,12 +147,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.open_in_new),
|
||||
title: Text(_s.system),
|
||||
title: Text(l10n.system),
|
||||
onTap: () => context.pop(1),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.folder),
|
||||
title: Text(_s.inner),
|
||||
title: Text(l10n.inner),
|
||||
onTap: () => context.pop(0),
|
||||
),
|
||||
],
|
||||
@@ -199,11 +196,11 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.folder),
|
||||
title: Text(_s.createFolder),
|
||||
title: Text(l10n.createFolder),
|
||||
onTap: () => _mkdir(context)),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.insert_drive_file),
|
||||
title: Text(_s.createFile),
|
||||
title: Text(l10n.createFile),
|
||||
onTap: () => _newFile(context)),
|
||||
],
|
||||
),
|
||||
@@ -217,7 +214,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
padding: const EdgeInsets.all(0),
|
||||
onPressed: () async {
|
||||
final p = await context.showRoundDialog<String>(
|
||||
title: Text(_s.goto),
|
||||
title: Text(l10n.goto),
|
||||
child: Autocomplete<String>(
|
||||
optionsBuilder: (val) {
|
||||
if (!Stores.setting.recordHistory.fetch()) {
|
||||
@@ -231,7 +228,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
return Input(
|
||||
autoFocus: true,
|
||||
icon: Icons.abc,
|
||||
label: _s.path,
|
||||
label: l10n.path,
|
||||
node: node,
|
||||
controller: controller,
|
||||
onSubmitted: (value) => context.pop(value),
|
||||
@@ -318,12 +315,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
final children = [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(_s.delete),
|
||||
title: Text(l10n.delete),
|
||||
onTap: () => _delete(context, file),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.abc),
|
||||
title: Text(_s.rename),
|
||||
title: Text(l10n.rename),
|
||||
onTap: () => _rename(context, file),
|
||||
),
|
||||
];
|
||||
@@ -331,19 +328,19 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
children.addAll([
|
||||
ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(_s.edit),
|
||||
title: Text(l10n.edit),
|
||||
onTap: () => _edit(context, file),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.download),
|
||||
title: Text(_s.download),
|
||||
title: Text(l10n.download),
|
||||
onTap: () => _download(context, file),
|
||||
),
|
||||
// Only show decompress option when the file is a compressed file
|
||||
if (_canDecompress(file.filename))
|
||||
ListTile(
|
||||
leading: const Icon(Icons.folder_zip),
|
||||
title: Text(_s.decompress),
|
||||
title: Text(l10n.decompress),
|
||||
onTap: () => _decompress(context, file),
|
||||
),
|
||||
]);
|
||||
@@ -359,7 +356,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
Future<void> _edit(BuildContext context, SftpName name) async {
|
||||
final size = name.attr.size;
|
||||
if (size == null || size > Miscs.editorMaxSize) {
|
||||
context.showSnackBar(_s.fileTooLarge(
|
||||
context.showSnackBar(l10n.fileTooLarge(
|
||||
name.filename,
|
||||
size ?? 0,
|
||||
Miscs.editorMaxSize,
|
||||
@@ -386,18 +383,18 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
if (result != null && result) {
|
||||
Providers.sftp
|
||||
.add(SftpReq(req.spi, remotePath, localPath, SftpReqType.upload));
|
||||
context.showSnackBar(_s.added2List);
|
||||
context.showSnackBar(l10n.added2List);
|
||||
}
|
||||
}
|
||||
|
||||
void _download(BuildContext context, SftpName name) {
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.attention),
|
||||
child: Text('${_s.dl2Local(name.filename)}\n${_s.keepForeground}'),
|
||||
title: Text(l10n.attention),
|
||||
child: Text('${l10n.dl2Local(name.filename)}\n${l10n.keepForeground}'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
@@ -415,7 +412,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
|
||||
context.pop();
|
||||
},
|
||||
child: Text(_s.download),
|
||||
child: Text(l10n.download),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -425,16 +422,16 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.pop();
|
||||
final isDir = file.attr.isDirectory;
|
||||
final useRmrf = Stores.setting.sftpRmrfDir.fetch();
|
||||
final dirText = (isDir && !useRmrf) ? '\n${_s.sureDirEmpty}' : '';
|
||||
final text = '${_s.sureDelete(file.filename)}$dirText';
|
||||
final dirText = (isDir && !useRmrf) ? '\n${l10n.sureDirEmpty}' : '';
|
||||
final text = '${l10n.sureDelete(file.filename)}$dirText';
|
||||
final child = Text(text);
|
||||
context.showRoundDialog(
|
||||
child: child,
|
||||
title: Text(_s.attention),
|
||||
title: Text(l10n.attention),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
@@ -453,12 +450,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
} catch (e) {
|
||||
context.pop();
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.error),
|
||||
title: Text(l10n.error),
|
||||
child: Text(e.toString()),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -466,7 +463,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
}
|
||||
_listDir();
|
||||
},
|
||||
child: Text(_s.delete, style: UIs.textRed),
|
||||
child: Text(l10n.delete, style: UIs.textRed),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -476,27 +473,27 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.pop();
|
||||
final textController = TextEditingController();
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.createFolder),
|
||||
title: Text(l10n.createFolder),
|
||||
child: Input(
|
||||
autoFocus: true,
|
||||
icon: Icons.folder,
|
||||
controller: textController,
|
||||
label: _s.name,
|
||||
label: l10n.name,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (textController.text == '') {
|
||||
context.showRoundDialog(
|
||||
child: Text(_s.fieldMustNotEmpty),
|
||||
child: Text(l10n.fieldMustNotEmpty),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -507,7 +504,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.pop();
|
||||
_listDir();
|
||||
},
|
||||
child: Text(_s.ok, style: UIs.textRed),
|
||||
child: Text(l10n.ok, style: UIs.textRed),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -517,24 +514,24 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.pop();
|
||||
final textController = TextEditingController();
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.createFile),
|
||||
title: Text(l10n.createFile),
|
||||
child: Input(
|
||||
autoFocus: true,
|
||||
icon: Icons.insert_drive_file,
|
||||
controller: textController,
|
||||
label: _s.name,
|
||||
label: l10n.name,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (textController.text == '') {
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.attention),
|
||||
child: Text(_s.fieldMustNotEmpty),
|
||||
title: Text(l10n.attention),
|
||||
child: Text(l10n.fieldMustNotEmpty),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -547,7 +544,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.pop();
|
||||
_listDir();
|
||||
},
|
||||
child: Text(_s.ok, style: UIs.textRed),
|
||||
child: Text(l10n.ok, style: UIs.textRed),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -557,25 +554,25 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.pop();
|
||||
final textController = TextEditingController();
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.rename),
|
||||
title: Text(l10n.rename),
|
||||
child: Input(
|
||||
autoFocus: true,
|
||||
icon: Icons.abc,
|
||||
controller: textController,
|
||||
label: _s.name,
|
||||
label: l10n.name,
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => context.pop(), child: Text(_s.cancel)),
|
||||
TextButton(onPressed: () => context.pop(), child: Text(l10n.cancel)),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (textController.text == '') {
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.attention),
|
||||
child: Text(_s.fieldMustNotEmpty),
|
||||
title: Text(l10n.attention),
|
||||
child: Text(l10n.fieldMustNotEmpty),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -585,7 +582,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.pop();
|
||||
_listDir();
|
||||
},
|
||||
child: Text(_s.rename, style: UIs.textRed),
|
||||
child: Text(l10n.rename, style: UIs.textRed),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -597,12 +594,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
final cmd = _getDecompressCmd(absPath);
|
||||
if (cmd == null) {
|
||||
context.showRoundDialog(
|
||||
title: Text(_s.error),
|
||||
title: Text(l10n.error),
|
||||
child: Text('Unsupport file: ${name.filename}'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -664,12 +661,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 177),
|
||||
() => context.showRoundDialog(
|
||||
title: Text(_s.error),
|
||||
title: Text(l10n.error),
|
||||
child: Text(e.toString()),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/datetime.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
@@ -23,19 +23,11 @@ class SftpMissionPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: Text(_s.mission, style: UIs.textSize18),
|
||||
title: Text(l10n.mission, style: UIs.textSize18),
|
||||
),
|
||||
body: _buildBody(),
|
||||
);
|
||||
@@ -45,7 +37,7 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
return Consumer<SftpProvider>(builder: (__, pro, _) {
|
||||
if (pro.status.isEmpty) {
|
||||
return Center(
|
||||
child: Text(_s.noTask),
|
||||
child: Text(l10n.noTask),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
@@ -63,8 +55,8 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
switch (status.status) {
|
||||
case SftpWorkerStatus.finished:
|
||||
final time = status.spentTime.toString();
|
||||
final str = '${_s.finished} ${_s.spentTime(
|
||||
time == 'null' ? _s.unknown : (time.substring(0, time.length - 7)),
|
||||
final str = '${l10n.finished} ${l10n.spentTime(
|
||||
time == 'null' ? l10n.unknown : (time.substring(0, time.length - 7)),
|
||||
)}';
|
||||
return _wrapInCard(
|
||||
status: status,
|
||||
@@ -91,29 +83,29 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
final size = (status.size ?? 0).convertBytes;
|
||||
return _wrapInCard(
|
||||
status: status,
|
||||
subtitle: _s.percentOfSize(percentStr, size),
|
||||
subtitle: l10n.percentOfSize(percentStr, size),
|
||||
trailing: _buildDelete(status.fileName, status.id),
|
||||
);
|
||||
case SftpWorkerStatus.preparing:
|
||||
return _wrapInCard(
|
||||
status: status,
|
||||
subtitle: _s.sftpDlPrepare,
|
||||
subtitle: l10n.sftpDlPrepare,
|
||||
trailing: _buildDelete(status.fileName, status.id),
|
||||
);
|
||||
case SftpWorkerStatus.sshConnectted:
|
||||
return _wrapInCard(
|
||||
status: status,
|
||||
subtitle: _s.sftpSSHConnected,
|
||||
subtitle: l10n.sftpSSHConnected,
|
||||
trailing: _buildDelete(status.fileName, status.id),
|
||||
);
|
||||
default:
|
||||
return _wrapInCard(
|
||||
status: status,
|
||||
subtitle: _s.unknown,
|
||||
subtitle: l10n.unknown,
|
||||
trailing: IconButton(
|
||||
onPressed: () => context.showRoundDialog(
|
||||
title: Text(_s.error),
|
||||
child: Text((status.error ?? _s.unknown).toString()),
|
||||
title: Text(l10n.error),
|
||||
child: Text((status.error ?? l10n.unknown).toString()),
|
||||
),
|
||||
icon: const Icon(Icons.error),
|
||||
),
|
||||
@@ -144,15 +136,15 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
Widget _buildDelete(String name, int id) {
|
||||
return IconButton(
|
||||
onPressed: () => context.showRoundDialog(
|
||||
title: Text(_s.attention),
|
||||
child: Text(_s.sureDelete(name)),
|
||||
title: Text(l10n.attention),
|
||||
child: Text(l10n.sureDelete(name)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Providers.sftp.cancel(id);
|
||||
context.pop();
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
]),
|
||||
icon: const Icon(Icons.delete),
|
||||
|
||||
Reference in New Issue
Block a user