extract op buttons and remove unused widget
This commit is contained in:
parent
e86324fa55
commit
78b2b79d3c
3 changed files with 121 additions and 185 deletions
|
@ -6,6 +6,8 @@ import 'package:file_selector/file_selector.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:fluxcloud/sftp_worker.dart';
|
||||
|
||||
import 'widgets/operation_buttons.dart';
|
||||
|
||||
class SftpExplorer extends StatefulWidget {
|
||||
const SftpExplorer({super.key, required this.sftpWorker});
|
||||
|
||||
|
@ -122,108 +124,7 @@ class _SftpExplorerState extends State<SftpExplorer> {
|
|||
return ListTile(
|
||||
leading: Icon(dirEntry.attr.isDirectory ? Icons.folder : Icons.description),
|
||||
title: Text(dirEntry.filename),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
icon: Icon(Icons.drive_file_move)
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
icon: Icon(Icons.copy)
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
final newNameController = TextEditingController(text: dirEntry.filename);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Rename'),
|
||||
content: TextField(
|
||||
controller: newNameController,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Enter new name'
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancel')),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
// try {
|
||||
// await widget.sftpWorker.rename('${path}${dirEntry.filename}', '${widget.path}${newNameController.text}');
|
||||
// _listDir();
|
||||
// }
|
||||
// on SftpStatusError catch (e) {
|
||||
// if (context.mounted) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(_buildErrorSnackBar(context, e.message));
|
||||
// }
|
||||
// }
|
||||
// if (context.mounted) {
|
||||
// Navigator.pop(context);
|
||||
// }
|
||||
//
|
||||
},
|
||||
child: Text('Rename')
|
||||
),
|
||||
|
||||
],
|
||||
)
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.drive_file_rename_outline)
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Delete Permanently?'),
|
||||
content: Text(dirEntry.attr.isDirectory ? 'The contents of this folder will be deleted as well\nThis action cannot be undone' : 'This action cannot be undone'),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancel')),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
// if (dirEntry.attr.isDirectory) {
|
||||
// Future<void> removeRecursively (String path) async {
|
||||
// final dirContents = await widget.sftpWorker.listdir(path);
|
||||
// for (SftpName entry in dirContents) {
|
||||
// final fullPath = '$path${entry.filename}';
|
||||
// if (entry.attr.isDirectory) {
|
||||
// await removeRecursively('$fullPath/');
|
||||
// await widget.sftpWorker.rmdir('$fullPath/');
|
||||
// }
|
||||
// else {
|
||||
// await widget.sftpWorker.remove(fullPath);
|
||||
// }
|
||||
// }
|
||||
// await widget.sftpWorker.rmdir(path);
|
||||
// }
|
||||
// await removeRecursively('${path}${dirEntry.filename}/');
|
||||
// }
|
||||
// else {
|
||||
// await widget.sftpWorker.remove('${path}${dirEntry.filename}');
|
||||
// }
|
||||
// _listDir();
|
||||
// if (context.mounted) {
|
||||
// Navigator.pop(context);
|
||||
// }
|
||||
},
|
||||
child: Text('Yes')
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.delete)
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: OperationButtons(dirEntry: dirEntry),
|
||||
onTap: () {
|
||||
if (dirEntry.attr.isDirectory) {
|
||||
path = '$path${dirEntry.filename}/';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue