|
|
|
@ -68,108 +68,65 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
|
|
|
|
|
input: files.data, |
|
|
|
|
builder: (final context, final sorted) => ValueListenableBuilder( |
|
|
|
|
valueListenable: widget.bloc.options.showHiddenFilesOption, |
|
|
|
|
builder: (final context, final showHiddenFiles, final _) => NeonListView<Widget>( |
|
|
|
|
scrollKey: 'files-${pathSnapshot.requireData.join('/')}', |
|
|
|
|
withFloatingActionButton: true, |
|
|
|
|
items: [ |
|
|
|
|
for (final uploadTask in tasksSnapshot.requireData.whereType<FilesUploadTask>().where( |
|
|
|
|
(final task) => |
|
|
|
|
sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, |
|
|
|
|
)) ...[ |
|
|
|
|
FileListTile( |
|
|
|
|
bloc: widget.filesBloc, |
|
|
|
|
browserBloc: widget.bloc, |
|
|
|
|
details: FileDetails.fromUploadTask( |
|
|
|
|
task: uploadTask, |
|
|
|
|
), |
|
|
|
|
mode: widget.mode, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
for (final file in sorted) ...[ |
|
|
|
|
builder: (final context, final showHiddenFiles, final _) { |
|
|
|
|
final uploadingTasks = tasksSnapshot.requireData |
|
|
|
|
.whereType<FilesUploadTask>() |
|
|
|
|
.where( |
|
|
|
|
(final task) => |
|
|
|
|
sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, |
|
|
|
|
) |
|
|
|
|
.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, |
|
|
|
|
browserBloc: widget.bloc, |
|
|
|
|
details: FileDetails.fromUploadTask( |
|
|
|
|
task: uploadingTasks[index], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final file = sorted[index - uploadingTasks.length]; |
|
|
|
|
if ((widget.mode != FilesBrowserMode.selectDirectory || file.isDirectory) && |
|
|
|
|
(!file.isHidden || showHiddenFiles)) ...[ |
|
|
|
|
Builder( |
|
|
|
|
builder: (final context) { |
|
|
|
|
final matchingTask = tasksSnapshot.requireData |
|
|
|
|
.firstWhereOrNull((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
|
|
|
|
|
|
final details = matchingTask != null |
|
|
|
|
? FileDetails.fromTask( |
|
|
|
|
task: matchingTask, |
|
|
|
|
file: file, |
|
|
|
|
) |
|
|
|
|
: FileDetails.fromWebDav( |
|
|
|
|
file: file, |
|
|
|
|
path: widget.bloc.path.value, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return FileListTile( |
|
|
|
|
bloc: widget.filesBloc, |
|
|
|
|
browserBloc: widget.bloc, |
|
|
|
|
details: details, |
|
|
|
|
mode: widget.mode, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
], |
|
|
|
|
], |
|
|
|
|
isLoading: files.isLoading, |
|
|
|
|
error: files.error, |
|
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
|
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>[ |
|
|
|
|
IconButton( |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
tooltip: AppLocalizations.of(context).goToPath(''), |
|
|
|
|
icon: const Icon( |
|
|
|
|
Icons.house, |
|
|
|
|
), |
|
|
|
|
onPressed: () { |
|
|
|
|
widget.bloc.setPath([]); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
for (var i = 0; i < pathSnapshot.requireData.length; i++) ...[ |
|
|
|
|
Builder( |
|
|
|
|
builder: (final context) { |
|
|
|
|
final path = pathSnapshot.requireData.sublist(0, i + 1); |
|
|
|
|
return Tooltip( |
|
|
|
|
message: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
|
excludeFromSemantics: true, |
|
|
|
|
child: TextButton( |
|
|
|
|
onPressed: () { |
|
|
|
|
widget.bloc.setPath(path); |
|
|
|
|
}, |
|
|
|
|
child: Text( |
|
|
|
|
pathSnapshot.requireData[i], |
|
|
|
|
semanticsLabel: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
] |
|
|
|
|
.intersperse( |
|
|
|
|
const Icon( |
|
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
), |
|
|
|
|
(!file.isHidden || showHiddenFiles)) { |
|
|
|
|
final matchingTask = tasksSnapshot.requireData |
|
|
|
|
.firstWhereOrNull((final task) => _pathMatchesFile(task.path, file.name)); |
|
|
|
|
|
|
|
|
|
final details = matchingTask != null |
|
|
|
|
? FileDetails.fromTask( |
|
|
|
|
task: matchingTask, |
|
|
|
|
file: file, |
|
|
|
|
) |
|
|
|
|
.toList(), |
|
|
|
|
), |
|
|
|
|
: FileDetails.fromWebDav( |
|
|
|
|
file: file, |
|
|
|
|
path: widget.bloc.path.value, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return FileListTile( |
|
|
|
|
bloc: widget.filesBloc, |
|
|
|
|
browserBloc: widget.bloc, |
|
|
|
|
details: details, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
}, |
|
|
|
|
isLoading: files.isLoading, |
|
|
|
|
error: files.error, |
|
|
|
|
onRefresh: widget.bloc.refresh, |
|
|
|
|
topScrollingChildren: [ |
|
|
|
|
FileBrowserNavigator( |
|
|
|
|
path: pathSnapshot.requireData, |
|
|
|
|
bloc: widget.bloc, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -182,3 +139,71 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
|
|
|
|
|
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, |
|
|
|
|
child: Container( |
|
|
|
|
margin: const EdgeInsets.symmetric( |
|
|
|
|
horizontal: 10, |
|
|
|
|
), |
|
|
|
|
child: Wrap( |
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center, |
|
|
|
|
children: <Widget>[ |
|
|
|
|
IconButton( |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
visualDensity: const VisualDensity( |
|
|
|
|
horizontal: VisualDensity.minimumDensity, |
|
|
|
|
vertical: VisualDensity.minimumDensity, |
|
|
|
|
), |
|
|
|
|
tooltip: AppLocalizations.of(context).goToPath(''), |
|
|
|
|
icon: const Icon( |
|
|
|
|
Icons.house, |
|
|
|
|
size: 30, |
|
|
|
|
), |
|
|
|
|
onPressed: () { |
|
|
|
|
bloc.setPath([]); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
for (var i = 0; i < path.length; i++) ...[ |
|
|
|
|
Builder( |
|
|
|
|
builder: (final context) { |
|
|
|
|
final path = this.path.sublist(0, i + 1); |
|
|
|
|
return Tooltip( |
|
|
|
|
message: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
|
excludeFromSemantics: true, |
|
|
|
|
child: TextButton( |
|
|
|
|
onPressed: () { |
|
|
|
|
bloc.setPath(path); |
|
|
|
|
}, |
|
|
|
|
child: Text( |
|
|
|
|
this.path[i], |
|
|
|
|
semanticsLabel: AppLocalizations.of(context).goToPath(path.join('/')), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
] |
|
|
|
|
.intersperse( |
|
|
|
|
const Icon( |
|
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
size: 30, |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
.toList(), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|