collection: scroll to top on sort/group change
This commit is contained in:
parent
1b6febe034
commit
ff517925f6
7 changed files with 15 additions and 13 deletions
|
@ -16,8 +16,6 @@ import '../source/enums.dart';
|
|||
|
||||
final Settings settings = Settings._private();
|
||||
|
||||
typedef SettingsCallback = void Function(String key, dynamic oldValue, dynamic newValue);
|
||||
|
||||
class Settings extends ChangeNotifier {
|
||||
static SharedPreferences _prefs;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class CollectionLens with ChangeNotifier, CollectionActivityMixin, CollectionSel
|
|||
final Set<CollectionFilter> filters;
|
||||
EntryGroupFactor groupFactor;
|
||||
EntrySortFactor sortFactor;
|
||||
final AChangeNotifier filterChangeNotifier = AChangeNotifier();
|
||||
final AChangeNotifier filterChangeNotifier = AChangeNotifier(), sortGroupChangeNotifier = AChangeNotifier();
|
||||
int id;
|
||||
bool listenToSource;
|
||||
|
||||
|
@ -111,11 +111,13 @@ class CollectionLens with ChangeNotifier, CollectionActivityMixin, CollectionSel
|
|||
this.sortFactor = sortFactor;
|
||||
_applySort();
|
||||
_applyGroup();
|
||||
sortGroupChangeNotifier.notifyListeners();
|
||||
}
|
||||
|
||||
void group(EntryGroupFactor groupFactor) {
|
||||
this.groupFactor = groupFactor;
|
||||
_applyGroup();
|
||||
sortGroupChangeNotifier.notifyListeners();
|
||||
}
|
||||
|
||||
void _applyFilters() {
|
||||
|
|
|
@ -75,7 +75,7 @@ class ThumbnailSelectionOverlay extends StatelessWidget {
|
|||
const duration = Durations.thumbnailOverlayAnimation;
|
||||
final fontSize = min(14.0, (extent / 8)).roundToDouble();
|
||||
final iconSize = fontSize * 2;
|
||||
final collection = Provider.of<CollectionLens>(context);
|
||||
final collection = context.watch<CollectionLens>();
|
||||
return ValueListenableBuilder<Activity>(
|
||||
valueListenable: collection.activityNotifier,
|
||||
builder: (context, activity, child) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:aves/main.dart';
|
||||
import 'package:aves/model/entry.dart';
|
||||
import 'package:aves/model/filters/favourite.dart';
|
||||
import 'package:aves/model/filters/mime.dart';
|
||||
import 'package:aves/model/highlight.dart';
|
||||
import 'package:aves/model/entry.dart';
|
||||
import 'package:aves/model/source/collection_lens.dart';
|
||||
import 'package:aves/model/source/collection_source.dart';
|
||||
import 'package:aves/ref/mime_types.dart';
|
||||
|
@ -109,7 +109,7 @@ class ThumbnailCollection extends StatelessWidget {
|
|||
final sectionedListLayout = context.read<SectionedListLayout<AvesEntry>>();
|
||||
return sectionedListLayout.getTileRect(entry) ?? Rect.zero;
|
||||
},
|
||||
onScaled: (entry) => Provider.of<HighlightInfo>(context, listen: false).add(entry),
|
||||
onScaled: (entry) => context.read<HighlightInfo>().add(entry),
|
||||
child: scrollView,
|
||||
);
|
||||
|
||||
|
@ -195,12 +195,14 @@ class _CollectionScrollViewState extends State<CollectionScrollView> {
|
|||
}
|
||||
|
||||
void _registerWidget(CollectionScrollView widget) {
|
||||
widget.collection.filterChangeNotifier.addListener(_onFilterChange);
|
||||
widget.collection.filterChangeNotifier.addListener(_scrollToTop);
|
||||
widget.collection.sortGroupChangeNotifier.addListener(_scrollToTop);
|
||||
widget.scrollController.addListener(_onScrollChange);
|
||||
}
|
||||
|
||||
void _unregisterWidget(CollectionScrollView widget) {
|
||||
widget.collection.filterChangeNotifier.removeListener(_onFilterChange);
|
||||
widget.collection.filterChangeNotifier.removeListener(_scrollToTop);
|
||||
widget.collection.sortGroupChangeNotifier.removeListener(_scrollToTop);
|
||||
widget.scrollController.removeListener(_onScrollChange);
|
||||
}
|
||||
|
||||
|
@ -283,7 +285,7 @@ class _CollectionScrollViewState extends State<CollectionScrollView> {
|
|||
);
|
||||
}
|
||||
|
||||
void _onFilterChange() => widget.scrollController.jumpTo(0);
|
||||
void _scrollToTop() => widget.scrollController.jumpTo(0);
|
||||
|
||||
void _onScrollChange() {
|
||||
widget.isScrollingNotifier.value = true;
|
||||
|
|
|
@ -76,7 +76,7 @@ class SectionHeader extends StatelessWidget {
|
|||
}
|
||||
|
||||
void _toggleSectionSelection(BuildContext context) {
|
||||
final collection = Provider.of<CollectionLens>(context, listen: false);
|
||||
final collection = context.read<CollectionLens>();
|
||||
final sectionEntries = collection.sections[sectionKey];
|
||||
final selected = collection.isSelected(sectionEntries);
|
||||
if (selected) {
|
||||
|
@ -140,7 +140,7 @@ class _SectionSelectableLeading extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
if (!selectable) return _buildBrowsing(context);
|
||||
|
||||
final collection = Provider.of<CollectionLens>(context);
|
||||
final collection = context.watch<CollectionLens>();
|
||||
return ValueListenableBuilder<Activity>(
|
||||
valueListenable: collection.activityNotifier,
|
||||
builder: (context, activity, child) {
|
||||
|
|
|
@ -138,7 +138,7 @@ class FilterGridPage<T extends CollectionFilter> extends StatelessWidget {
|
|||
final sectionedListLayout = context.read<SectionedListLayout<FilterGridItem<T>>>();
|
||||
return sectionedListLayout.getTileRect(item) ?? Rect.zero;
|
||||
},
|
||||
onScaled: (item) => Provider.of<HighlightInfo>(context, listen: false).add(item.filter),
|
||||
onScaled: (item) => context.read<HighlightInfo>().add(item.filter),
|
||||
child: scrollView,
|
||||
);
|
||||
|
||||
|
|
|
@ -467,7 +467,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with SingleTickerPr
|
|||
_overlayAnimationController.value = _overlayAnimationController.upperBound;
|
||||
}
|
||||
} else {
|
||||
final mediaQuery = Provider.of<MediaQueryData>(context, listen: false);
|
||||
final mediaQuery = context.read<MediaQueryData>();
|
||||
setState(() {
|
||||
_frozenViewInsets = mediaQuery.viewInsets;
|
||||
_frozenViewPadding = mediaQuery.viewPadding;
|
||||
|
|
Loading…
Reference in a new issue