|
|
@ -6,7 +6,6 @@ class FilesBrowserView extends StatefulWidget { |
|
|
|
required this.filesBloc, |
|
|
|
required this.filesBloc, |
|
|
|
this.onPickFile, |
|
|
|
this.onPickFile, |
|
|
|
this.enableFileActions = true, |
|
|
|
this.enableFileActions = true, |
|
|
|
this.enableCreateActions = true, |
|
|
|
|
|
|
|
this.onlyShowDirectories = false, |
|
|
|
this.onlyShowDirectories = false, |
|
|
|
super.key, |
|
|
|
super.key, |
|
|
|
// ignore: prefer_asserts_with_message |
|
|
|
// ignore: prefer_asserts_with_message |
|
|
@ -16,7 +15,6 @@ class FilesBrowserView extends StatefulWidget { |
|
|
|
final FilesBloc filesBloc; |
|
|
|
final FilesBloc filesBloc; |
|
|
|
final Function(FileDetails)? onPickFile; |
|
|
|
final Function(FileDetails)? onPickFile; |
|
|
|
final bool enableFileActions; |
|
|
|
final bool enableFileActions; |
|
|
|
final bool enableCreateActions; |
|
|
|
|
|
|
|
final bool onlyShowDirectories; |
|
|
|
final bool onlyShowDirectories; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
@ -55,149 +53,132 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: Scaffold( |
|
|
|
child: SortBoxBuilder<FilesSortProperty, WebDavFile>( |
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
sortBox: filesSortBox, |
|
|
|
floatingActionButton: widget.enableCreateActions |
|
|
|
sortPropertyOption: widget.bloc.options.filesSortPropertyOption, |
|
|
|
? FloatingActionButton( |
|
|
|
sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption, |
|
|
|
onPressed: () async { |
|
|
|
input: files.data, |
|
|
|
await showDialog( |
|
|
|
builder: (final context, final sorted) => NeonListView<Widget>( |
|
|
|
context: context, |
|
|
|
scrollKey: 'files-${pathSnapshot.data!.join('/')}', |
|
|
|
builder: (final context) => FilesChooseCreateDialog( |
|
|
|
withFloatingActionButton: true, |
|
|
|
bloc: widget.filesBloc, |
|
|
|
items: [ |
|
|
|
basePath: widget.bloc.path.value, |
|
|
|
for (final uploadTask in sorted == null |
|
|
|
), |
|
|
|
? <UploadTask>[] |
|
|
|
); |
|
|
|
: uploadTasksSnapshot.data!.where( |
|
|
|
}, |
|
|
|
(final task) => |
|
|
|
child: const Icon(Icons.add), |
|
|
|
sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, |
|
|
|
) |
|
|
|
)) ...[ |
|
|
|
: null, |
|
|
|
StreamBuilder<int>( |
|
|
|
body: SortBoxBuilder<FilesSortProperty, WebDavFile>( |
|
|
|
stream: uploadTask.progress, |
|
|
|
sortBox: filesSortBox, |
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
sortPropertyOption: widget.bloc.options.filesSortPropertyOption, |
|
|
|
!uploadTaskProgressSnapshot.hasData |
|
|
|
sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption, |
|
|
|
? Container() |
|
|
|
input: files.data, |
|
|
|
: _buildFile( |
|
|
|
builder: (final context, final sorted) => NeonListView<Widget>( |
|
|
|
context: context, |
|
|
|
scrollKey: 'files-${pathSnapshot.data!.join('/')}', |
|
|
|
details: FileDetails( |
|
|
|
withFloatingActionButton: true, |
|
|
|
path: uploadTask.path, |
|
|
|
items: [ |
|
|
|
isDirectory: false, |
|
|
|
for (final uploadTask in sorted == null |
|
|
|
size: uploadTask.size, |
|
|
|
? <UploadTask>[] |
|
|
|
etag: null, |
|
|
|
: uploadTasksSnapshot.data!.where( |
|
|
|
mimeType: null, |
|
|
|
(final task) => |
|
|
|
lastModified: uploadTask.lastModified, |
|
|
|
sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, |
|
|
|
hasPreview: null, |
|
|
|
)) ...[ |
|
|
|
isFavorite: null, |
|
|
|
StreamBuilder<int>( |
|
|
|
|
|
|
|
stream: uploadTask.progress, |
|
|
|
|
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
|
|
|
|
!uploadTaskProgressSnapshot.hasData |
|
|
|
|
|
|
|
? Container() |
|
|
|
|
|
|
|
: _buildFile( |
|
|
|
|
|
|
|
context: context, |
|
|
|
|
|
|
|
details: FileDetails( |
|
|
|
|
|
|
|
path: uploadTask.path, |
|
|
|
|
|
|
|
isDirectory: false, |
|
|
|
|
|
|
|
size: uploadTask.size, |
|
|
|
|
|
|
|
etag: null, |
|
|
|
|
|
|
|
mimeType: null, |
|
|
|
|
|
|
|
lastModified: uploadTask.lastModified, |
|
|
|
|
|
|
|
hasPreview: null, |
|
|
|
|
|
|
|
isFavorite: null, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
uploadProgress: uploadTaskProgressSnapshot.data, |
|
|
|
|
|
|
|
downloadProgress: null, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
uploadProgress: uploadTaskProgressSnapshot.data, |
|
|
|
], |
|
|
|
downloadProgress: null, |
|
|
|
if (sorted != null) ...[ |
|
|
|
), |
|
|
|
for (final file in sorted) ...[ |
|
|
|
), |
|
|
|
if (!widget.onlyShowDirectories || file.isDirectory) ...[ |
|
|
|
], |
|
|
|
Builder( |
|
|
|
if (sorted != null) ...[ |
|
|
|
builder: (final context) { |
|
|
|
for (final file in sorted) ...[ |
|
|
|
final matchingUploadTasks = uploadTasksSnapshot.data! |
|
|
|
if (!widget.onlyShowDirectories || file.isDirectory) ...[ |
|
|
|
.where((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
Builder( |
|
|
|
final matchingDownloadTasks = downloadTasksSnapshot.data! |
|
|
|
builder: (final context) { |
|
|
|
.where((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
final matchingUploadTasks = uploadTasksSnapshot.data! |
|
|
|
|
|
|
|
.where((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
|
|
|
|
final matchingDownloadTasks = downloadTasksSnapshot.data! |
|
|
|
|
|
|
|
.where((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
|
|
|
|
|
|
|
|
return StreamBuilder<int?>( |
|
|
|
return StreamBuilder<int?>( |
|
|
|
stream: matchingUploadTasks.isNotEmpty |
|
|
|
stream: matchingUploadTasks.isNotEmpty |
|
|
|
? matchingUploadTasks.first.progress |
|
|
|
? matchingUploadTasks.first.progress |
|
|
|
|
|
|
|
: Stream.value(null), |
|
|
|
|
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
|
|
|
|
StreamBuilder<int?>( |
|
|
|
|
|
|
|
stream: matchingDownloadTasks.isNotEmpty |
|
|
|
|
|
|
|
? matchingDownloadTasks.first.progress |
|
|
|
: Stream.value(null), |
|
|
|
: Stream.value(null), |
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
builder: (final context, final downloadTaskProgressSnapshot) => _buildFile( |
|
|
|
StreamBuilder<int?>( |
|
|
|
context: context, |
|
|
|
stream: matchingDownloadTasks.isNotEmpty |
|
|
|
details: FileDetails( |
|
|
|
? matchingDownloadTasks.first.progress |
|
|
|
path: [...widget.bloc.path.value, file.name], |
|
|
|
: Stream.value(null), |
|
|
|
isDirectory: matchingUploadTasks.isEmpty && file.isDirectory, |
|
|
|
builder: (final context, final downloadTaskProgressSnapshot) => _buildFile( |
|
|
|
size: matchingUploadTasks.isNotEmpty |
|
|
|
context: context, |
|
|
|
? matchingUploadTasks.first.size |
|
|
|
details: FileDetails( |
|
|
|
: file.size!, |
|
|
|
path: [...widget.bloc.path.value, file.name], |
|
|
|
etag: matchingUploadTasks.isNotEmpty ? null : file.etag, |
|
|
|
isDirectory: matchingUploadTasks.isEmpty && file.isDirectory, |
|
|
|
mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType, |
|
|
|
size: matchingUploadTasks.isNotEmpty |
|
|
|
lastModified: matchingUploadTasks.isNotEmpty |
|
|
|
? matchingUploadTasks.first.size |
|
|
|
? matchingUploadTasks.first.lastModified |
|
|
|
: file.size!, |
|
|
|
: file.lastModified!, |
|
|
|
etag: matchingUploadTasks.isNotEmpty ? null : file.etag, |
|
|
|
hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview, |
|
|
|
mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType, |
|
|
|
isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite, |
|
|
|
lastModified: matchingUploadTasks.isNotEmpty |
|
|
|
|
|
|
|
? matchingUploadTasks.first.lastModified |
|
|
|
|
|
|
|
: file.lastModified!, |
|
|
|
|
|
|
|
hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview, |
|
|
|
|
|
|
|
isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
uploadProgress: uploadTaskProgressSnapshot.data, |
|
|
|
|
|
|
|
downloadProgress: downloadTaskProgressSnapshot.data, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
uploadProgress: uploadTaskProgressSnapshot.data, |
|
|
|
|
|
|
|
downloadProgress: downloadTaskProgressSnapshot.data, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
), |
|
|
|
}, |
|
|
|
); |
|
|
|
), |
|
|
|
}, |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
isLoading: files.loading, |
|
|
|
], |
|
|
|
error: files.error, |
|
|
|
isLoading: files.loading, |
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
error: files.error, |
|
|
|
builder: (final context, final widget) => widget, |
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
topScrollingChildren: [ |
|
|
|
builder: (final context, final widget) => widget, |
|
|
|
Align( |
|
|
|
topScrollingChildren: [ |
|
|
|
alignment: Alignment.topLeft, |
|
|
|
Align( |
|
|
|
child: Container( |
|
|
|
alignment: Alignment.topLeft, |
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
child: Container( |
|
|
|
horizontal: 10, |
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
), |
|
|
|
horizontal: 10, |
|
|
|
child: Wrap( |
|
|
|
), |
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
child: Wrap( |
|
|
|
children: <Widget>[ |
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
SizedBox( |
|
|
|
children: <Widget>[ |
|
|
|
height: 40, |
|
|
|
SizedBox( |
|
|
|
child: InkWell( |
|
|
|
height: 40, |
|
|
|
onTap: () { |
|
|
|
child: InkWell( |
|
|
|
widget.bloc.setPath([]); |
|
|
|
onTap: () { |
|
|
|
}, |
|
|
|
widget.bloc.setPath([]); |
|
|
|
child: const Icon(Icons.house), |
|
|
|
}, |
|
|
|
), |
|
|
|
child: const Icon(Icons.house), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
for (var i = 0; i < pathSnapshot.data!.length; i++) ...[ |
|
|
|
|
|
|
|
InkWell( |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
widget.bloc.setPath(pathSnapshot.data!.sublist(0, i + 1)); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
child: Text(pathSnapshot.data![i]), |
|
|
|
), |
|
|
|
), |
|
|
|
for (var i = 0; i < pathSnapshot.data!.length; i++) ...[ |
|
|
|
], |
|
|
|
InkWell( |
|
|
|
] |
|
|
|
onTap: () { |
|
|
|
.intersperse( |
|
|
|
widget.bloc.setPath(pathSnapshot.data!.sublist(0, i + 1)); |
|
|
|
const Icon( |
|
|
|
}, |
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
child: Text(pathSnapshot.data![i]), |
|
|
|
size: 40, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
) |
|
|
|
] |
|
|
|
.toList(), |
|
|
|
.intersperse( |
|
|
|
|
|
|
|
const Icon( |
|
|
|
|
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
|
|
|
size: 40, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.toList(), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|