Commit 6a2edbbf authored by Adam Barth's avatar Adam Barth

[rename fixit] ItemsSnapAlignment -> PageableListFlingBehavior

Fixes #2448
parent 9b9ad3db
...@@ -12,10 +12,10 @@ import 'scroll_behavior.dart'; ...@@ -12,10 +12,10 @@ import 'scroll_behavior.dart';
import 'scrollable.dart'; import 'scrollable.dart';
import 'virtual_viewport.dart'; import 'virtual_viewport.dart';
/// Controls what alignment items use when settling. /// Controls how a pageable list should behave during a fling.
enum ItemsSnapAlignment { enum PageableListFlingBehavior {
item, canFlingAcrossMultiplePages,
adjacentItem stopAtNextPage
} }
/// Scrollable widget that scrolls one "page" at a time. /// Scrollable widget that scrolls one "page" at a time.
...@@ -33,7 +33,7 @@ class PageableList extends Scrollable { ...@@ -33,7 +33,7 @@ class PageableList extends Scrollable {
ScrollListener onScrollEnd, ScrollListener onScrollEnd,
SnapOffsetCallback snapOffsetCallback, SnapOffsetCallback snapOffsetCallback,
this.itemsWrap: false, this.itemsWrap: false,
this.itemsSnapAlignment: ItemsSnapAlignment.adjacentItem, this.itemsSnapAlignment: PageableListFlingBehavior.stopAtNextPage,
this.onPageChanged, this.onPageChanged,
this.scrollableListPainter, this.scrollableListPainter,
this.duration: const Duration(milliseconds: 200), this.duration: const Duration(milliseconds: 200),
...@@ -48,13 +48,15 @@ class PageableList extends Scrollable { ...@@ -48,13 +48,15 @@ class PageableList extends Scrollable {
onScroll: onScroll, onScroll: onScroll,
onScrollEnd: onScrollEnd, onScrollEnd: onScrollEnd,
snapOffsetCallback: snapOffsetCallback snapOffsetCallback: snapOffsetCallback
); ) {
assert(itemsSnapAlignment != null);
}
/// Whether the first item should be revealed after scrolling past the last item. /// Whether the first item should be revealed after scrolling past the last item.
final bool itemsWrap; final bool itemsWrap;
/// Controls whether a fling always reveals the adjacent item or whether flings can traverse many items. /// Controls whether a fling always reveals the adjacent item or whether flings can traverse many items.
final ItemsSnapAlignment itemsSnapAlignment; final PageableListFlingBehavior itemsSnapAlignment;
/// Called when the currently visible page changes. /// Called when the currently visible page changes.
final ValueChanged<int> onPageChanged; final ValueChanged<int> onPageChanged;
...@@ -187,7 +189,7 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> { ...@@ -187,7 +189,7 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
ScrollBehavior<double, double> createScrollBehavior() => scrollBehavior; ScrollBehavior<double, double> createScrollBehavior() => scrollBehavior;
bool get shouldSnapScrollOffset => config.itemsSnapAlignment == ItemsSnapAlignment.item; bool get shouldSnapScrollOffset => config.itemsSnapAlignment == PageableListFlingBehavior.canFlingAcrossMultiplePages;
double snapScrollOffset(double newScrollOffset) { double snapScrollOffset(double newScrollOffset) {
final double previousItemOffset = newScrollOffset.floorToDouble(); final double previousItemOffset = newScrollOffset.floorToDouble();
...@@ -205,10 +207,10 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> { ...@@ -205,10 +207,10 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
Future<Null> fling(double scrollVelocity) { Future<Null> fling(double scrollVelocity) {
switch(config.itemsSnapAlignment) { switch(config.itemsSnapAlignment) {
case ItemsSnapAlignment.adjacentItem: case PageableListFlingBehavior.canFlingAcrossMultiplePages:
return _flingToAdjacentItem(scrollVelocity);
default:
return super.fling(scrollVelocity).then(_notifyPageChanged); return super.fling(scrollVelocity).then(_notifyPageChanged);
case PageableListFlingBehavior.stopAtNextPage:
return _flingToAdjacentItem(scrollVelocity);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment