fix: can't quit app

This commit is contained in:
LollipopKit
2022-12-20 13:40:48 +08:00
parent cfd28c3009
commit 6bda94bd7b
17 changed files with 353 additions and 380 deletions

View File

@@ -35,13 +35,13 @@ class _SFTPPageState extends State<SFTPPage> {
final ScrollController _scrollController = ScrollController();
late MediaQueryData _media;
late S s;
late S _s;
@override
void didChangeDependencies() {
super.didChangeDependencies();
_media = MediaQuery.of(context);
s = S.of(context);
_s = S.of(context);
}
@override
@@ -61,24 +61,24 @@ class _SFTPPageState extends State<SFTPPage> {
IconButton(
onPressed: (() => showRoundDialog(
context,
s.choose,
_s.choose,
Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.folder),
title: Text(s.createFolder),
title: Text(_s.createFolder),
onTap: () => mkdir(context)),
ListTile(
leading: const Icon(Icons.insert_drive_file),
title: Text(s.createFile),
title: Text(_s.createFile),
onTap: () => newFile(context)),
],
),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.close))
child: Text(_s.close))
],
)),
icon: const Icon(Icons.add),
@@ -167,24 +167,24 @@ class _SFTPPageState extends State<SFTPPage> {
void onItemPress(BuildContext context, SftpName file, bool showDownload) {
showRoundDialog(
context,
s.choose,
_s.choose,
Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.delete),
title: Text(s.delete),
title: Text(_s.delete),
onTap: () => delete(context, file),
),
ListTile(
leading: const Icon(Icons.edit),
title: Text(s.rename),
title: Text(_s.rename),
onTap: () => rename(context, file),
),
showDownload
? ListTile(
leading: const Icon(Icons.download),
title: Text(s.download),
title: Text(_s.download),
onTap: () => download(context, file),
)
: const SizedBox()
@@ -192,7 +192,8 @@ class _SFTPPageState extends State<SFTPPage> {
),
[
TextButton(
onPressed: () => Navigator.of(context).pop(), child: Text(s.cancel))
onPressed: () => Navigator.of(context).pop(),
child: Text(_s.cancel))
],
);
}
@@ -200,12 +201,12 @@ class _SFTPPageState extends State<SFTPPage> {
void download(BuildContext context, SftpName name) {
showRoundDialog(
context,
s.download,
Text('${s.dl2Local(name.filename)}\n${s.keepForeground}'),
_s.download,
Text('${_s.dl2Local(name.filename)}\n${_s.keepForeground}'),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.cancel)),
child: Text(_s.cancel)),
TextButton(
onPressed: () async {
Navigator.of(context).pop();
@@ -229,12 +230,12 @@ class _SFTPPageState extends State<SFTPPage> {
Navigator.of(context).pop();
showRoundDialog(
context,
s.goSftpDlPage,
_s.goSftpDlPage,
const SizedBox(),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.cancel),
child: Text(_s.cancel),
),
TextButton(
onPressed: () {
@@ -242,12 +243,12 @@ class _SFTPPageState extends State<SFTPPage> {
AppRoute(const SFTPDownloadingPage(), 'sftp downloading')
.go(context);
},
child: Text(s.ok),
child: Text(_s.ok),
)
],
);
},
child: Text(s.download),
child: Text(_s.download),
)
],
);
@@ -257,8 +258,8 @@ class _SFTPPageState extends State<SFTPPage> {
Navigator.of(context).pop();
showRoundDialog(
context,
s.attention,
Text(s.sureDelete(file.filename)),
_s.attention,
Text(_s.sureDelete(file.filename)),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
@@ -270,7 +271,7 @@ class _SFTPPageState extends State<SFTPPage> {
listDir();
},
child: Text(
s.delete,
_s.delete,
style: const TextStyle(color: Colors.red),
),
),
@@ -283,29 +284,29 @@ class _SFTPPageState extends State<SFTPPage> {
final textController = TextEditingController();
showRoundDialog(
context,
s.createFolder,
_s.createFolder,
TextField(
controller: textController,
decoration: InputDecoration(
labelText: s.name,
labelText: _s.name,
),
),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.cancel),
child: Text(_s.cancel),
),
TextButton(
onPressed: () {
if (textController.text == '') {
showRoundDialog(
context,
s.attention,
Text(s.fieldMustNotEmpty),
_s.attention,
Text(_s.fieldMustNotEmpty),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.ok)),
child: Text(_s.ok)),
],
);
return;
@@ -316,7 +317,7 @@ class _SFTPPageState extends State<SFTPPage> {
listDir();
},
child: Text(
s.ok,
_s.ok,
style: const TextStyle(color: Colors.red),
),
),
@@ -329,29 +330,29 @@ class _SFTPPageState extends State<SFTPPage> {
final textController = TextEditingController();
showRoundDialog(
context,
s.createFile,
_s.createFile,
TextField(
controller: textController,
decoration: InputDecoration(
labelText: s.name,
labelText: _s.name,
),
),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.cancel),
child: Text(_s.cancel),
),
TextButton(
onPressed: () async {
if (textController.text == '') {
showRoundDialog(
context,
s.attention,
Text(s.fieldMustNotEmpty),
_s.attention,
Text(_s.fieldMustNotEmpty),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.ok),
child: Text(_s.ok),
),
],
);
@@ -364,7 +365,7 @@ class _SFTPPageState extends State<SFTPPage> {
listDir();
},
child: Text(
s.ok,
_s.ok,
style: const TextStyle(color: Colors.red),
),
),
@@ -377,28 +378,28 @@ class _SFTPPageState extends State<SFTPPage> {
final textController = TextEditingController();
showRoundDialog(
context,
s.rename,
_s.rename,
TextField(
controller: textController,
decoration: InputDecoration(
labelText: s.name,
labelText: _s.name,
),
),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.cancel)),
child: Text(_s.cancel)),
TextButton(
onPressed: () async {
if (textController.text == '') {
showRoundDialog(
context,
s.attention,
Text(s.fieldMustNotEmpty),
_s.attention,
Text(_s.fieldMustNotEmpty),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.ok),
child: Text(_s.ok),
),
],
);
@@ -409,7 +410,7 @@ class _SFTPPageState extends State<SFTPPage> {
listDir();
},
child: Text(
s.rename,
_s.rename,
style: const TextStyle(color: Colors.red),
),
),
@@ -440,12 +441,12 @@ class _SFTPPageState extends State<SFTPPage> {
} catch (e) {
await showRoundDialog(
context,
s.error,
_s.error,
Text(e.toString()),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.ok),
child: Text(_s.ok),
)
],
);
@@ -458,7 +459,7 @@ class _SFTPPageState extends State<SFTPPage> {
Widget _buildDestSelector() {
final str = _status.path?.path;
return ExpansionTile(
title: Text(_status.spi?.name ?? s.chooseDestination),
title: Text(_status.spi?.name ?? _s.chooseDestination),
subtitle: _status.selected
? str!.omitStartStr(style: const TextStyle(color: Colors.grey))
: null,