|
|
@ -68,28 +68,32 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
input: files.data, |
|
|
|
input: files.data, |
|
|
|
builder: (final context, final sorted) => ValueListenableBuilder( |
|
|
|
builder: (final context, final sorted) => ValueListenableBuilder( |
|
|
|
valueListenable: widget.bloc.options.showHiddenFilesOption, |
|
|
|
valueListenable: widget.bloc.options.showHiddenFilesOption, |
|
|
|
builder: (final context, final showHiddenFiles, final _) => NeonListView<Widget>( |
|
|
|
builder: (final context, final showHiddenFiles, final _) { |
|
|
|
scrollKey: 'files-${pathSnapshot.requireData.join('/')}', |
|
|
|
final uploadingTasks = tasksSnapshot.requireData |
|
|
|
withFloatingActionButton: true, |
|
|
|
.whereType<FilesUploadTask>() |
|
|
|
items: [ |
|
|
|
.where( |
|
|
|
for (final uploadTask in tasksSnapshot.requireData.whereType<FilesUploadTask>().where( |
|
|
|
|
|
|
|
(final task) => |
|
|
|
(final task) => |
|
|
|
sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, |
|
|
|
sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, |
|
|
|
)) ...[ |
|
|
|
) |
|
|
|
FileListTile( |
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NeonListView( |
|
|
|
|
|
|
|
scrollKey: 'files-${pathSnapshot.requireData.join('/')}', |
|
|
|
|
|
|
|
itemCount: uploadingTasks.length + sorted.length, |
|
|
|
|
|
|
|
itemBuilder: (final context, final index) { |
|
|
|
|
|
|
|
if (index < uploadingTasks.length) { |
|
|
|
|
|
|
|
return FileListTile( |
|
|
|
bloc: widget.filesBloc, |
|
|
|
bloc: widget.filesBloc, |
|
|
|
browserBloc: widget.bloc, |
|
|
|
browserBloc: widget.bloc, |
|
|
|
details: FileDetails.fromUploadTask( |
|
|
|
details: FileDetails.fromUploadTask( |
|
|
|
task: uploadTask, |
|
|
|
task: uploadingTasks[index], |
|
|
|
), |
|
|
|
|
|
|
|
mode: widget.mode, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
for (final file in sorted) ...[ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final file = sorted[index - uploadingTasks.length]; |
|
|
|
if ((widget.mode != FilesBrowserMode.selectDirectory || file.isDirectory) && |
|
|
|
if ((widget.mode != FilesBrowserMode.selectDirectory || file.isDirectory) && |
|
|
|
(!file.isHidden || showHiddenFiles)) ...[ |
|
|
|
(!file.isHidden || showHiddenFiles)) { |
|
|
|
Builder( |
|
|
|
|
|
|
|
builder: (final context) { |
|
|
|
|
|
|
|
final matchingTask = tasksSnapshot.requireData |
|
|
|
final matchingTask = tasksSnapshot.requireData |
|
|
|
.firstWhereOrNull((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
.firstWhereOrNull((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
|
|
|
|
|
|
|
@ -107,19 +111,47 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
bloc: widget.filesBloc, |
|
|
|
bloc: widget.filesBloc, |
|
|
|
browserBloc: widget.bloc, |
|
|
|
browserBloc: widget.bloc, |
|
|
|
details: details, |
|
|
|
details: details, |
|
|
|
mode: widget.mode, |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
isLoading: files.isLoading, |
|
|
|
isLoading: files.isLoading, |
|
|
|
error: files.error, |
|
|
|
error: files.error, |
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
builder: (final context, final widget) => widget, |
|
|
|
|
|
|
|
topScrollingChildren: [ |
|
|
|
topScrollingChildren: [ |
|
|
|
Align( |
|
|
|
FileBrowserNavigator( |
|
|
|
|
|
|
|
path: pathSnapshot.requireData, |
|
|
|
|
|
|
|
bloc: widget.bloc, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality<String>().equals( |
|
|
|
|
|
|
|
[...widget.bloc.path.value, name], |
|
|
|
|
|
|
|
path, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FileBrowserNavigator extends StatelessWidget { |
|
|
|
|
|
|
|
const FileBrowserNavigator({ |
|
|
|
|
|
|
|
required this.path, |
|
|
|
|
|
|
|
required this.bloc, |
|
|
|
|
|
|
|
super.key, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final List<String> path; |
|
|
|
|
|
|
|
final FilesBrowserBloc bloc; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
Widget build(final BuildContext context) => Align( |
|
|
|
alignment: Alignment.topLeft, |
|
|
|
alignment: Alignment.topLeft, |
|
|
|
child: Container( |
|
|
|
child: Container( |
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
@ -130,27 +162,32 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
children: <Widget>[ |
|
|
|
children: <Widget>[ |
|
|
|
IconButton( |
|
|
|
IconButton( |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
|
|
|
visualDensity: const VisualDensity( |
|
|
|
|
|
|
|
horizontal: VisualDensity.minimumDensity, |
|
|
|
|
|
|
|
vertical: VisualDensity.minimumDensity, |
|
|
|
|
|
|
|
), |
|
|
|
tooltip: AppLocalizations.of(context).goToPath(''), |
|
|
|
tooltip: AppLocalizations.of(context).goToPath(''), |
|
|
|
icon: const Icon( |
|
|
|
icon: const Icon( |
|
|
|
Icons.house, |
|
|
|
Icons.house, |
|
|
|
|
|
|
|
size: 30, |
|
|
|
), |
|
|
|
), |
|
|
|
onPressed: () { |
|
|
|
onPressed: () { |
|
|
|
widget.bloc.setPath([]); |
|
|
|
bloc.setPath([]); |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
for (var i = 0; i < pathSnapshot.requireData.length; i++) ...[ |
|
|
|
for (var i = 0; i < path.length; i++) ...[ |
|
|
|
Builder( |
|
|
|
Builder( |
|
|
|
builder: (final context) { |
|
|
|
builder: (final context) { |
|
|
|
final path = pathSnapshot.requireData.sublist(0, i + 1); |
|
|
|
final path = this.path.sublist(0, i + 1); |
|
|
|
return Tooltip( |
|
|
|
return Tooltip( |
|
|
|
message: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
message: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
excludeFromSemantics: true, |
|
|
|
excludeFromSemantics: true, |
|
|
|
child: TextButton( |
|
|
|
child: TextButton( |
|
|
|
onPressed: () { |
|
|
|
onPressed: () { |
|
|
|
widget.bloc.setPath(path); |
|
|
|
bloc.setPath(path); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: Text( |
|
|
|
child: Text( |
|
|
|
pathSnapshot.requireData[i], |
|
|
|
this.path[i], |
|
|
|
semanticsLabel: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
semanticsLabel: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
@ -162,23 +199,11 @@ class _FilesBrowserViewState extends State<FilesBrowserView> { |
|
|
|
.intersperse( |
|
|
|
.intersperse( |
|
|
|
const Icon( |
|
|
|
const Icon( |
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
|
|
|
size: 30, |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
) |
|
|
|
.toList(), |
|
|
|
.toList(), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality<String>().equals( |
|
|
|
|
|
|
|
[...widget.bloc.path.value, name], |
|
|
|
|
|
|
|
path, |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|