|
|
@ -46,142 +46,154 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
!uploadTasksSnapshot.hasData || |
|
|
|
!uploadTasksSnapshot.hasData || |
|
|
|
!downloadTasksSnapshot.hasData |
|
|
|
!downloadTasksSnapshot.hasData |
|
|
|
? Container() |
|
|
|
? Container() |
|
|
|
: Scaffold( |
|
|
|
: BackButtonListener( |
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
onBackButtonPressed: () async { |
|
|
|
floatingActionButton: widget.enableCreateActions |
|
|
|
final path = pathSnapshot.data!; |
|
|
|
? FloatingActionButton( |
|
|
|
if (path.isNotEmpty) { |
|
|
|
onPressed: () async { |
|
|
|
widget.bloc.setPath(path.sublist(0, path.length - 1)); |
|
|
|
await showDialog( |
|
|
|
return true; |
|
|
|
context: context, |
|
|
|
} |
|
|
|
builder: (final context) => FilesChooseCreateDialog( |
|
|
|
return false; |
|
|
|
bloc: widget.filesBloc, |
|
|
|
}, |
|
|
|
basePath: widget.bloc.path.value, |
|
|
|
child: Scaffold( |
|
|
|
), |
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
); |
|
|
|
floatingActionButton: widget.enableCreateActions |
|
|
|
}, |
|
|
|
? FloatingActionButton( |
|
|
|
child: const Icon(Icons.add), |
|
|
|
onPressed: () async { |
|
|
|
) |
|
|
|
await showDialog( |
|
|
|
: null, |
|
|
|
context: context, |
|
|
|
body: NeonListView<Widget>( |
|
|
|
builder: (final context) => FilesChooseCreateDialog( |
|
|
|
scrollKey: 'files-${pathSnapshot.data!.join('/')}', |
|
|
|
bloc: widget.filesBloc, |
|
|
|
withFloatingActionButton: true, |
|
|
|
basePath: widget.bloc.path.value, |
|
|
|
items: [ |
|
|
|
), |
|
|
|
for (final uploadTask in files.data == null |
|
|
|
); |
|
|
|
? <UploadTask>[] |
|
|
|
}, |
|
|
|
: uploadTasksSnapshot.data!.where( |
|
|
|
child: const Icon(Icons.add), |
|
|
|
(final task) => |
|
|
|
) |
|
|
|
files.data!.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, |
|
|
|
: null, |
|
|
|
)) ...[ |
|
|
|
body: NeonListView<Widget>( |
|
|
|
StreamBuilder<int>( |
|
|
|
scrollKey: 'files-${pathSnapshot.data!.join('/')}', |
|
|
|
stream: uploadTask.progress, |
|
|
|
withFloatingActionButton: true, |
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
items: [ |
|
|
|
!uploadTaskProgressSnapshot.hasData |
|
|
|
for (final uploadTask in files.data == null |
|
|
|
? Container() |
|
|
|
? <UploadTask>[] |
|
|
|
: _buildFile( |
|
|
|
: uploadTasksSnapshot.data!.where( |
|
|
|
context: context, |
|
|
|
(final task) => files.data! |
|
|
|
details: FileDetails( |
|
|
|
.where((final file) => _pathMatchesFile(task.path, file.name)) |
|
|
|
path: uploadTask.path, |
|
|
|
.isEmpty, |
|
|
|
isDirectory: false, |
|
|
|
)) ...[ |
|
|
|
size: uploadTask.size, |
|
|
|
StreamBuilder<int>( |
|
|
|
etag: null, |
|
|
|
stream: uploadTask.progress, |
|
|
|
mimeType: null, |
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
lastModified: uploadTask.lastModified, |
|
|
|
!uploadTaskProgressSnapshot.hasData |
|
|
|
hasPreview: null, |
|
|
|
? Container() |
|
|
|
isFavorite: null, |
|
|
|
: _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 (files.data != null) ...[ |
|
|
|
), |
|
|
|
for (final file in files.data!) ...[ |
|
|
|
], |
|
|
|
if (!widget.onlyShowDirectories || file.isDirectory) ...[ |
|
|
|
if (files.data != null) ...[ |
|
|
|
Builder( |
|
|
|
for (final file in files.data!) ...[ |
|
|
|
builder: (final context) { |
|
|
|
if (!widget.onlyShowDirectories || file.isDirectory) ...[ |
|
|
|
final matchingUploadTasks = uploadTasksSnapshot.data! |
|
|
|
Builder( |
|
|
|
.where((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
builder: (final context) { |
|
|
|
final matchingDownloadTasks = downloadTasksSnapshot.data! |
|
|
|
final matchingUploadTasks = uploadTasksSnapshot.data! |
|
|
|
.where((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
.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 downloadTaskProgressSnapshot) => _buildFile( |
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
context: context, |
|
|
|
StreamBuilder<int?>( |
|
|
|
details: FileDetails( |
|
|
|
stream: matchingDownloadTasks.isNotEmpty |
|
|
|
path: [...widget.bloc.path.value, file.name], |
|
|
|
? matchingDownloadTasks.first.progress |
|
|
|
isDirectory: matchingUploadTasks.isEmpty && file.isDirectory, |
|
|
|
: Stream.value(null), |
|
|
|
size: matchingUploadTasks.isNotEmpty |
|
|
|
builder: (final context, final downloadTaskProgressSnapshot) => _buildFile( |
|
|
|
? matchingUploadTasks.first.size |
|
|
|
context: context, |
|
|
|
: file.size!, |
|
|
|
details: FileDetails( |
|
|
|
etag: matchingUploadTasks.isNotEmpty ? null : file.etag, |
|
|
|
path: [...widget.bloc.path.value, file.name], |
|
|
|
mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType, |
|
|
|
isDirectory: matchingUploadTasks.isEmpty && file.isDirectory, |
|
|
|
lastModified: matchingUploadTasks.isNotEmpty |
|
|
|
size: matchingUploadTasks.isNotEmpty |
|
|
|
? matchingUploadTasks.first.lastModified |
|
|
|
? matchingUploadTasks.first.size |
|
|
|
: file.lastModified!, |
|
|
|
: file.size!, |
|
|
|
hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview, |
|
|
|
etag: matchingUploadTasks.isNotEmpty ? null : file.etag, |
|
|
|
isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite, |
|
|
|
mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType, |
|
|
|
|
|
|
|
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, |
|
|
|
isLoading: files.loading, |
|
|
|
error: files.error, |
|
|
|
error: files.error, |
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
builder: (final context, final widget) => widget, |
|
|
|
builder: (final context, final widget) => widget, |
|
|
|
topScrollingChildren: [ |
|
|
|
topScrollingChildren: [ |
|
|
|
Align( |
|
|
|
Align( |
|
|
|
alignment: Alignment.topLeft, |
|
|
|
alignment: Alignment.topLeft, |
|
|
|
child: Container( |
|
|
|
child: Container( |
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
horizontal: 10, |
|
|
|
horizontal: 10, |
|
|
|
), |
|
|
|
), |
|
|
|
child: Wrap( |
|
|
|
child: Wrap( |
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
children: <Widget>[ |
|
|
|
children: <Widget>[ |
|
|
|
SizedBox( |
|
|
|
SizedBox( |
|
|
|
height: 40, |
|
|
|
height: 40, |
|
|
|
child: InkWell( |
|
|
|
child: InkWell( |
|
|
|
onTap: () { |
|
|
|
onTap: () { |
|
|
|
widget.bloc.setPath([]); |
|
|
|
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( |
|
|
|
.intersperse( |
|
|
|
onTap: () { |
|
|
|
const Icon( |
|
|
|
widget.bloc.setPath(pathSnapshot.data!.sublist(0, i + 1)); |
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
}, |
|
|
|
size: 40, |
|
|
|
child: Text(pathSnapshot.data![i]), |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
], |
|
|
|
.toList(), |
|
|
|
] |
|
|
|
|
|
|
|
.intersperse( |
|
|
|
|
|
|
|
const Icon( |
|
|
|
|
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
|
|
|
size: 40, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.toList(), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|