make copy work, also some abstraction and new provider
This commit is contained in:
parent
a66ed70532
commit
869f2c14c3
6 changed files with 145 additions and 107 deletions
41
lib/providers/sftp_provider.dart
Normal file
41
lib/providers/sftp_provider.dart
Normal file
|
@ -0,0 +1,41 @@
|
|||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluxcloud/sftp_worker.dart';
|
||||
|
||||
class SftpProvider extends ChangeNotifier {
|
||||
final SftpWorker _sftpWorker;
|
||||
|
||||
String _path = '/';
|
||||
bool _isLoading = false;
|
||||
late List<SftpName> _dirContents;
|
||||
|
||||
SftpProvider(this._sftpWorker) {
|
||||
listDir();
|
||||
}
|
||||
|
||||
SftpWorker get sftpWorker => _sftpWorker;
|
||||
|
||||
String get path => _path;
|
||||
bool get isLoading => _isLoading;
|
||||
List<SftpName> get dirContents => _dirContents;
|
||||
|
||||
Future<void> listDir() async {
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
_dirContents = await _sftpWorker.listdir(_path);
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void goToPrevDir() {
|
||||
_path = _path.substring(0, _path.length - 1);
|
||||
_path = _path.substring(0, _path.lastIndexOf('/')+1);
|
||||
listDir();
|
||||
}
|
||||
|
||||
void goToDir(String path) {
|
||||
_path = path;
|
||||
listDir();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue