From 6b8fc6efe9c74ac3ebcc3fd52330610a5d612e10 Mon Sep 17 00:00:00 2001 From: Kingtous Date: Fri, 1 Jul 2022 12:08:52 +0800 Subject: [PATCH] add: file transfer status list like sciter --- .../lib/desktop/pages/file_manager_page.dart | 24 ++++++--- flutter/lib/models/file_model.dart | 49 +++++++++++++------ 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/flutter/lib/desktop/pages/file_manager_page.dart b/flutter/lib/desktop/pages/file_manager_page.dart index ed4a32b37..241a416e5 100644 --- a/flutter/lib/desktop/pages/file_manager_page.dart +++ b/flutter/lib/desktop/pages/file_manager_page.dart @@ -73,8 +73,9 @@ class _FileManagerPageState extends State backgroundColor: MyTheme.grayBg, body: Row( children: [ - Flexible(flex: 1, child: body(isLocal: true)), - Flexible(flex: 1, child: body(isLocal: false)) + Flexible(flex: 3, child: body(isLocal: true)), + Flexible(flex: 3, child: body(isLocal: false)), + Flexible(flex: 2, child: statusList()) ], ), bottomSheet: bottomSheet(), @@ -198,7 +199,7 @@ class _FileManagerPageState extends State itemCount: entries.length + 1, itemBuilder: (context, index) { if (index >= entries.length) { - return listTail(); + return listTail(isLocal: isLocal); } var selected = false; if (model.selectMode) { @@ -297,6 +298,16 @@ class _FileManagerPageState extends State ]); } + /// transfer status list + /// watch transfer status + Widget statusList() { + return PreferredSize(child: Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.white70) + ), + ), preferredSize: Size(200, double.infinity)); + } + goBack({bool? isLocal}) { model.goToParentDirectory(isLocal: isLocal); } @@ -362,7 +373,8 @@ class _FileManagerPageState extends State ], )); - Widget listTail() { + Widget listTail({bool isLocal = false}) { + final dir = isLocal ? model.currentLocalDir : model.currentRemoteDir; return Container( height: 100, child: Column( @@ -370,14 +382,14 @@ class _FileManagerPageState extends State Padding( padding: EdgeInsets.fromLTRB(30, 5, 30, 0), child: Text( - model.currentDir.path, + dir.path, style: TextStyle(color: MyTheme.darkGray), ), ), Padding( padding: EdgeInsets.all(2), child: Text( - "${translate("Total")}: ${model.currentDir.entries.length} ${translate("items")}", + "${translate("Total")}: ${dir.entries.length} ${translate("items")}", style: TextStyle(color: MyTheme.darkGray), ), ) diff --git a/flutter/lib/models/file_model.dart b/flutter/lib/models/file_model.dart index adb44286d..1aecb41e3 100644 --- a/flutter/lib/models/file_model.dart +++ b/flutter/lib/models/file_model.dart @@ -276,23 +276,40 @@ class FileModel extends ChangeNotifier { openDirectory(parent, isLocal: isLocal); } - sendFiles(SelectedItems items) { - if (items.isLocal == null) { - debugPrint("Failed to sendFiles ,wrong path state"); - return; + /// isRemote only for desktop now, [isRemote == true] means [remote -> local] + sendFiles(SelectedItems items, {bool isRemote = false}) { + if (isDesktop) { + // desktop sendFiles + _jobProgress.state = JobState.inProgress; + final toPath = + isRemote ? currentRemoteDir.path : currentLocalDir.path; + final isWindows = + isRemote ? _localOption.isWindows : _remoteOption.isWindows; + final showHidden = + isRemote ? _localOption.showHidden : _remoteOption.showHidden ; + items.items.forEach((from) async { + _jobId++; + await _ffi.target?.bind.sessionSendFiles(id: '${_ffi.target?.id}', actId: _jobId, path: from.path, to: PathUtil.join(toPath, from.name, isWindows) + ,fileNum: 0, includeHidden: showHidden, isRemote: isRemote); + }); + } else { + if (items.isLocal == null) { + debugPrint("Failed to sendFiles ,wrong path state"); + return; + } + _jobProgress.state = JobState.inProgress; + final toPath = + items.isLocal! ? currentRemoteDir.path : currentLocalDir.path; + final isWindows = + items.isLocal! ? _localOption.isWindows : _remoteOption.isWindows; + final showHidden = + items.isLocal! ? _localOption.showHidden : _remoteOption.showHidden; + items.items.forEach((from) async { + _jobId++; + await _ffi.target?.bind.sessionSendFiles(id: '${_ffi.target?.getId()}', actId: _jobId, path: from.path, to: PathUtil.join(toPath, from.name, isWindows) + ,fileNum: 0, includeHidden: showHidden, isRemote: !(items.isLocal!)); + }); } - _jobProgress.state = JobState.inProgress; - final toPath = - items.isLocal! ? currentRemoteDir.path : currentLocalDir.path; - final isWindows = - items.isLocal! ? _localOption.isWindows : _remoteOption.isWindows; - final showHidden = - items.isLocal! ? _localOption.showHidden : _remoteOption.showHidden; - items.items.forEach((from) async { - _jobId++; - await _ffi.target?.bind.sessionSendFiles(id: '${_ffi.target?.getId()}', actId: _jobId, path: from.path, to: PathUtil.join(toPath, from.name, isWindows) - ,fileNum: 0, includeHidden: showHidden, isRemote: !(items.isLocal!)); - }); } bool removeCheckboxRemember = false;