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

@@ -23,8 +23,7 @@ class SFTPDownloadedPage extends StatefulWidget {
class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
PathWithPrefix? _path;
String? _prefixPath;
late S s;
late ThemeData _theme;
late S _s;
@override
void initState() {
@@ -39,15 +38,14 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
s = S.of(context);
_theme = Theme.of(context);
_s = S.of(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(s.download),
title: Text(_s.download),
actions: [
IconButton(
icon: const Icon(Icons.downloading),
@@ -68,7 +66,7 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
floatingActionButton: FloatingActionButton(
onPressed: (() {
if (_path!.path == _prefixPath) {
showSnackBar(context, Text(s.alreadyLastDir));
showSnackBar(context, Text(_s.alreadyLastDir));
return;
}
_path!.update('..');
@@ -80,18 +78,13 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
}
Widget _buildPath() {
final color = _theme.scaffoldBackgroundColor;
return Container(
color: color,
padding: const EdgeInsets.fromLTRB(11, 7, 11, 11),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Divider(),
(_path?.path ?? s.loadingFiles).omitStartStr(
style: TextStyle(
color: color.isBrightColor ? Colors.black : Colors.white),
)
(_path?.path ?? _s.loadingFiles).omitStartStr(),
],
),
);
@@ -142,30 +135,30 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
final fileName = file.path.split('/').last;
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: () {
Navigator.of(context).pop();
showRoundDialog(
context,
s.sureDelete(fileName),
_s.sureDelete(fileName),
const SizedBox(),
[
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.cancel)),
child: Text(_s.cancel)),
TextButton(
onPressed: () {
file.deleteSync();
setState(() {});
Navigator.of(context).pop();
},
child: Text(s.ok),
child: Text(_s.ok),
),
],
);
@@ -173,7 +166,7 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
),
ListTile(
leading: const Icon(Icons.open_in_new),
title: Text(s.open),
title: Text(_s.open),
onTap: () {
shareFiles(context, [file.absolute.path]);
},
@@ -183,7 +176,7 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
[
TextButton(
onPressed: (() => Navigator.of(context).pop()),
child: Text(s.close))
child: Text(_s.close))
],
);
}