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