|
|
@ -80,68 +80,17 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
child: const Icon(Icons.add), |
|
|
|
child: const Icon(Icons.add), |
|
|
|
) |
|
|
|
) |
|
|
|
: null, |
|
|
|
: null, |
|
|
|
body: RefreshIndicator( |
|
|
|
body: CustomListView<Widget>( |
|
|
|
onRefresh: () async { |
|
|
|
scrollKey: 'files-${pathSnapshot.data!.join('/')}', |
|
|
|
widget.bloc.refresh(); |
|
|
|
withFloatingActionButton: true, |
|
|
|
}, |
|
|
|
items: [ |
|
|
|
child: Column( |
|
|
|
for (final uploadTask in filesData == null |
|
|
|
children: [ |
|
|
|
? <UploadTask>[] |
|
|
|
ExceptionWidget( |
|
|
|
: uploadTasksSnapshot.data!.where( |
|
|
|
filesError, |
|
|
|
|
|
|
|
onRetry: () { |
|
|
|
|
|
|
|
widget.bloc.refresh(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CustomLinearProgressIndicator( |
|
|
|
|
|
|
|
visible: filesLoading, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
Align( |
|
|
|
|
|
|
|
alignment: Alignment.topLeft, |
|
|
|
|
|
|
|
child: Container( |
|
|
|
|
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
|
|
|
|
horizontal: 10, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
child: Wrap( |
|
|
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
|
|
|
|
children: <Widget>[ |
|
|
|
|
|
|
|
SizedBox( |
|
|
|
|
|
|
|
height: 40, |
|
|
|
|
|
|
|
child: InkWell( |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
widget.bloc.setPath([]); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
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]), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
.intersperse( |
|
|
|
|
|
|
|
const Icon( |
|
|
|
|
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
|
|
|
size: 40, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.toList(), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
if (filesData != null) ...[ |
|
|
|
|
|
|
|
Builder( |
|
|
|
|
|
|
|
builder: (final context) { |
|
|
|
|
|
|
|
final uploadTasksWithoutExistingFile = uploadTasksSnapshot.data!.where( |
|
|
|
|
|
|
|
(final task) => filesData |
|
|
|
(final task) => filesData |
|
|
|
.where((final file) => _pathMatchesFile(task.path, file.name)) |
|
|
|
.where((final file) => _pathMatchesFile(task.path, file.name)) |
|
|
|
.isEmpty, |
|
|
|
.isEmpty, |
|
|
|
); |
|
|
|
)) ...[ |
|
|
|
final widgets = [ |
|
|
|
|
|
|
|
for (final uploadTask in uploadTasksWithoutExistingFile) ...[ |
|
|
|
|
|
|
|
StreamBuilder<int>( |
|
|
|
StreamBuilder<int>( |
|
|
|
stream: uploadTask.progress, |
|
|
|
stream: uploadTask.progress, |
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
|
builder: (final context, final uploadTaskProgressSnapshot) => |
|
|
@ -164,6 +113,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
if (filesData != null) ...[ |
|
|
|
for (final file in filesData) ...[ |
|
|
|
for (final file in filesData) ...[ |
|
|
|
if (!widget.onlyShowDirectories || file.isDirectory) ...[ |
|
|
|
if (!widget.onlyShowDirectories || file.isDirectory) ...[ |
|
|
|
Builder( |
|
|
|
Builder( |
|
|
@ -182,8 +132,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
stream: matchingDownloadTasks.isNotEmpty |
|
|
|
stream: matchingDownloadTasks.isNotEmpty |
|
|
|
? matchingDownloadTasks.first.progress |
|
|
|
? matchingDownloadTasks.first.progress |
|
|
|
: Stream.value(null), |
|
|
|
: Stream.value(null), |
|
|
|
builder: (final context, final downloadTaskProgressSnapshot) => |
|
|
|
builder: (final context, final downloadTaskProgressSnapshot) => _buildFile( |
|
|
|
_buildFile( |
|
|
|
|
|
|
|
context: context, |
|
|
|
context: context, |
|
|
|
details: FileDetails( |
|
|
|
details: FileDetails( |
|
|
|
path: [...widget.bloc.path.value, file.name], |
|
|
|
path: [...widget.bloc.path.value, file.name], |
|
|
@ -196,10 +145,8 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
lastModified: matchingUploadTasks.isNotEmpty |
|
|
|
lastModified: matchingUploadTasks.isNotEmpty |
|
|
|
? matchingUploadTasks.first.lastModified |
|
|
|
? matchingUploadTasks.first.lastModified |
|
|
|
: file.lastModified!, |
|
|
|
: file.lastModified!, |
|
|
|
hasPreview: |
|
|
|
hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview, |
|
|
|
matchingUploadTasks.isNotEmpty ? null : file.hasPreview, |
|
|
|
isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite, |
|
|
|
isFavorite: |
|
|
|
|
|
|
|
matchingUploadTasks.isNotEmpty ? null : file.favorite, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
uploadProgress: uploadTaskProgressSnapshot.data, |
|
|
|
uploadProgress: uploadTaskProgressSnapshot.data, |
|
|
|
downloadProgress: downloadTaskProgressSnapshot.data, |
|
|
|
downloadProgress: downloadTaskProgressSnapshot.data, |
|
|
@ -210,29 +157,58 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
]; |
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
return Expanded( |
|
|
|
isLoading: filesLoading, |
|
|
|
child: CustomListView<Widget>( |
|
|
|
error: filesError, |
|
|
|
scrollKey: 'files-${pathSnapshot.data!.join('/')}', |
|
|
|
onRetry: () { |
|
|
|
withFloatingActionButton: true, |
|
|
|
widget.bloc.refresh(); |
|
|
|
items: widgets, |
|
|
|
}, |
|
|
|
|
|
|
|
onRefresh: () async { |
|
|
|
|
|
|
|
widget.bloc.refresh(); |
|
|
|
|
|
|
|
}, |
|
|
|
builder: (final context, final widget) => widget, |
|
|
|
builder: (final context, final widget) => widget, |
|
|
|
|
|
|
|
topScrollingChildren: [ |
|
|
|
|
|
|
|
Align( |
|
|
|
|
|
|
|
alignment: Alignment.topLeft, |
|
|
|
|
|
|
|
child: Container( |
|
|
|
|
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
|
|
|
|
horizontal: 10, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
child: Wrap( |
|
|
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
|
|
|
|
children: <Widget>[ |
|
|
|
|
|
|
|
SizedBox( |
|
|
|
|
|
|
|
height: 40, |
|
|
|
|
|
|
|
child: InkWell( |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
widget.bloc.setPath([]); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
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]), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
] |
|
|
|
] |
|
|
|
.intersperse( |
|
|
|
.intersperse( |
|
|
|
const SizedBox( |
|
|
|
const Icon( |
|
|
|
height: 10, |
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
|
|
|
size: 40, |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
) |
|
|
|
.toList(), |
|
|
|
.toList(), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|