Compare commits
No commits in common. "3f12b14e8a4cec4ccf7bdbbb4d3aadb184a6b8f2" and "045d0694e7da58e0426e121dcacd245a41d7b695" have entirely different histories.
3f12b14e8a
...
045d0694e7
4 changed files with 31 additions and 59 deletions
|
@ -28,17 +28,3 @@ class MainApp extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SnackBar buildErrorSnackBar(BuildContext context, String error) {
|
|
||||||
return SnackBar(
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
content: Row(
|
|
||||||
spacing: 10,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.error, color: Colors.red,),
|
|
||||||
Text(error, style: TextStyle(color: Theme.of(context).colorScheme.onSecondaryContainer),),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import 'package:dartssh2/dartssh2.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:file_selector/file_selector.dart';
|
import 'package:file_selector/file_selector.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fluxcloud/main.dart';
|
|
||||||
import 'package:fluxcloud/sftp_worker.dart';
|
import 'package:fluxcloud/sftp_worker.dart';
|
||||||
|
|
||||||
import 'widgets/operation_buttons.dart';
|
import 'widgets/operation_buttons.dart';
|
||||||
|
@ -40,7 +39,7 @@ class _SftpExplorerState extends State<SftpExplorer> {
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(buildErrorSnackBar(context, e.toString()));
|
ScaffoldMessenger.of(context).showSnackBar(_buildErrorSnackBar(context, e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
|
@ -169,7 +168,7 @@ class _SftpExplorerState extends State<SftpExplorer> {
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(buildErrorSnackBar(context, e.toString()));
|
ScaffoldMessenger.of(context).showSnackBar(_buildErrorSnackBar(context, e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
|
@ -203,7 +202,7 @@ class _SftpExplorerState extends State<SftpExplorer> {
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(buildErrorSnackBar(context, e.toString()));
|
ScaffoldMessenger.of(context).showSnackBar(_buildErrorSnackBar(context, e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setState(() => _progress = null);
|
setState(() => _progress = null);
|
||||||
|
@ -215,4 +214,17 @@ class _SftpExplorerState extends State<SftpExplorer> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SnackBar _buildErrorSnackBar(BuildContext context, String error) {
|
||||||
|
return SnackBar(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
content: Row(
|
||||||
|
spacing: 10,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.error, color: Colors.red,),
|
||||||
|
Text(error, style: TextStyle(color: Theme.of(context).colorScheme.onSecondaryContainer),),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,6 @@ class Remove extends SftpCommand {
|
||||||
Remove(this.dirEntry, this.path);
|
Remove(this.dirEntry, this.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Rename extends SftpCommand {
|
|
||||||
final String oldpath;
|
|
||||||
final String newpath;
|
|
||||||
|
|
||||||
Rename(this.oldpath, this.newpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SftpWorker {
|
class SftpWorker {
|
||||||
|
|
||||||
|
@ -170,15 +163,7 @@ class SftpWorker {
|
||||||
}
|
}
|
||||||
sendPort.send((id, 0));
|
sendPort.send((id, 0));
|
||||||
}
|
}
|
||||||
on SftpStatusError catch (e) {
|
on SftpStatusError catch (e) {
|
||||||
sendPort.send((id, RemoteError(e.message, '')));
|
|
||||||
}
|
|
||||||
case Rename(:final oldpath, :final newpath):
|
|
||||||
try {
|
|
||||||
await sftpClient.rename(oldpath, newpath);
|
|
||||||
sendPort.send((id, 0));
|
|
||||||
}
|
|
||||||
on SftpStatusError catch (e) {
|
|
||||||
sendPort.send((id, RemoteError(e.message, '')));
|
sendPort.send((id, RemoteError(e.message, '')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,12 +232,4 @@ class SftpWorker {
|
||||||
await completer.future;
|
await completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> rename(String oldpath, String newpath) async {
|
|
||||||
final completer = Completer.sync();
|
|
||||||
final id = _idCounter++;
|
|
||||||
_activeRequests[id] = completer;
|
|
||||||
_commands.send((id, Rename(oldpath, newpath)));
|
|
||||||
await completer.future;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'package:dartssh2/dartssh2.dart';
|
import 'package:dartssh2/dartssh2.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fluxcloud/main.dart';
|
|
||||||
import 'package:fluxcloud/sftp_worker.dart';
|
import 'package:fluxcloud/sftp_worker.dart';
|
||||||
|
|
||||||
class OperationButtons extends StatelessWidget {
|
class OperationButtons extends StatelessWidget {
|
||||||
|
@ -51,19 +50,19 @@ class OperationButtons extends StatelessWidget {
|
||||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancel')),
|
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancel')),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
try {
|
// try {
|
||||||
await sftpWorker.rename('$path${dirEntry.filename}', '$path${newNameController.text}');
|
// await sftpWorker.rename('${path}${dirEntry.filename}', '${widget.path}${newNameController.text}');
|
||||||
listDir();
|
// _listDir();
|
||||||
}
|
// }
|
||||||
on SftpStatusError catch (e) {
|
// on SftpStatusError catch (e) {
|
||||||
if (context.mounted) {
|
// if (context.mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(buildErrorSnackBar(context, e.message));
|
// ScaffoldMessenger.of(context).showSnackBar(_buildErrorSnackBar(context, e.message));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (context.mounted) {
|
// if (context.mounted) {
|
||||||
Navigator.pop(context);
|
// Navigator.pop(context);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
},
|
},
|
||||||
child: Text('Rename')
|
child: Text('Rename')
|
||||||
),
|
),
|
||||||
|
@ -98,9 +97,7 @@ class OperationButtons extends StatelessWidget {
|
||||||
await sftpWorker.remove(dirEntry, path);
|
await sftpWorker.remove(dirEntry, path);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (context.mounted) {
|
print(e.toString());
|
||||||
ScaffoldMessenger.of(context).showSnackBar(buildErrorSnackBar(context, e.toString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
listDir();
|
listDir();
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue