Browse Source

feat(neon_files): enable hiding files starting with a '.'

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
pull/604/head
Nikolas Rimikis 1 year ago
parent
commit
c4d38589a7
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 1
      packages/neon/neon_files/lib/l10n/en.arb
  2. 6
      packages/neon/neon_files/lib/l10n/localizations.dart
  3. 3
      packages/neon/neon_files/lib/l10n/localizations_en.dart
  4. 10
      packages/neon/neon_files/lib/options.dart
  5. 8
      packages/neon/neon_files/lib/widgets/browser_view.dart
  6. 11
      packages/nextcloud/lib/src/webdav/file.dart
  7. 1
      packages/nextcloud/pubspec.yaml

1
packages/neon/neon_files/lib/l10n/en.arb

@ -77,6 +77,7 @@
"optionsFilesSortPropertyModifiedDate": "Last modified",
"optionsFilesSortPropertySize": "Size",
"optionsFilesSortOrder": "Sort order of files",
"optionsShowHiddenFiles": "Show hidden files",
"optionsShowPreviews": "Show previews for files",
"optionsUploadQueueParallelism": "Upload queue parallelism",
"optionsDownloadQueueParallelism": "Download queue parallelism",

6
packages/neon/neon_files/lib/l10n/localizations.dart

@ -305,6 +305,12 @@ abstract class AppLocalizations {
/// **'Sort order of files'**
String get optionsFilesSortOrder;
/// No description provided for @optionsShowHiddenFiles.
///
/// In en, this message translates to:
/// **'Show hidden files'**
String get optionsShowHiddenFiles;
/// No description provided for @optionsShowPreviews.
///
/// In en, this message translates to:

3
packages/neon/neon_files/lib/l10n/localizations_en.dart

@ -122,6 +122,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get optionsFilesSortOrder => 'Sort order of files';
@override
String get optionsShowHiddenFiles => 'Show hidden files';
@override
String get optionsShowPreviews => 'Show previews for files';

10
packages/neon/neon_files/lib/options.dart

@ -8,6 +8,7 @@ class FilesAppSpecificOptions extends NextcloudAppOptions {
super.options = [
filesSortPropertyOption,
filesSortBoxOrderOption,
showHiddenFilesOption,
showPreviewsOption,
uploadQueueParallelism,
downloadQueueParallelism,
@ -43,6 +44,14 @@ class FilesAppSpecificOptions extends NextcloudAppOptions {
values: sortBoxOrderOptionValues,
);
late final showHiddenFilesOption = ToggleOption(
storage: super.storage,
category: generalCategory,
key: 'show-hidden-files',
label: (final context) => AppLocalizations.of(context).optionsShowHiddenFiles,
defaultValue: false,
);
late final showPreviewsOption = ToggleOption(
storage: super.storage,
category: generalCategory,
@ -117,4 +126,5 @@ enum FilesSortProperty {
name,
modifiedDate,
size,
isFolder,
}

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

@ -66,7 +66,9 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
(FilesSortProperty.isFolder, SortBoxOrder.ascending),
},
input: files.data,
builder: (final context, final sorted) => NeonListView<Widget>(
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: [
@ -84,7 +86,8 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
),
],
for (final file in sorted) ...[
if (widget.mode != FilesBrowserMode.selectDirectory || file.isDirectory) ...[
if ((widget.mode != FilesBrowserMode.selectDirectory || file.isDirectory) &&
(!file.isHidden || showHiddenFiles)) ...[
Builder(
builder: (final context) {
final matchingTask = tasksSnapshot.requireData
@ -177,6 +180,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
),
),
),
),
);
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality().equals(

11
packages/nextcloud/lib/src/webdav/file.dart

@ -83,12 +83,13 @@ class WebDavFile {
// normalised path (remove trailing slash)
final end = path.endsWith('/') ? path.length - 1 : path.length;
final segments = Uri.parse(path, 0, end).pathSegments;
if (segments.isNotEmpty) {
return segments.last;
}
return '';
return segments.lastOrNull ?? '';
}();
/// Returns if the file is a directory
/// Whether the file is hidden.
late final bool isHidden = name.startsWith('.');
/// Whether the file is a directory
late final bool isDirectory = (isCollection ?? false) || path.endsWith('/');
}

1
packages/nextcloud/pubspec.yaml

@ -8,6 +8,7 @@ environment:
dependencies:
built_collection: ^5.1.1
built_value: ^8.6.2
collection: ^1.17.2
crypto: ^3.0.3
crypton: ^2.2.0
dynamite_runtime:

Loading…
Cancel
Save