Browse Source

refactor(neon_files): Allow setting an intial path for files browser bloc

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/780/head
jld3103 1 year ago
parent
commit
00392b4556
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 9
      packages/neon/neon_files/lib/blocs/browser.dart
  2. 9
      packages/neon/neon_files/lib/blocs/files.dart
  3. 6
      packages/neon/neon_files/lib/widgets/actions.dart

9
packages/neon/neon_files/lib/blocs/browser.dart

@ -15,8 +15,13 @@ abstract interface class FilesBrowserBlocStates {
class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents, FilesBrowserBlocStates {
FilesBrowserBloc(
this.options,
this.account,
) {
this.account, {
final List<String>? initialPath,
}) {
if (initialPath != null) {
path.add(initialPath);
}
unawaited(refresh());
}

9
packages/neon/neon_files/lib/blocs/files.dart

@ -177,7 +177,14 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
tasks.add(tasks.value..remove(task));
}
FilesBrowserBloc getNewFilesBrowserBloc() => FilesBrowserBloc(options, account);
FilesBrowserBloc getNewFilesBrowserBloc({
final List<String>? initialPath,
}) =>
FilesBrowserBloc(
options,
account,
initialPath: initialPath,
);
void _downloadParallelismListener() {
_downloadQueue.parallel = options.downloadQueueParallelism.value;

6
packages/neon/neon_files/lib/widgets/actions.dart

@ -48,9 +48,8 @@ class FileActions extends StatelessWidget {
if (!context.mounted) {
return;
}
final b = bloc.getNewFilesBrowserBloc();
final originalPath = details.path.sublist(0, details.path.length - 1);
b.setPath(originalPath);
final b = bloc.getNewFilesBrowserBloc(initialPath: originalPath);
final result = await showDialog<List<String>?>(
context: context,
builder: (final context) => FilesChooseFolderDialog(
@ -67,9 +66,8 @@ class FileActions extends StatelessWidget {
if (!context.mounted) {
return;
}
final b = bloc.getNewFilesBrowserBloc();
final originalPath = details.path.sublist(0, details.path.length - 1);
b.setPath(originalPath);
final b = bloc.getNewFilesBrowserBloc(initialPath: originalPath);
final result = await showDialog<List<String>?>(
context: context,
builder: (final context) => FilesChooseFolderDialog(

Loading…
Cancel
Save