nested folder structures
This commit is contained in:
@@ -41,7 +41,7 @@ class FileBrowserBloc extends Bloc<FileBrowserEvent, FileBrowserState> {
|
||||
_filteredFiles = _currentFiles;
|
||||
_currentPage = 1;
|
||||
if (files.isEmpty) {
|
||||
emit(DirectoryEmpty());
|
||||
emit(DirectoryEmpty(_currentPath));
|
||||
} else {
|
||||
_emitLoadedState(emit);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ class FileBrowserBloc extends Bloc<FileBrowserEvent, FileBrowserState> {
|
||||
_filteredFiles = files;
|
||||
_currentPage = 1;
|
||||
if (files.isEmpty) {
|
||||
emit(DirectoryEmpty());
|
||||
emit(DirectoryEmpty(_currentPath));
|
||||
} else {
|
||||
_emitLoadedState(emit);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,14 @@ class DirectoryLoaded extends FileBrowserState {
|
||||
];
|
||||
}
|
||||
|
||||
class DirectoryEmpty extends FileBrowserState {}
|
||||
class DirectoryEmpty extends FileBrowserState {
|
||||
final String currentPath;
|
||||
|
||||
const DirectoryEmpty(this.currentPath);
|
||||
|
||||
@override
|
||||
List<Object> get props => [currentPath];
|
||||
}
|
||||
|
||||
class DirectoryError extends FileBrowserState {
|
||||
final String error;
|
||||
|
||||
@@ -425,7 +425,7 @@ class _FileExplorerState extends State<FileExplorer> {
|
||||
context.read<FileBrowserBloc>().add(
|
||||
CreateFolder(
|
||||
orgId: 'org1',
|
||||
parentPath: '/',
|
||||
parentPath: state.currentPath,
|
||||
folderName: folderName,
|
||||
),
|
||||
);
|
||||
@@ -456,8 +456,21 @@ class _FileExplorerState extends State<FileExplorer> {
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
onPressed: () {
|
||||
final parentPath = state.currentPath == '/'
|
||||
? '/'
|
||||
: state.currentPath
|
||||
.substring(
|
||||
0,
|
||||
state.currentPath.lastIndexOf('/'),
|
||||
)
|
||||
.isEmpty
|
||||
? '/'
|
||||
: state.currentPath.substring(
|
||||
0,
|
||||
state.currentPath.lastIndexOf('/'),
|
||||
);
|
||||
context.read<FileBrowserBloc>().add(
|
||||
LoadDirectory(orgId: 'org1', path: '/'),
|
||||
LoadDirectory(orgId: 'org1', path: parentPath),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -519,7 +532,7 @@ class _FileExplorerState extends State<FileExplorer> {
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
'${breadcrumb.name}/',
|
||||
'/${breadcrumb.name}',
|
||||
style: const TextStyle(
|
||||
color: AppTheme.secondaryText,
|
||||
),
|
||||
|
||||
@@ -172,10 +172,11 @@ class MockFileRepository implements FileRepository {
|
||||
Future<List<FileItem>> getFiles(String orgId, String path) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
if (path == '/') {
|
||||
return _files;
|
||||
return _files.where((f) => !f.path.substring(1).contains('/')).toList();
|
||||
} else {
|
||||
// For subfolders, return empty for simplicity
|
||||
return [];
|
||||
return _files
|
||||
.where((f) => f.path.startsWith('$path/') && f.path != path)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,10 +206,15 @@ class MockFileRepository implements FileRepository {
|
||||
String folderName,
|
||||
) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final newPath = '$parentPath/$folderName';
|
||||
final normalizedName = folderName.startsWith('/')
|
||||
? folderName.substring(1)
|
||||
: folderName;
|
||||
final newPath = parentPath == '/'
|
||||
? '/$normalizedName'
|
||||
: '$parentPath/$normalizedName';
|
||||
_files.add(
|
||||
FileItem(
|
||||
name: folderName,
|
||||
name: normalizedName,
|
||||
path: newPath,
|
||||
type: FileType.folder,
|
||||
lastModified: DateTime.now(),
|
||||
|
||||
Reference in New Issue
Block a user