fix: sftp dl

This commit is contained in:
lollipopkit
2023-07-28 19:08:34 +08:00
parent 6803e9fa40
commit 6045e7e7f0
22 changed files with 137 additions and 116 deletions

View File

@@ -103,7 +103,9 @@ class _EditorPageState extends State<EditorPage> with AfterLayoutMixin {
),
child: SingleChildScrollView(
child: CodeTheme(
data: CodeThemeData(styles: _codeTheme ?? (isDarkMode(context) ? monokaiTheme : a11yLightTheme)),
data: CodeThemeData(
styles: _codeTheme ??
(isDarkMode(context) ? monokaiTheme : a11yLightTheme)),
child: CodeField(
focusNode: _focusNode,
controller: _controller,

View File

@@ -280,10 +280,12 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
showSnackBar(context, Text(_s.fieldMustNotEmpty));
return;
}
locator<SftpProvider>().add(
SftpReqItem(spi, remotePath, file.absolute.path),
locator<SftpProvider>().add(SftpReq(
spi,
remotePath,
file.absolute.path,
SftpReqType.upload,
);
));
showSnackBar(context, Text(_s.added2List));
},
),

View File

@@ -79,7 +79,11 @@ class _SFTPDownloadingPageState extends State<SFTPDownloadingPage> {
Widget _buildItem(SftpReqStatus status) {
if (status.error != null) {
showSnackBar(context, Text(status.error.toString()));
final err = status.error.toString();
Future.delayed(
const Duration(milliseconds: 377),
() => showSnackBar(context, Text(err)),
);
status.error = null;
}
switch (status.status) {
@@ -92,7 +96,7 @@ class _SFTPDownloadingPageState extends State<SFTPDownloadingPage> {
status,
str,
trailing: IconButton(
onPressed: () => shareFiles(context, [status.item.localPath]),
onPressed: () => shareFiles(context, [status.req.localPath]),
icon: const Icon(Icons.open_in_new),
),
);
@@ -103,18 +107,35 @@ class _SFTPDownloadingPageState extends State<SFTPDownloadingPage> {
return _wrapInCard(
status,
_s.downloadStatus(percentStr, size),
trailing: CircularProgressIndicator(value: percent),
trailing: SizedBox(
height: 27,
width: 27,
child: CircularProgressIndicator(
value: percent,
),
)
);
case SftpWorkerStatus.preparing:
return _wrapInCard(status, _s.sftpDlPrepare, trailing: loadingIcon);
return _wrapInCard(
status,
_s.sftpDlPrepare,
trailing: _loading,
);
case SftpWorkerStatus.sshConnectted:
return _wrapInCard(status, _s.sftpSSHConnected, trailing: loadingIcon);
return _wrapInCard(
status,
_s.sftpSSHConnected,
trailing: _loading,
);
default:
return _wrapInCard(
status,
_s.unknown,
trailing: const Icon(Icons.error, size: 40),
trailing: const Icon(Icons.error),
);
}
}
}
const _loading =
SizedBox(height: 27, width: 27, child: CircularProgressIndicator());

View File

@@ -174,8 +174,12 @@ class _SFTPPageState extends State<SFTPPage> {
return;
}
_sftp.add(
SftpReqItem(widget.spi, remotePath, path),
SftpReqType.upload,
SftpReq(
widget.spi,
remotePath,
path,
SftpReqType.upload,
),
);
},
icon: const Icon(Icons.upload_file));
@@ -350,8 +354,13 @@ class _SFTPPageState extends State<SFTPPage> {
final remotePath = _getRemotePath(name);
final localPath = await _getLocalPath(remotePath);
final completer = Completer();
final req = SftpReqItem(widget.spi, remotePath, localPath);
_sftp.add(req, SftpReqType.download, completer: completer);
final req = SftpReq(
widget.spi,
remotePath,
localPath,
SftpReqType.download,
);
_sftp.add(req, completer: completer);
showRoundDialog(context: context, child: centerSizedLoading);
await completer.future;
context.pop();
@@ -361,7 +370,7 @@ class _SFTPPageState extends State<SFTPPage> {
'SFTP edit',
).go<String>(context);
if (result != null) {
_sftp.add(req, SftpReqType.upload);
_sftp.add(SftpReq(req.spi, remotePath, localPath, SftpReqType.upload));
}
}
@@ -381,12 +390,12 @@ class _SFTPPageState extends State<SFTPPage> {
final remotePath = _getRemotePath(name);
_sftp.add(
SftpReqItem(
SftpReq(
widget.spi,
remotePath,
await _getLocalPath(remotePath),
SftpReqType.download,
),
SftpReqType.download,
);
context.pop();