From b0c3cd3834d51fb1274c5b14944d48cfd31d2c7e Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Sat, 7 May 2022 23:05:31 +0800 Subject: [PATCH] fix & optimize - fix downloading page unbond size - auto dispose isolate --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/data/model/sftp/download_status.dart | 3 +++ lib/data/model/sftp/download_worker.dart | 4 ++++ lib/data/res/build_data.dart | 4 ++-- lib/view/page/sftp/downloading.dart | 8 ++++---- lib/view/page/sftp/view.dart | 8 ++++++-- lib/view/widget/center_loading.dart | 2 ++ 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 4be13256..283b04ed 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -354,7 +354,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 127; + CURRENT_PROJECT_VERSION = 128; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -362,7 +362,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.127; + MARKETING_VERSION = 1.0.128; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -484,7 +484,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 127; + CURRENT_PROJECT_VERSION = 128; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -492,7 +492,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.127; + MARKETING_VERSION = 1.0.128; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -508,7 +508,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 127; + CURRENT_PROJECT_VERSION = 128; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -516,7 +516,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.127; + MARKETING_VERSION = 1.0.128; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/model/sftp/download_status.dart b/lib/data/model/sftp/download_status.dart index 53ac0b52..1733d345 100644 --- a/lib/data/model/sftp/download_status.dart +++ b/lib/data/model/sftp/download_status.dart @@ -33,6 +33,9 @@ class SftpDownloadStatus { switch (event.runtimeType) { case SftpWorkerStatus: status = event; + if (status == SftpWorkerStatus.finished) { + worker.dispose(); + } break; case double: progress = event; diff --git a/lib/data/model/sftp/download_worker.dart b/lib/data/model/sftp/download_worker.dart index d991d8f9..a1380bee 100644 --- a/lib/data/model/sftp/download_worker.dart +++ b/lib/data/model/sftp/download_worker.dart @@ -24,6 +24,10 @@ class SftpDownloadWorker { final worker = Worker(); final String? privateKey; + void dispose() { + worker.dispose(); + } + /// Initiate the worker (new thread) and start listen from messages between /// the threads Future init() async { diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 9ffcb91e..0f2e9a49 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 127; + static const int build = 128; static const String engine = "Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 5464c5bac7 (3 weeks ago) • 2022-04-18 09:55:37 -0700\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n"; - static const String buildAt = "2022-05-07 22:16:13.513462"; + static const String buildAt = "2022-05-07 22:36:43.297250"; static const int modifications = 1; } diff --git a/lib/view/page/sftp/downloading.dart b/lib/view/page/sftp/downloading.dart index b19372b1..cac21fbe 100644 --- a/lib/view/page/sftp/downloading.dart +++ b/lib/view/page/sftp/downloading.dart @@ -47,7 +47,7 @@ class _SFTPDownloadingPageState extends State { ); } return ListView.builder( - padding: const EdgeInsets.all(13), + padding: const EdgeInsets.all(11), itemCount: pro.status.length, itemBuilder: (context, index) { final status = pro.status[index]; @@ -78,7 +78,7 @@ class _SFTPDownloadingPageState extends State { switch (status.status) { case SftpWorkerStatus.finished: return _wrapInCard(status, - '${s.downloadFinished}, ${s.spentTime(status.spentTime ?? s.unknown)}', + '${s.downloadFinished} ${s.spentTime(status.spentTime ?? s.unknown)}', trailing: IconButton( onPressed: () => Share.shareFiles([status.item.localPath], text: '${status.fileName} from ServerBox'), @@ -91,9 +91,9 @@ class _SFTPDownloadingPageState extends State { trailing: CircularProgressIndicator(value: (status.progress ?? 0) / 100)); case SftpWorkerStatus.preparing: - return _wrapInCard(status, s.sftpDlPrepare, trailing: centerLoading); + return _wrapInCard(status, s.sftpDlPrepare, trailing: loadingIcon); case SftpWorkerStatus.sshConnectted: - return _wrapInCard(status, s.sftpSSHConnected, trailing: centerLoading); + return _wrapInCard(status, s.sftpSSHConnected, trailing: loadingIcon); default: return _wrapInCard(status, s.unknown, trailing: const Icon( diff --git a/lib/view/page/sftp/view.dart b/lib/view/page/sftp/view.dart index a487ba9a..11b8ca36 100644 --- a/lib/view/page/sftp/view.dart +++ b/lib/view/page/sftp/view.dart @@ -211,13 +211,17 @@ class _SFTPPageState extends State { key: pubKeyId == null ? null : locator().get(pubKeyId).privateKey); + Navigator.of(context).pop(); showRoundDialog(context, s.goSftpDlPage, const SizedBox(), [ TextButton( onPressed: () => Navigator.of(context).pop(), child: Text(s.cancel)), TextButton( - onPressed: () => - AppRoute(const SFTPDownloadingPage(), 'sftp downloading'), + onPressed: () { + Navigator.of(context).pop(); + AppRoute(const SFTPDownloadingPage(), 'sftp downloading') + .go(context); + }, child: Text(s.ok)) ]); }, diff --git a/lib/view/widget/center_loading.dart b/lib/view/widget/center_loading.dart index 49db55ae..c7599cea 100644 --- a/lib/view/widget/center_loading.dart +++ b/lib/view/widget/center_loading.dart @@ -9,3 +9,5 @@ const centerSizedLoading = SizedBox( child: CircularProgressIndicator(), ), ); + +final loadingIcon = IconButton(onPressed: () {}, icon: centerLoading);