mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
SFTP init.
This commit is contained in:
@@ -15,7 +15,7 @@ class MenuItems {
|
||||
static const List<MenuItem> secondItems = [edit];
|
||||
|
||||
static const ssh = MenuItem(text: 'SSH', icon: Icons.link);
|
||||
static const sftp = MenuItem(text: 'SFTP', icon: Icons.file_present);
|
||||
static const sftp = MenuItem(text: 'SFTP', icon: Icons.insert_drive_file);
|
||||
static const snippet = MenuItem(text: 'Snippet', icon: Icons.label);
|
||||
static const apt = MenuItem(text: 'Apt', icon: Icons.system_security_update);
|
||||
static const edit = MenuItem(text: 'Edit', icon: Icons.edit);
|
||||
|
||||
29
lib/data/model/sftp/absolute_path.dart
Normal file
29
lib/data/model/sftp/absolute_path.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
class AbsolutePath {
|
||||
String path;
|
||||
String? _prePath;
|
||||
AbsolutePath(this.path);
|
||||
|
||||
void update(String newPath) {
|
||||
_prePath = path;
|
||||
if (newPath == '..') {
|
||||
path = path.substring(0, path.lastIndexOf('/'));
|
||||
if (path == '') {
|
||||
path = '/';
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (newPath == '/') {
|
||||
path = '/';
|
||||
return;
|
||||
}
|
||||
path = path + (path.endsWith('/') ? '' : '/') + newPath;
|
||||
}
|
||||
|
||||
bool undo() {
|
||||
if (_prePath == null) {
|
||||
return false;
|
||||
}
|
||||
path = _prePath!;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
39
lib/data/model/sftp/sftp_side_status.dart
Normal file
39
lib/data/model/sftp/sftp_side_status.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/sftp/absolute_path.dart';
|
||||
|
||||
class SFTPSideViewStatus {
|
||||
bool leftSelected = false;
|
||||
bool rightSelected = false;
|
||||
ServerPrivateInfo? leftSpi;
|
||||
ServerPrivateInfo? rightSpi;
|
||||
List<SftpName>? leftFiles;
|
||||
List<SftpName>? rightFiles;
|
||||
AbsolutePath? leftPath;
|
||||
AbsolutePath? rightPath;
|
||||
SftpClient? leftClient;
|
||||
SftpClient? rightClient;
|
||||
|
||||
SFTPSideViewStatus();
|
||||
|
||||
ServerPrivateInfo? spi(bool left) => left ? leftSpi : rightSpi;
|
||||
void setSpi(bool left, ServerPrivateInfo nSpi) =>
|
||||
left ? leftSpi = nSpi : rightSpi = nSpi;
|
||||
|
||||
/// Whether the Left/Right Destination is selected.
|
||||
bool selected(bool left) => left ? leftSelected : rightSelected;
|
||||
void setSelect(bool left, bool nSelect) =>
|
||||
left ? leftSelected = nSelect : rightSelected = nSelect;
|
||||
|
||||
List<SftpName>? files(bool left) => left ? leftFiles : rightFiles;
|
||||
void setFiles(bool left, List<SftpName>? nFiles) =>
|
||||
left ? leftFiles = nFiles : rightFiles = nFiles;
|
||||
|
||||
AbsolutePath? path(bool left) => left ? leftPath : rightPath;
|
||||
void setPath(bool left, AbsolutePath? nPath) =>
|
||||
left ? leftPath = nPath : rightPath = nPath;
|
||||
|
||||
SftpClient? client(bool left) => left ? leftClient : rightClient;
|
||||
void setClient(bool left, SftpClient? nClient) =>
|
||||
left ? leftClient = nClient : rightClient = nClient;
|
||||
}
|
||||
Reference in New Issue
Block a user