Browse Source

neon_files: Go up a folder when going back

pull/265/head
jld3103 2 years ago
parent
commit
78866400ee
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 20
      packages/neon/neon_files/lib/widgets/browser_view.dart

20
packages/neon/neon_files/lib/widgets/browser_view.dart

@ -46,7 +46,16 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
!uploadTasksSnapshot.hasData || !uploadTasksSnapshot.hasData ||
!downloadTasksSnapshot.hasData !downloadTasksSnapshot.hasData
? Container() ? Container()
: Scaffold( : BackButtonListener(
onBackButtonPressed: () async {
final path = pathSnapshot.data!;
if (path.isNotEmpty) {
widget.bloc.setPath(path.sublist(0, path.length - 1));
return true;
}
return false;
},
child: Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
floatingActionButton: widget.enableCreateActions floatingActionButton: widget.enableCreateActions
? FloatingActionButton( ? FloatingActionButton(
@ -69,8 +78,9 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
for (final uploadTask in files.data == null for (final uploadTask in files.data == null
? <UploadTask>[] ? <UploadTask>[]
: uploadTasksSnapshot.data!.where( : uploadTasksSnapshot.data!.where(
(final task) => (final task) => files.data!
files.data!.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, .where((final file) => _pathMatchesFile(task.path, file.name))
.isEmpty,
)) ...[ )) ...[
StreamBuilder<int>( StreamBuilder<int>(
stream: uploadTask.progress, stream: uploadTask.progress,
@ -108,7 +118,8 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
stream: matchingUploadTasks.isNotEmpty stream: matchingUploadTasks.isNotEmpty
? matchingUploadTasks.first.progress ? matchingUploadTasks.first.progress
: Stream.value(null), : Stream.value(null),
builder: (final context, final uploadTaskProgressSnapshot) => StreamBuilder<int?>( builder: (final context, final uploadTaskProgressSnapshot) =>
StreamBuilder<int?>(
stream: matchingDownloadTasks.isNotEmpty stream: matchingDownloadTasks.isNotEmpty
? matchingDownloadTasks.first.progress ? matchingDownloadTasks.first.progress
: Stream.value(null), : Stream.value(null),
@ -187,6 +198,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
), ),
), ),
), ),
),
); );
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality().equals( bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality().equals(

Loading…
Cancel
Save