groups: scroll to top on group change
This commit is contained in:
parent
244c1a293d
commit
5358a38bd8
1 changed files with 21 additions and 0 deletions
|
@ -473,6 +473,8 @@ class _FilterSectionedContentState<T extends CollectionFilter> extends State<_Fi
|
||||||
|
|
||||||
final GlobalKey scrollableKey = GlobalKey(debugLabel: 'filter-grid-page-scrollable');
|
final GlobalKey scrollableKey = GlobalKey(debugLabel: 'filter-grid-page-scrollable');
|
||||||
|
|
||||||
|
FilterGrouping? _grouping;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -480,6 +482,14 @@ class _FilterSectionedContentState<T extends CollectionFilter> extends State<_Fi
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => _checkInitHighlight());
|
WidgetsBinding.instance.addPostFrameCallback((_) => _checkInitHighlight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
_unregisterDependencies();
|
||||||
|
_grouping = context.read<FilterGrouping?>();
|
||||||
|
_registerDependencies();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant _FilterSectionedContent<T> oldWidget) {
|
void didUpdateWidget(covariant _FilterSectionedContent<T> oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
|
@ -489,10 +499,19 @@ class _FilterSectionedContentState<T extends CollectionFilter> extends State<_Fi
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_unregisterDependencies();
|
||||||
_unregisterWidget(widget);
|
_unregisterWidget(widget);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _registerDependencies() {
|
||||||
|
_grouping?.addListener(_scrollToTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _unregisterDependencies() {
|
||||||
|
_grouping?.removeListener(_scrollToTop);
|
||||||
|
}
|
||||||
|
|
||||||
void _registerWidget(_FilterSectionedContent<T> widget) {
|
void _registerWidget(_FilterSectionedContent<T> widget) {
|
||||||
widget.appBarHeightNotifier.addListener(_onAppBarHeightChanged);
|
widget.appBarHeightNotifier.addListener(_onAppBarHeightChanged);
|
||||||
}
|
}
|
||||||
|
@ -553,6 +572,8 @@ class _FilterSectionedContentState<T extends CollectionFilter> extends State<_Fi
|
||||||
final animate = context.read<Settings>().animate;
|
final animate = context.read<Settings>().animate;
|
||||||
highlightInfo.trackItem(item, animate: animate, highlightItem: filter);
|
highlightInfo.trackItem(item, animate: animate, highlightItem: filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _scrollToTop() => widget.scrollController.jumpTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FilterScaler<T extends CollectionFilter> extends StatelessWidget {
|
class _FilterScaler<T extends CollectionFilter> extends StatelessWidget {
|
||||||
|
|
Loading…
Reference in a new issue