This commit is contained in:
Thibault Deckers 2022-12-03 18:24:18 +01:00
parent 1bfbaca794
commit 6b392f84cc
5 changed files with 104 additions and 239 deletions

View file

@ -34,6 +34,7 @@ class AboutTranslators extends StatelessWidget {
Contributor('Igor Sorocean', 'sorocean.igor@gmail.com'), Contributor('Igor Sorocean', 'sorocean.igor@gmail.com'),
Contributor('JY3', 'GeeyunJY3@gmail.com'), Contributor('JY3', 'GeeyunJY3@gmail.com'),
Contributor('Gediminas Murauskas', 'muziejusinfo@gmail.com'), Contributor('Gediminas Murauskas', 'muziejusinfo@gmail.com'),
Contributor('Oğuz Ersen', 'oguz@ersen.moe'),
// Contributor('Allan Nordhøy', 'epost@anotheragency.no'), // Contributor('Allan Nordhøy', 'epost@anotheragency.no'),
// Contributor('Piotr K', '1337.kelt@gmail.com'), // Contributor('Piotr K', '1337.kelt@gmail.com'),
// Contributor('امیر جهانگرد', 'ijahangard.a@gmail.com'), // Contributor('امیر جهانگرد', 'ijahangard.a@gmail.com'),

View file

@ -5,8 +5,8 @@ import 'package:aves/utils/constants.dart';
import 'package:aves/widgets/common/identity/aves_filter_chip.dart'; import 'package:aves/widgets/common/identity/aves_filter_chip.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExpandableFilterRow extends StatelessWidget { class TitledExpandableFilterRow extends StatelessWidget {
final String? title; final String title;
final Iterable<CollectionFilter> filters; final Iterable<CollectionFilter> filters;
final ValueNotifier<String?> expandedNotifier; final ValueNotifier<String?> expandedNotifier;
final bool showGenericIcon; final bool showGenericIcon;
@ -14,9 +14,9 @@ class ExpandableFilterRow extends StatelessWidget {
final FilterCallback onTap; final FilterCallback onTap;
final OffsetFilterCallback? onLongPress; final OffsetFilterCallback? onLongPress;
const ExpandableFilterRow({ const TitledExpandableFilterRow({
super.key, super.key,
this.title, required this.title,
required this.filters, required this.filters,
required this.expandedNotifier, required this.expandedNotifier,
this.showGenericIcon = true, this.showGenericIcon = true,
@ -25,41 +25,85 @@ class ExpandableFilterRow extends StatelessWidget {
required this.onLongPress, required this.onLongPress,
}); });
static const double horizontalPadding = 8;
static const double verticalPadding = 8;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (filters.isEmpty) return const SizedBox(); if (filters.isEmpty) return const SizedBox();
final hasTitle = title != null && title!.isNotEmpty; final isExpanded = expandedNotifier.value == title;
final isExpanded = hasTitle && expandedNotifier.value == title; return Column(
crossAxisAlignment: CrossAxisAlignment.start,
Widget? titleRow; children: [
if (hasTitle) { Padding(
titleRow = Padding( padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(16), child: Row(
child: Row( children: [
children: [ Text(
Text( title,
title!, style: Constants.knownTitleTextStyle,
style: Constants.knownTitleTextStyle, ),
), const Spacer(),
const Spacer(), IconButton(
IconButton( icon: Icon(isExpanded ? AIcons.collapse : AIcons.expand),
icon: Icon(isExpanded ? AIcons.collapse : AIcons.expand), onPressed: () => expandedNotifier.value = isExpanded ? null : title,
onPressed: () => expandedNotifier.value = isExpanded ? null : title, tooltip: isExpanded ? MaterialLocalizations.of(context).expandedIconTapHint : MaterialLocalizations.of(context).collapsedIconTapHint,
tooltip: isExpanded ? MaterialLocalizations.of(context).expandedIconTapHint : MaterialLocalizations.of(context).collapsedIconTapHint, ),
), ],
], ),
), ),
); ExpandableFilterRow(
} filters: filters,
isExpanded: isExpanded,
showGenericIcon: showGenericIcon,
heroTypeBuilder: heroTypeBuilder,
onTap: onTap,
onLongPress: onLongPress,
),
],
);
}
}
class ExpandableFilterRow extends StatelessWidget {
final Iterable<CollectionFilter> filters;
final bool isExpanded;
final bool showGenericIcon;
final HeroType Function(CollectionFilter filter)? heroTypeBuilder;
final FilterCallback onTap;
final OffsetFilterCallback? onLongPress;
static const double horizontalPadding = 8;
static const double verticalPadding = 8;
const ExpandableFilterRow({
super.key,
required this.filters,
required this.isExpanded,
this.showGenericIcon = true,
this.heroTypeBuilder,
required this.onTap,
required this.onLongPress,
});
@override
Widget build(BuildContext context) {
if (filters.isEmpty) return const SizedBox();
return AnimatedSwitcher(
duration: Durations.filterRowExpandAnimation,
layoutBuilder: (currentChild, previousChildren) => Stack(
children: [
...previousChildren,
if (currentChild != null) currentChild,
],
),
child: isExpanded ? _buildExpanded() : _buildCollapsed(),
);
}
Widget _buildExpanded() {
final filterList = filters.toList(); final filterList = filters.toList();
final wrap = Container( return Container(
key: Key('wrap$title'), key: const Key('wrap'),
padding: const EdgeInsets.symmetric(horizontal: horizontalPadding), padding: const EdgeInsets.symmetric(horizontal: horizontalPadding),
// specify transparent as a workaround to prevent // specify transparent as a workaround to prevent
// chip border clipping when the floating app bar is fading // chip border clipping when the floating app bar is fading
@ -67,11 +111,15 @@ class ExpandableFilterRow extends StatelessWidget {
child: Wrap( child: Wrap(
spacing: horizontalPadding, spacing: horizontalPadding,
runSpacing: verticalPadding, runSpacing: verticalPadding,
children: filterList.map(_buildFilterChip).toList(), children: filterList.map(_buildChip).toList(),
), ),
); );
}
Widget _buildCollapsed() {
final filterList = filters.toList();
final list = Container( final list = Container(
key: Key('list$title'), key: const Key('list'),
// specify transparent as a workaround to prevent // specify transparent as a workaround to prevent
// chip border clipping when the floating app bar is fading // chip border clipping when the floating app bar is fading
color: Colors.transparent, color: Colors.transparent,
@ -80,34 +128,16 @@ class ExpandableFilterRow extends StatelessWidget {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: horizontalPadding), padding: const EdgeInsets.symmetric(horizontal: horizontalPadding),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return index < filterList.length ? _buildFilterChip(filterList[index]) : const SizedBox(); return index < filterList.length ? _buildChip(filterList[index]) : const SizedBox();
}, },
separatorBuilder: (context, index) => const SizedBox(width: 8), separatorBuilder: (context, index) => const SizedBox(width: 8),
itemCount: filterList.length, itemCount: filterList.length,
), ),
); );
final filterChips = isExpanded ? wrap : list; return list;
return titleRow != null
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
titleRow,
AnimatedSwitcher(
duration: Durations.filterRowExpandAnimation,
layoutBuilder: (currentChild, previousChildren) => Stack(
children: [
...previousChildren,
if (currentChild != null) currentChild,
],
),
child: filterChips,
),
],
)
: filterChips;
} }
Widget _buildFilterChip(CollectionFilter filter) { Widget _buildChip(CollectionFilter filter) {
return AvesFilterChip( return AvesFilterChip(
// key `album-{path}` is expected by test driver // key `album-{path}` is expected by test driver
key: Key(filter.key), key: Key(filter.key),

View file

@ -245,7 +245,7 @@ class _FilterRow extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return filters.isEmpty return filters.isEmpty
? const SizedBox() ? const SizedBox()
: ExpandableFilterRow( : TitledExpandableFilterRow(
title: title, title: title,
filters: filters, filters: filters,
expandedNotifier: expandedNotifier, expandedNotifier: expandedNotifier,

View file

@ -132,14 +132,24 @@ class CollectionSearchDelegate extends AvesSearchDelegate {
required List<CollectionFilter> filters, required List<CollectionFilter> filters,
HeroType Function(CollectionFilter filter)? heroTypeBuilder, HeroType Function(CollectionFilter filter)? heroTypeBuilder,
}) { }) {
return ExpandableFilterRow( void onTap(filter) => _select(context, filter is QueryFilter ? QueryFilter(filter.query) : filter);
title: title, const onLongPress = AvesFilterChip.showDefaultLongPressMenu;
filters: filters, return title != null
expandedNotifier: _expandedSectionNotifier, ? TitledExpandableFilterRow(
heroTypeBuilder: heroTypeBuilder, title: title,
onTap: (filter) => _select(context, filter is QueryFilter ? QueryFilter(filter.query) : filter), filters: filters,
onLongPress: AvesFilterChip.showDefaultLongPressMenu, expandedNotifier: _expandedSectionNotifier,
); heroTypeBuilder: heroTypeBuilder,
onTap: onTap,
onLongPress: onLongPress,
)
: ExpandableFilterRow(
filters: filters,
isExpanded: false,
heroTypeBuilder: heroTypeBuilder,
onTap: onTap,
onLongPress: onLongPress,
);
} }
Widget _buildDateFilters(BuildContext context, _ContainQuery containQuery) { Widget _buildDateFilters(BuildContext context, _ContainQuery containQuery) {

View file

@ -593,20 +593,6 @@
"filePickerUseThisFolder" "filePickerUseThisFolder"
], ],
"de": [
"filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel",
"filterNoAddressLabel",
"subtitlePositionTop",
"subtitlePositionBottom",
"widgetDisplayedItemRandom",
"widgetDisplayedItemMostRecent",
"settingsViewerShowRatingTags",
"settingsSubtitleThemeTextPositionTile",
"settingsSubtitleThemeTextPositionDialogTitle",
"settingsWidgetDisplayedItem"
],
"el": [ "el": [
"filterAspectRatioLandscapeLabel", "filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel", "filterAspectRatioPortraitLabel",
@ -614,13 +600,6 @@
"settingsViewerShowRatingTags" "settingsViewerShowRatingTags"
], ],
"es": [
"filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel",
"filterNoAddressLabel",
"settingsViewerShowRatingTags"
],
"fa": [ "fa": [
"appName", "appName",
"welcomeMessage", "welcomeMessage",
@ -1215,13 +1194,6 @@
"filePickerUseThisFolder" "filePickerUseThisFolder"
], ],
"fr": [
"filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel",
"filterNoAddressLabel",
"settingsViewerShowRatingTags"
],
"gl": [ "gl": [
"entryInfoActionExportMetadata", "entryInfoActionExportMetadata",
"filterAspectRatioLandscapeLabel", "filterAspectRatioLandscapeLabel",
@ -1721,145 +1693,6 @@
"settingsWidgetDisplayedItem" "settingsWidgetDisplayedItem"
], ],
"ko": [
"filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel",
"filterNoAddressLabel",
"settingsViewerShowRatingTags"
],
"lt": [
"filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel",
"filterNoAddressLabel",
"settingsViewerShowRatingTags"
],
"nb": [
"videoActionCaptureFrame",
"videoActionSelectStreams",
"entryInfoActionEditLocation",
"entryInfoActionExportMetadata",
"filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel",
"filterNoAddressLabel",
"coordinateFormatDms",
"mapStyleHuaweiNormal",
"mapStyleHuaweiTerrain",
"mapStyleStamenToner",
"mapStyleStamenWatercolor",
"keepScreenOnViewerOnly",
"subtitlePositionTop",
"subtitlePositionBottom",
"viewerTransitionFade",
"widgetDisplayedItemRandom",
"widgetDisplayedItemMostRecent",
"albumTierSpecial",
"storageAccessDialogMessage",
"restrictedAccessDialogMessage",
"notEnoughSpaceDialogMessage",
"missingSystemFilePickerDialogMessage",
"unsupportedTypeDialogMessage",
"binEntriesConfirmationDialogMessage",
"deleteEntriesConfirmationDialogMessage",
"moveUndatedConfirmationDialogMessage",
"setCoverDialogLatest",
"hideFilterConfirmationDialogMessage",
"deleteSingleAlbumConfirmationDialogMessage",
"deleteMultiAlbumConfirmationDialogMessage",
"editEntryDateDialogExtractFromTitle",
"editEntryDateDialogShift",
"editEntryDateDialogSourceFileModifiedDate",
"editEntryLocationDialogTitle",
"editEntryLocationDialogSetCustom",
"locationPickerUseThisLocationButton",
"removeEntryMetadataMotionPhotoXmpWarningDialogMessage",
"videoStreamSelectionDialogText",
"videoStreamSelectionDialogTrack",
"videoStreamSelectionDialogNoSelection",
"viewDialogLayoutSectionTitle",
"viewDialogReverseSortOrder",
"tileLayoutMosaic",
"collectionDeleteFailureFeedback",
"collectionCopyFailureFeedback",
"collectionMoveFailureFeedback",
"collectionRenameFailureFeedback",
"collectionEditFailureFeedback",
"collectionExportFailureFeedback",
"collectionCopySuccessFeedback",
"collectionMoveSuccessFeedback",
"collectionRenameSuccessFeedback",
"collectionEditSuccessFeedback",
"collectionSelectSectionTooltip",
"collectionDeselectSectionTooltip",
"albumGroupTier",
"settingsConfirmationBeforeDeleteItems",
"settingsConfirmationBeforeMoveToBinItems",
"settingsConfirmationBeforeMoveUndatedItems",
"settingsConfirmationAfterMoveToBinItems",
"settingsNavigationDrawerBanner",
"settingsThumbnailOverlayTile",
"settingsThumbnailOverlayPageTitle",
"settingsThumbnailShowFavouriteIcon",
"settingsThumbnailShowTagIcon",
"settingsThumbnailShowLocationIcon",
"settingsThumbnailShowMotionPhotoIcon",
"settingsThumbnailShowRating",
"settingsThumbnailShowRawIcon",
"settingsThumbnailShowVideoDuration",
"settingsCollectionQuickActionsTile",
"settingsCollectionQuickActionEditorPageTitle",
"settingsCollectionQuickActionTabBrowsing",
"settingsCollectionQuickActionTabSelecting",
"settingsCollectionBrowsingQuickActionEditorBanner",
"settingsCollectionSelectionQuickActionEditorBanner",
"settingsViewerSectionTitle",
"settingsViewerGestureSideTapNext",
"settingsViewerUseCutout",
"settingsViewerMaximumBrightness",
"settingsMotionPhotoAutoPlay",
"settingsImageBackground",
"settingsViewerQuickActionEditorBanner",
"settingsViewerQuickActionEditorDisplayedButtonsSectionTitle",
"settingsViewerQuickActionEditorAvailableButtonsSectionTitle",
"settingsViewerQuickActionEmpty",
"settingsViewerOverlayTile",
"settingsViewerOverlayPageTitle",
"settingsViewerShowOverlayOnOpening",
"settingsViewerShowRatingTags",
"settingsViewerShowShootingDetails",
"settingsViewerEnableOverlayBlurEffect",
"settingsSlideshowShuffle",
"settingsSubtitleThemeSample",
"settingsSubtitleThemeTextPositionTile",
"settingsSubtitleThemeTextPositionDialogTitle",
"settingsAllowInstalledAppAccess",
"settingsAllowMediaManagement",
"settingsHiddenFiltersBanner",
"settingsHiddenFiltersEmpty",
"settingsHiddenItemsTabPaths",
"settingsHiddenPathsBanner",
"addPathTooltip",
"settingsStorageAccessTile",
"settingsStorageAccessBanner",
"settingsStorageAccessEmpty",
"settingsTimeToTakeActionTile",
"settingsThemeColorHighlights",
"settingsDisplayRefreshRateModeTile",
"settingsDisplayRefreshRateModeDialogTitle",
"settingsWidgetDisplayedItem",
"statsWithGps",
"viewerErrorDoesNotExist",
"mapAttributionStamen",
"mapEmptyRegion",
"viewerInfoOpenEmbeddedFailureFeedback",
"viewerInfoSearchEmpty",
"wallpaperUseScrollEffect",
"tagEditorSectionPlaceholders",
"tagPlaceholderCountry",
"tagPlaceholderPlace"
],
"nl": [ "nl": [
"entryInfoActionExportMetadata", "entryInfoActionExportMetadata",
"filterAspectRatioLandscapeLabel", "filterAspectRatioLandscapeLabel",
@ -2779,19 +2612,10 @@
"filePickerUseThisFolder" "filePickerUseThisFolder"
], ],
"tr": [
"filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel",
"filterNoAddressLabel",
"settingsViewerShowRatingTags"
],
"zh": [ "zh": [
"filterAspectRatioLandscapeLabel", "filterAspectRatioLandscapeLabel",
"filterAspectRatioPortraitLabel", "filterAspectRatioPortraitLabel",
"filterNoAddressLabel", "filterNoAddressLabel",
"aboutLicensesFlutterPackagesSectionTitle",
"aboutLicensesDartPackagesSectionTitle",
"settingsViewerShowRatingTags" "settingsViewerShowRatingTags"
] ]
} }