Browse Source

Merge pull request #780 from nextcloud/refactor/files-browser-initial-path

refactor(neon_files): Allow setting an intial path for files browser bloc
pull/790/head
Kate 1 year ago committed by GitHub
parent
commit
22559ad04f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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 { class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents, FilesBrowserBlocStates {
FilesBrowserBloc( FilesBrowserBloc(
this.options, this.options,
this.account, this.account, {
) { final List<String>? initialPath,
}) {
if (initialPath != null) {
path.add(initialPath);
}
unawaited(refresh()); 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)); tasks.add(tasks.value..remove(task));
} }
FilesBrowserBloc getNewFilesBrowserBloc() => FilesBrowserBloc(options, account); FilesBrowserBloc getNewFilesBrowserBloc({
final List<String>? initialPath,
}) =>
FilesBrowserBloc(
options,
account,
initialPath: initialPath,
);
void _downloadParallelismListener() { void _downloadParallelismListener() {
_downloadQueue.parallel = options.downloadQueueParallelism.value; _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) { if (!context.mounted) {
return; return;
} }
final b = bloc.getNewFilesBrowserBloc();
final originalPath = details.path.sublist(0, details.path.length - 1); 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>?>( final result = await showDialog<List<String>?>(
context: context, context: context,
builder: (final context) => FilesChooseFolderDialog( builder: (final context) => FilesChooseFolderDialog(
@ -67,9 +66,8 @@ class FileActions extends StatelessWidget {
if (!context.mounted) { if (!context.mounted) {
return; return;
} }
final b = bloc.getNewFilesBrowserBloc();
final originalPath = details.path.sublist(0, details.path.length - 1); 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>?>( final result = await showDialog<List<String>?>(
context: context, context: context,
builder: (final context) => FilesChooseFolderDialog( builder: (final context) => FilesChooseFolderDialog(

Loading…
Cancel
Save