added chip long press override parameter
This commit is contained in:
parent
56c985403f
commit
d8d157a832
10 changed files with 35 additions and 20 deletions
|
@ -108,7 +108,7 @@ class _FilterBarState extends State<FilterBar> {
|
||||||
filter: filter,
|
filter: filter,
|
||||||
removable: true,
|
removable: true,
|
||||||
heroType: HeroType.always,
|
heroType: HeroType.always,
|
||||||
onPressed: (filter) {
|
onTap: (filter) {
|
||||||
_userRemovedFilter = filter;
|
_userRemovedFilter = filter;
|
||||||
widget.onPressed(filter);
|
widget.onPressed(filter);
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,14 +10,14 @@ class ExpandableFilterRow extends StatelessWidget {
|
||||||
final Iterable<CollectionFilter> filters;
|
final Iterable<CollectionFilter> filters;
|
||||||
final ValueNotifier<String> expandedNotifier;
|
final ValueNotifier<String> expandedNotifier;
|
||||||
final HeroType Function(CollectionFilter filter) heroTypeBuilder;
|
final HeroType Function(CollectionFilter filter) heroTypeBuilder;
|
||||||
final FilterCallback onPressed;
|
final FilterCallback onTap;
|
||||||
|
|
||||||
const ExpandableFilterRow({
|
const ExpandableFilterRow({
|
||||||
this.title,
|
this.title,
|
||||||
@required this.filters,
|
@required this.filters,
|
||||||
this.expandedNotifier,
|
this.expandedNotifier,
|
||||||
this.heroTypeBuilder,
|
this.heroTypeBuilder,
|
||||||
@required this.onPressed,
|
@required this.onTap,
|
||||||
});
|
});
|
||||||
|
|
||||||
static const double horizontalPadding = 8;
|
static const double horizontalPadding = 8;
|
||||||
|
@ -107,7 +107,7 @@ class ExpandableFilterRow extends StatelessWidget {
|
||||||
key: Key(filter.key),
|
key: Key(filter.key),
|
||||||
filter: filter,
|
filter: filter,
|
||||||
heroType: heroTypeBuilder?.call(filter) ?? HeroType.onTap,
|
heroType: heroTypeBuilder?.call(filter) ?? HeroType.onTap,
|
||||||
onPressed: onPressed,
|
onTap: onTap,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ class ImageSearchDelegate {
|
||||||
filters: filters,
|
filters: filters,
|
||||||
expandedNotifier: expandedSectionNotifier,
|
expandedNotifier: expandedSectionNotifier,
|
||||||
heroTypeBuilder: heroTypeBuilder,
|
heroTypeBuilder: heroTypeBuilder,
|
||||||
onPressed: (filter) => _select(context, filter is QueryFilter ? QueryFilter(filter.query) : filter),
|
onTap: (filter) => _select(context, filter is QueryFilter ? QueryFilter(filter.query) : filter),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
|
||||||
icon: AIcons.album,
|
icon: AIcons.album,
|
||||||
text: 'No albums',
|
text: 'No albums',
|
||||||
),
|
),
|
||||||
onPressed: (filter) => Navigator.pop<String>(context, (filter as AlbumFilter)?.album),
|
onTap: (filter) => Navigator.pop<String>(context, (filter as AlbumFilter)?.album),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:aves/widgets/common/icons.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
typedef FilterCallback = void Function(CollectionFilter filter);
|
typedef FilterCallback = void Function(CollectionFilter filter);
|
||||||
|
typedef OffsetFilterCallback = void Function(CollectionFilter filter, Offset tapPosition);
|
||||||
|
|
||||||
enum HeroType { always, onTap, never }
|
enum HeroType { always, onTap, never }
|
||||||
|
|
||||||
|
@ -13,7 +14,8 @@ class AvesFilterChip extends StatefulWidget {
|
||||||
final Widget background;
|
final Widget background;
|
||||||
final Widget details;
|
final Widget details;
|
||||||
final HeroType heroType;
|
final HeroType heroType;
|
||||||
final FilterCallback onPressed;
|
final FilterCallback onTap;
|
||||||
|
final OffsetFilterCallback onLongPress;
|
||||||
|
|
||||||
static final BorderRadius borderRadius = BorderRadius.circular(32);
|
static final BorderRadius borderRadius = BorderRadius.circular(32);
|
||||||
static const double outlineWidth = 2;
|
static const double outlineWidth = 2;
|
||||||
|
@ -31,7 +33,8 @@ class AvesFilterChip extends StatefulWidget {
|
||||||
this.background,
|
this.background,
|
||||||
this.details,
|
this.details,
|
||||||
this.heroType = HeroType.onTap,
|
this.heroType = HeroType.onTap,
|
||||||
@required this.onPressed,
|
@required this.onTap,
|
||||||
|
this.onLongPress,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -42,6 +45,7 @@ class _AvesFilterChipState extends State<AvesFilterChip> {
|
||||||
Future<Color> _colorFuture;
|
Future<Color> _colorFuture;
|
||||||
Color _outlineColor;
|
Color _outlineColor;
|
||||||
bool _tapped;
|
bool _tapped;
|
||||||
|
Offset _tapPosition;
|
||||||
|
|
||||||
CollectionFilter get filter => widget.filter;
|
CollectionFilter get filter => widget.filter;
|
||||||
|
|
||||||
|
@ -160,12 +164,14 @@ class _AvesFilterChipState extends State<AvesFilterChip> {
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: widget.onPressed != null
|
onTapDown: (details) => _tapPosition = details.globalPosition,
|
||||||
|
onTap: widget.onTap != null
|
||||||
? () {
|
? () {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => widget.onPressed(filter));
|
WidgetsBinding.instance.addPostFrameCallback((_) => widget.onTap(filter));
|
||||||
setState(() => _tapped = true);
|
setState(() => _tapped = true);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
onLongPress: widget.onLongPress != null ? () => widget.onLongPress(filter, _tapPosition) : null,
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
child: FutureBuilder<Color>(
|
child: FutureBuilder<Color>(
|
||||||
future: _colorFuture,
|
future: _colorFuture,
|
||||||
|
|
|
@ -16,14 +16,16 @@ class DecoratedFilterChip extends StatelessWidget {
|
||||||
final CollectionSource source;
|
final CollectionSource source;
|
||||||
final CollectionFilter filter;
|
final CollectionFilter filter;
|
||||||
final ImageEntry entry;
|
final ImageEntry entry;
|
||||||
final FilterCallback onPressed;
|
final FilterCallback onTap;
|
||||||
|
final OffsetFilterCallback onLongPress;
|
||||||
|
|
||||||
const DecoratedFilterChip({
|
const DecoratedFilterChip({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.source,
|
@required this.source,
|
||||||
@required this.filter,
|
@required this.filter,
|
||||||
@required this.entry,
|
@required this.entry,
|
||||||
@required this.onPressed,
|
@required this.onTap,
|
||||||
|
this.onLongPress,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -45,7 +47,8 @@ class DecoratedFilterChip extends StatelessWidget {
|
||||||
showGenericIcon: false,
|
showGenericIcon: false,
|
||||||
background: backgroundImage,
|
background: backgroundImage,
|
||||||
details: _buildDetails(filter),
|
details: _buildDetails(filter),
|
||||||
onPressed: onPressed,
|
onTap: onTap,
|
||||||
|
onLongPress: onLongPress,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ class FilterNavigationPage extends StatelessWidget {
|
||||||
final Map<String, ImageEntry> filterEntries;
|
final Map<String, ImageEntry> filterEntries;
|
||||||
final CollectionFilter Function(String key) filterBuilder;
|
final CollectionFilter Function(String key) filterBuilder;
|
||||||
final Widget Function() emptyBuilder;
|
final Widget Function() emptyBuilder;
|
||||||
|
final OffsetFilterCallback onLongPress;
|
||||||
|
|
||||||
const FilterNavigationPage({
|
const FilterNavigationPage({
|
||||||
@required this.source,
|
@required this.source,
|
||||||
|
@ -40,6 +41,7 @@ class FilterNavigationPage extends StatelessWidget {
|
||||||
@required this.filterEntries,
|
@required this.filterEntries,
|
||||||
@required this.filterBuilder,
|
@required this.filterBuilder,
|
||||||
@required this.emptyBuilder,
|
@required this.emptyBuilder,
|
||||||
|
this.onLongPress,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -66,7 +68,7 @@ class FilterNavigationPage extends StatelessWidget {
|
||||||
return sourceState != SourceState.loading && emptyBuilder != null ? emptyBuilder() : SizedBox.shrink();
|
return sourceState != SourceState.loading && emptyBuilder != null ? emptyBuilder() : SizedBox.shrink();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
onPressed: (filter) => Navigator.pushAndRemoveUntil(
|
onTap: (filter) => Navigator.pushAndRemoveUntil(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
settings: RouteSettings(name: CollectionPage.routeName),
|
settings: RouteSettings(name: CollectionPage.routeName),
|
||||||
|
@ -79,6 +81,7 @@ class FilterNavigationPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
settings.navRemoveRoutePredicate(CollectionPage.routeName),
|
settings.navRemoveRoutePredicate(CollectionPage.routeName),
|
||||||
),
|
),
|
||||||
|
onLongPress: onLongPress,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +126,8 @@ class FilterGridPage extends StatelessWidget {
|
||||||
final Map<String, ImageEntry> filterEntries;
|
final Map<String, ImageEntry> filterEntries;
|
||||||
final CollectionFilter Function(String key) filterBuilder;
|
final CollectionFilter Function(String key) filterBuilder;
|
||||||
final Widget Function() emptyBuilder;
|
final Widget Function() emptyBuilder;
|
||||||
final FilterCallback onPressed;
|
final FilterCallback onTap;
|
||||||
|
final OffsetFilterCallback onLongPress;
|
||||||
|
|
||||||
const FilterGridPage({
|
const FilterGridPage({
|
||||||
@required this.source,
|
@required this.source,
|
||||||
|
@ -131,7 +135,8 @@ class FilterGridPage extends StatelessWidget {
|
||||||
@required this.filterEntries,
|
@required this.filterEntries,
|
||||||
@required this.filterBuilder,
|
@required this.filterBuilder,
|
||||||
@required this.emptyBuilder,
|
@required this.emptyBuilder,
|
||||||
@required this.onPressed,
|
@required this.onTap,
|
||||||
|
this.onLongPress,
|
||||||
});
|
});
|
||||||
|
|
||||||
List<String> get filterKeys => filterEntries.keys.toList();
|
List<String> get filterKeys => filterEntries.keys.toList();
|
||||||
|
@ -169,7 +174,8 @@ class FilterGridPage extends StatelessWidget {
|
||||||
source: source,
|
source: source,
|
||||||
filter: filterBuilder(key),
|
filter: filterBuilder(key),
|
||||||
entry: filterEntries[key],
|
entry: filterEntries[key],
|
||||||
onPressed: onPressed,
|
onTap: onTap,
|
||||||
|
onLongPress: onLongPress,
|
||||||
);
|
);
|
||||||
return AnimationConfiguration.staggeredGrid(
|
return AnimationConfiguration.staggeredGrid(
|
||||||
position: i,
|
position: i,
|
||||||
|
|
|
@ -74,7 +74,7 @@ class BasicSection extends StatelessWidget {
|
||||||
children: effectiveFilters
|
children: effectiveFilters
|
||||||
.map((filter) => AvesFilterChip(
|
.map((filter) => AvesFilterChip(
|
||||||
filter: filter,
|
filter: filter,
|
||||||
onPressed: onFilter,
|
onTap: onFilter,
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
|
|
|
@ -119,7 +119,7 @@ class _LocationSectionState extends State<LocationSection> {
|
||||||
children: filters
|
children: filters
|
||||||
.map((filter) => AvesFilterChip(
|
.map((filter) => AvesFilterChip(
|
||||||
filter: filter,
|
filter: filter,
|
||||||
onPressed: widget.onFilter,
|
onTap: widget.onFilter,
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
|
|
|
@ -54,7 +54,7 @@ class FilterTable extends StatelessWidget {
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: AvesFilterChip(
|
child: AvesFilterChip(
|
||||||
filter: filter,
|
filter: filter,
|
||||||
onPressed: (filter) => _goToCollection(context, filter),
|
onTap: (filter) => _goToCollection(context, filter),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (showPercentIndicator)
|
if (showPercentIndicator)
|
||||||
|
|
Loading…
Reference in a new issue