update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
113
.config/Code/User/History/-4a5cb082/3MJv.dart
Normal file
113
.config/Code/User/History/-4a5cb082/3MJv.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({this.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: key);
|
||||
|
||||
// final GlobalKey<_FileButtonState> globalKey;
|
||||
final Key? key;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/4ZPL.dart
Normal file
112
.config/Code/User/History/-4a5cb082/4ZPL.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/63jy.dart
Normal file
112
.config/Code/User/History/-4a5cb082/63jy.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
117
.config/Code/User/History/-4a5cb082/6snZ.dart
Normal file
117
.config/Code/User/History/-4a5cb082/6snZ.dart
Normal file
|
@ -0,0 +1,117 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
void updateState(){
|
||||
print('state change attempted');
|
||||
final state = createState();
|
||||
(state as _FileButtonState).setButton(false);
|
||||
}
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/73oR.dart
Normal file
112
.config/Code/User/History/-4a5cb082/73oR.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
174
.config/Code/User/History/-4a5cb082/81Ow.dart
Normal file
174
.config/Code/User/History/-4a5cb082/81Ow.dart
Normal file
|
@ -0,0 +1,174 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
|
||||
});
|
||||
|
||||
List<Widget> selected = List.empty();
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: _handleOption()
|
||||
);
|
||||
}
|
||||
}
|
173
.config/Code/User/History/-4a5cb082/9Uvn.dart
Normal file
173
.config/Code/User/History/-4a5cb082/9Uvn.dart
Normal file
|
@ -0,0 +1,173 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value, List<Widget> selected){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
for(var button in selected){
|
||||
|
||||
}
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/AA2d.dart
Normal file
112
.config/Code/User/History/-4a5cb082/AA2d.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/AoiA.dart
Normal file
112
.config/Code/User/History/-4a5cb082/AoiA.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/B7Uz.dart
Normal file
112
.config/Code/User/History/-4a5cb082/B7Uz.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
163
.config/Code/User/History/-4a5cb082/CuSW.dart
Normal file
163
.config/Code/User/History/-4a5cb082/CuSW.dart
Normal file
|
@ -0,0 +1,163 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value, List<Widget> selected){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
111
.config/Code/User/History/-4a5cb082/E0j7.dart
Normal file
111
.config/Code/User/History/-4a5cb082/E0j7.dart
Normal file
|
@ -0,0 +1,111 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
151
.config/Code/User/History/-4a5cb082/FbcU.dart
Normal file
151
.config/Code/User/History/-4a5cb082/FbcU.dart
Normal file
|
@ -0,0 +1,151 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: _handleOption
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/G6uC.dart
Normal file
112
.config/Code/User/History/-4a5cb082/G6uC.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
171
.config/Code/User/History/-4a5cb082/GAaP.dart
Normal file
171
.config/Code/User/History/-4a5cb082/GAaP.dart
Normal file
|
@ -0,0 +1,171 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value, List<Widget> selected){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/GGGe.dart
Normal file
112
.config/Code/User/History/-4a5cb082/GGGe.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/GTQL.dart
Normal file
112
.config/Code/User/History/-4a5cb082/GTQL.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/GfH9.dart
Normal file
113
.config/Code/User/History/-4a5cb082/GfH9.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/GfkF.dart
Normal file
112
.config/Code/User/History/-4a5cb082/GfkF.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
118
.config/Code/User/History/-4a5cb082/KBYP.dart
Normal file
118
.config/Code/User/History/-4a5cb082/KBYP.dart
Normal file
|
@ -0,0 +1,118 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
void updateState(){
|
||||
print('state change attempted');
|
||||
final state = createState();
|
||||
(state as _FileButtonState).setButton(false);
|
||||
}
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/KWAD.dart
Normal file
113
.config/Code/User/History/-4a5cb082/KWAD.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final Key key;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
116
.config/Code/User/History/-4a5cb082/MRzI.dart
Normal file
116
.config/Code/User/History/-4a5cb082/MRzI.dart
Normal file
|
@ -0,0 +1,116 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
void updateState(){
|
||||
final state = createState();
|
||||
(state as _FileButtonState).setButton(false);
|
||||
}
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
116
.config/Code/User/History/-4a5cb082/MopS.dart
Normal file
116
.config/Code/User/History/-4a5cb082/MopS.dart
Normal file
|
@ -0,0 +1,116 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
void updateState(){
|
||||
final state = createState();
|
||||
(state as _FileButtonState).setButton(false);
|
||||
}
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/OP1F.dart
Normal file
112
.config/Code/User/History/-4a5cb082/OP1F.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/PTbr.dart
Normal file
112
.config/Code/User/History/-4a5cb082/PTbr.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/QGkc.dart
Normal file
112
.config/Code/User/History/-4a5cb082/QGkc.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/TKos.dart
Normal file
113
.config/Code/User/History/-4a5cb082/TKos.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/VPbA.dart
Normal file
113
.config/Code/User/History/-4a5cb082/VPbA.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/VRr5.dart
Normal file
113
.config/Code/User/History/-4a5cb082/VRr5.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
174
.config/Code/User/History/-4a5cb082/Vh7r.dart
Normal file
174
.config/Code/User/History/-4a5cb082/Vh7r.dart
Normal file
|
@ -0,0 +1,174 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value, List<Widget> selected){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/W2MU.dart
Normal file
113
.config/Code/User/History/-4a5cb082/W2MU.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final GlobalKey<_FileButtonState> key;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
163
.config/Code/User/History/-4a5cb082/WzJC.dart
Normal file
163
.config/Code/User/History/-4a5cb082/WzJC.dart
Normal file
|
@ -0,0 +1,163 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
172
.config/Code/User/History/-4a5cb082/aHe7.dart
Normal file
172
.config/Code/User/History/-4a5cb082/aHe7.dart
Normal file
|
@ -0,0 +1,172 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget{
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: _handleOption()
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/d4Fs.dart
Normal file
113
.config/Code/User/History/-4a5cb082/d4Fs.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
1
.config/Code/User/History/-4a5cb082/entries.json
Normal file
1
.config/Code/User/History/-4a5cb082/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Stuff/Coding/Flutter/filemanager/lib/file_button.dart","entries":[{"id":"qEg8.dart","timestamp":1724824685641},{"id":"FbcU.dart","timestamp":1724824699558},{"id":"t7eW.dart","source":"Add 'const' modifier","timestamp":1724996806975},{"id":"wSSJ.dart","timestamp":1724996853925},{"id":"WzJC.dart","timestamp":1724996917085},{"id":"CuSW.dart","timestamp":1724996943791},{"id":"wv4N.dart","timestamp":1724997029864},{"id":"Vh7r.dart","timestamp":1724997106960},{"id":"vLRO.dart","timestamp":1724997129366},{"id":"GAaP.dart","timestamp":1724997141553},{"id":"9Uvn.dart","timestamp":1724997172629},{"id":"xhC1.dart","timestamp":1724997238552},{"id":"81Ow.dart","timestamp":1724997285804},{"id":"aHe7.dart","timestamp":1724997307577},{"id":"vz5V.dart","timestamp":1724997326984},{"id":"AA2d.dart","source":"Import library 'package:filemanager/file_options_menu.dart'","timestamp":1724997398243},{"id":"E0j7.dart","timestamp":1724997411133},{"id":"MopS.dart","timestamp":1725076590095},{"id":"qHEc.dart","timestamp":1725076669253},{"id":"MRzI.dart","timestamp":1725076679626},{"id":"huc4.dart","timestamp":1725076710913},{"id":"6snZ.dart","timestamp":1725077355104},{"id":"KBYP.dart","timestamp":1725077654528},{"id":"winE.dart","timestamp":1725077709092},{"id":"gZly.dart","timestamp":1725077722983},{"id":"AoiA.dart","timestamp":1725077798624},{"id":"GTQL.dart","timestamp":1725770130972},{"id":"KWAD.dart","timestamp":1725770359149},{"id":"f1zP.dart","timestamp":1725770455773},{"id":"W2MU.dart","timestamp":1725770535989},{"id":"irnb.dart","timestamp":1725770623939},{"id":"d4Fs.dart","timestamp":1725771661564},{"id":"j370.dart","timestamp":1725771704773},{"id":"OP1F.dart","source":"Remove const","timestamp":1725772239976},{"id":"G6uC.dart","timestamp":1725772247870},{"id":"B7Uz.dart","source":"Remove const","timestamp":1725772266236},{"id":"73oR.dart","timestamp":1725772298300},{"id":"QGkc.dart","source":"Remove const","timestamp":1725772300037},{"id":"TKos.dart","timestamp":1725773375305},{"id":"GfH9.dart","timestamp":1725773393415},{"id":"VPbA.dart","timestamp":1725773562430},{"id":"VRr5.dart","timestamp":1725773583266},{"id":"4ZPL.dart","timestamp":1725773676509},{"id":"jzgw.dart","timestamp":1725773765744},{"id":"GGGe.dart","timestamp":1725773985402},{"id":"3MJv.dart","timestamp":1725774182809},{"id":"63jy.dart","timestamp":1725774229237},{"id":"PTbr.dart","timestamp":1725774258378},{"id":"GfkF.dart","timestamp":1725774290445},{"id":"w7Gr.dart","timestamp":1725774321319}]}
|
113
.config/Code/User/History/-4a5cb082/f1zP.dart
Normal file
113
.config/Code/User/History/-4a5cb082/f1zP.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final GlobalKey<_FileButtonState> key;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/gZly.dart
Normal file
112
.config/Code/User/History/-4a5cb082/gZly.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
116
.config/Code/User/History/-4a5cb082/huc4.dart
Normal file
116
.config/Code/User/History/-4a5cb082/huc4.dart
Normal file
|
@ -0,0 +1,116 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
void updateState(){
|
||||
final state = createState();
|
||||
(state as _FileButtonState).setButton(false);
|
||||
}
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
113
.config/Code/User/History/-4a5cb082/irnb.dart
Normal file
113
.config/Code/User/History/-4a5cb082/irnb.dart
Normal file
|
@ -0,0 +1,113 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/j370.dart
Normal file
112
.config/Code/User/History/-4a5cb082/j370.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/jzgw.dart
Normal file
112
.config/Code/User/History/-4a5cb082/jzgw.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey<State<FileButton>> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
151
.config/Code/User/History/-4a5cb082/qEg8.dart
Normal file
151
.config/Code/User/History/-4a5cb082/qEg8.dart
Normal file
|
@ -0,0 +1,151 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
116
.config/Code/User/History/-4a5cb082/qHEc.dart
Normal file
116
.config/Code/User/History/-4a5cb082/qHEc.dart
Normal file
|
@ -0,0 +1,116 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
void updateState(){
|
||||
final state = createState();
|
||||
(state as _FileButtonState).setButton(false);
|
||||
}
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(List.empty(growable: true)),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
162
.config/Code/User/History/-4a5cb082/t7eW.dart
Normal file
162
.config/Code/User/History/-4a5cb082/t7eW.dart
Normal file
|
@ -0,0 +1,162 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
171
.config/Code/User/History/-4a5cb082/vLRO.dart
Normal file
171
.config/Code/User/History/-4a5cb082/vLRO.dart
Normal file
|
@ -0,0 +1,171 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value, List<Widget> selected){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
171
.config/Code/User/History/-4a5cb082/vz5V.dart
Normal file
171
.config/Code/User/History/-4a5cb082/vz5V.dart
Normal file
|
@ -0,0 +1,171 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget{
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: _handleOption()
|
||||
);
|
||||
}
|
||||
}
|
112
.config/Code/User/History/-4a5cb082/w7Gr.dart
Normal file
112
.config/Code/User/History/-4a5cb082/w7Gr.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({required this.globalKey, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last, super(key: globalKey);
|
||||
|
||||
final GlobalKey<_FileButtonState> globalKey;
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
SafeArea(
|
||||
child: FileOptionsMenu(selected: [widget],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
163
.config/Code/User/History/-4a5cb082/wSSJ.dart
Normal file
163
.config/Code/User/History/-4a5cb082/wSSJ.dart
Normal file
|
@ -0,0 +1,163 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget{
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
118
.config/Code/User/History/-4a5cb082/winE.dart
Normal file
118
.config/Code/User/History/-4a5cb082/winE.dart
Normal file
|
@ -0,0 +1,118 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/file_options_menu.dart';
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
void updateState(){
|
||||
print('state change attempted');
|
||||
final state = createState();
|
||||
(state as _FileButtonState).setButton(false);
|
||||
}
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
print('set Button');
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(selected: [],),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
167
.config/Code/User/History/-4a5cb082/wv4N.dart
Normal file
167
.config/Code/User/History/-4a5cb082/wv4N.dart
Normal file
|
@ -0,0 +1,167 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setSelected(bool option){
|
||||
setState((){
|
||||
selected = option;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value, List<Widget> selected){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
setState((){
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
});
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: null
|
||||
);
|
||||
}
|
||||
}
|
170
.config/Code/User/History/-4a5cb082/xhC1.dart
Normal file
170
.config/Code/User/History/-4a5cb082/xhC1.dart
Normal file
|
@ -0,0 +1,170 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:filemanager/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum FileOptions{delete, copy, cut, rename}
|
||||
|
||||
class FileButton extends StatefulWidget{
|
||||
FileButton({super.key, required this.fsEntity, required this.openFile, required this.refresh, required this.copyFile, required this.setMode, required this.getMode, required this.selectionList}) : name = fsEntity.path.split('/').last;
|
||||
|
||||
final FileSystemEntity fsEntity;
|
||||
final Function(FileSystemEntity, String) openFile;
|
||||
final Function() refresh;
|
||||
final Function(FileSystemEntity, FileOptions) copyFile;
|
||||
final Function(FMMode) setMode;
|
||||
final Function() getMode;
|
||||
final Function(FileButton, bool) selectionList;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
State<FileButton> createState() => _FileButtonState();
|
||||
}
|
||||
|
||||
class _FileButtonState extends State<FileButton>{
|
||||
|
||||
bool selected = false;
|
||||
late Icon icon;
|
||||
Color? color;
|
||||
VoidCallback? onPress;
|
||||
VoidCallback? onLongPress;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
super.initState();
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
|
||||
void onPressed(){
|
||||
if(widget.getMode() == FMMode.normal){
|
||||
widget.openFile(widget.fsEntity, widget.name);
|
||||
}
|
||||
else if(widget.getMode() == FMMode.selection){
|
||||
setState((){
|
||||
if(selected){
|
||||
selected = false;
|
||||
widget.selectionList(widget, false);
|
||||
}
|
||||
else{
|
||||
selected = true;
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onLongPressed(){
|
||||
setState((){
|
||||
selected = true;
|
||||
});
|
||||
widget.setMode(FMMode.selection);
|
||||
widget.selectionList(widget, true);
|
||||
}
|
||||
|
||||
void setButton(bool enabled){
|
||||
setState((){
|
||||
if(enabled){
|
||||
onPress = onPressed;
|
||||
onLongPress = onLongPressed;
|
||||
}
|
||||
else{
|
||||
onPress = null;
|
||||
onLongPress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
color = null;
|
||||
if(selected){
|
||||
icon = const Icon(Icons.check);
|
||||
color = Theme.of(context).focusColor;
|
||||
}
|
||||
else if(widget.fsEntity is File){
|
||||
icon = const Icon(Icons.file_copy);
|
||||
}
|
||||
else if(widget.fsEntity is Directory){
|
||||
icon = const Icon(Icons.folder);
|
||||
}
|
||||
else{
|
||||
icon = const Icon(Icons.question_mark);
|
||||
}
|
||||
return MaterialButton(
|
||||
color: color,
|
||||
onPressed: onPress,
|
||||
onLongPress: onLongPress,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SafeArea(child: icon),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(widget.name)),
|
||||
const SafeArea(
|
||||
child: FileOptionsMenu(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FileOptionsMenu extends StatelessWidget {
|
||||
const FileOptionsMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
void _handleOption(FileOptions value){
|
||||
switch (value){
|
||||
case FileOptions.cut:
|
||||
continue copy;
|
||||
copy:
|
||||
case FileOptions.copy:
|
||||
widget.copyFile(widget.fsEntity, value);
|
||||
break;
|
||||
case FileOptions.rename:
|
||||
var controller = TextEditingController();
|
||||
String fileExtension = widget.fsEntity.path.substring(widget.fsEntity.path.lastIndexOf('.'));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Rename'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
actions: <IconButton>[
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
icon: const Icon(Icons.cancel)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.fsEntity.renameSync(
|
||||
'${widget.fsEntity.parent.path}/${controller.text}$fileExtension');
|
||||
Navigator.pop(context);
|
||||
widget.refresh();
|
||||
},
|
||||
icon: const Icon(Icons.check)),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileOptions.delete:
|
||||
widget.fsEntity.deleteSync(recursive: true);
|
||||
//TODO: call getdirbuttons here
|
||||
}
|
||||
widget.refresh();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileOptions>>[
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.copy,child: Text('Copy')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.cut,child: Text('Cut')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.rename,child: Text('Rename')),
|
||||
const PopupMenuItem<FileOptions>(value: FileOptions.delete,child: Text('Delete')),
|
||||
],
|
||||
onSelected: _handleOption()
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue