kg
6 年前
当前提交
6995fceb
共有 31 个文件被更改,包括 2133 次插入 和 189 次删除
-
4Assets/UIWidgets/Tests/RenderEditable.cs
-
2Assets/UIWidgets/foundation/change_notifier.cs
-
10Assets/UIWidgets/foundation/debug.cs
-
2Assets/UIWidgets/gestures/constants.cs
-
9Assets/UIWidgets/gestures/converter.cs
-
6Assets/UIWidgets/gestures/monodrag.cs
-
2Assets/UIWidgets/gestures/tap.cs
-
8Assets/UIWidgets/physics/utils.cs
-
10Assets/UIWidgets/rendering/object.cs
-
34Assets/UIWidgets/rendering/proxy_box.cs
-
6Assets/UIWidgets/rendering/viewport_offset.cs
-
1Assets/UIWidgets/scheduler/ticker.cs
-
107Assets/UIWidgets/widgets/basic.cs
-
14Assets/UIWidgets/widgets/framework.cs
-
16Assets/UIWidgets/widgets/scroll_metrics.cs
-
494Assets/UIWidgets/widgets/scroll_position.cs
-
173Assets/UIWidgets/widgets/ticker_provider.cs
-
31Assets/UIWidgets/gestures/long_press.cs
-
3Assets/UIWidgets/gestures/long_press.cs.meta
-
380Assets/UIWidgets/widgets/gesture_detector.cs
-
3Assets/UIWidgets/widgets/gesture_detector.cs.meta
-
144Assets/UIWidgets/widgets/page_storage.cs
-
3Assets/UIWidgets/widgets/page_storage.cs.meta
-
58Assets/UIWidgets/widgets/scroll_configuration.cs
-
3Assets/UIWidgets/widgets/scroll_configuration.cs.meta
-
192Assets/UIWidgets/widgets/scroll_controller.cs
-
3Assets/UIWidgets/widgets/scroll_controller.cs.meta
-
205Assets/UIWidgets/widgets/scroll_position_with_single_context.cs
-
3Assets/UIWidgets/widgets/scroll_position_with_single_context.cs.meta
-
393Assets/UIWidgets/widgets/scrollable.cs
-
3Assets/UIWidgets/widgets/scrollable.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RSG; |
|||
using UIWidgets.animation; |
|||
using UIWidgets.gestures; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.physics; |
|||
// public abstract class ScrollPosition : ViewportOffset, ScrollMetrics {
|
|||
// ScrollPosition(
|
|||
// ScrollPhysics physics = null,
|
|||
// ScrollContext context = null,
|
|||
// bool keepScrollOffset = true,
|
|||
// ScrollPosition oldPosition = null,
|
|||
// string debugLabel = null
|
|||
// ) {
|
|||
// D.assert(physics != null);
|
|||
// D.assert(context != null);
|
|||
// D.assert(context.vsync != null);
|
|||
//
|
|||
// this.physics = physics;
|
|||
// this.context = context;
|
|||
// this.keepScrollOffset = keepScrollOffset;
|
|||
// this.debugLabel = debugLabel;
|
|||
//
|
|||
// if (oldPosition != null) {
|
|||
// this.absorb(oldPosition);
|
|||
// }
|
|||
//
|
|||
// if (keepScrollOffset) {
|
|||
// this.restoreScrollOffset();
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// public readonly ScrollPhysics physics;
|
|||
// public readonly ScrollContext context;
|
|||
// public readonly bool keepScrollOffset;
|
|||
// public readonly string debugLabel;
|
|||
//
|
|||
// public double minScrollExtent {
|
|||
// get { return this._minScrollExtent; }
|
|||
// }
|
|||
//
|
|||
// double _minScrollExtent;
|
|||
//
|
|||
// public double maxScrollExtent {
|
|||
// get { return this._maxScrollExtent; }
|
|||
// }
|
|||
//
|
|||
// double _maxScrollExtent;
|
|||
//
|
|||
// public override double? pixels {
|
|||
// get { return this._pixels; }
|
|||
// }
|
|||
//
|
|||
// double? _pixels;
|
|||
//
|
|||
// public double viewportDimension {
|
|||
// get { return this._viewportDimension; }
|
|||
// }
|
|||
//
|
|||
// double _viewportDimension;
|
|||
//
|
|||
// public bool haveDimensions {
|
|||
// get { return this._haveDimensions; }
|
|||
// }
|
|||
//
|
|||
// bool _haveDimensions = false;
|
|||
//
|
|||
// protected virtual void absorb(ScrollPosition other) {
|
|||
// D.assert(other != null);
|
|||
// D.assert(other.context == context);
|
|||
// D.assert(_pixels == null);
|
|||
// _minScrollExtent = other.minScrollExtent;
|
|||
// _maxScrollExtent = other.maxScrollExtent;
|
|||
// _pixels = other._pixels;
|
|||
// _viewportDimension = other.viewportDimension;
|
|||
//
|
|||
// D.assert(activity == null);
|
|||
// D.assert(other.activity != null);
|
|||
// _activity = other.activity;
|
|||
// other._activity = null;
|
|||
// if (other.runtimeType != runtimeType)
|
|||
// activity.resetActivity();
|
|||
// context.setIgnorePointer(activity.shouldIgnorePointer);
|
|||
// isScrollingNotifier.value = activity.isScrolling;
|
|||
// }
|
|||
//
|
|||
// public double setPixels(double newPixels) {
|
|||
// D.assert(this._pixels != null);
|
|||
// D.assert(this.context.vsync.schedulerBinding.schedulerPhase <= SchedulerPhase.transientCallbacks);
|
|||
// if (newPixels != this.pixels) {
|
|||
// double overscroll = this.applyBoundaryConditions(newPixels);
|
|||
// D.assert(() => {
|
|||
// double delta = newPixels - this.pixels;
|
|||
// if (overscroll.abs() > delta.abs()) {
|
|||
// throw new UIWidgetsError(
|
|||
// string.Format(
|
|||
// "{0}.applyBoundaryConditions returned invalid overscroll value.\n" +
|
|||
// "setPixels() was called to change the scroll offset from {1} to {2}.\n" +
|
|||
// "That is a delta of {3} units.\n" +
|
|||
// "{0}.applyBoundaryConditions reported an overscroll of {4} units."
|
|||
// , this.GetType(), this.pixels, newPixels, delta, overscroll));
|
|||
// }
|
|||
//
|
|||
// return true;
|
|||
// });
|
|||
//
|
|||
// double oldPixels = this.pixels;
|
|||
// this._pixels = newPixels - overscroll;
|
|||
// if (this._pixels != oldPixels) {
|
|||
// this.notifyListeners();
|
|||
// this.didUpdateScrollPositionBy(this._pixels - oldPixels);
|
|||
// }
|
|||
//
|
|||
// if (overscroll != 0.0) {
|
|||
// this.didOverscrollBy(overscroll);
|
|||
// return overscroll;
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// return 0.0;
|
|||
// }
|
|||
//
|
|||
// public void correctPixels(double value) {
|
|||
// this._pixels = value;
|
|||
// }
|
|||
//
|
|||
// public override void correctBy(double correction) {
|
|||
// D.assert(
|
|||
// this._pixels != null,
|
|||
// "An initial pixels value must exist by caling correctPixels on the ScrollPosition"
|
|||
// );
|
|||
//
|
|||
// this._pixels += correction;
|
|||
// this._didChangeViewportDimensionOrReceiveCorrection = true;
|
|||
// }
|
|||
//
|
|||
// protected void forcePixels(double value) {
|
|||
// D.assert(this.pixels != null);
|
|||
// _pixels = value;
|
|||
// notifyListeners();
|
|||
// }
|
|||
//
|
|||
// protected void saveScrollOffset() {
|
|||
// PageStorage.of(context.storageContext)?.writeState(context.storageContext, pixels);
|
|||
// }
|
|||
//
|
|||
// protected void restoreScrollOffset() {
|
|||
// if (pixels == null) {
|
|||
// final double value = PageStorage.of(context.storageContext)?.readState(context.storageContext);
|
|||
// if (value != null)
|
|||
// correctPixels(value);
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
public abstract class ScrollPosition : ViewportOffset, ScrollMetrics { |
|||
protected ScrollPosition( |
|||
ScrollPhysics physics = null, |
|||
ScrollContext context = null, |
|||
bool keepScrollOffset = true, |
|||
ScrollPosition oldPosition = null, |
|||
string debugLabel = null |
|||
) { |
|||
D.assert(physics != null); |
|||
D.assert(context != null); |
|||
D.assert(context.vsync != null); |
|||
|
|||
this.physics = physics; |
|||
this.context = context; |
|||
this.keepScrollOffset = keepScrollOffset; |
|||
this.debugLabel = debugLabel; |
|||
|
|||
if (oldPosition != null) { |
|||
this.absorb(oldPosition); |
|||
} |
|||
|
|||
if (keepScrollOffset) { |
|||
this.restoreScrollOffset(); |
|||
} |
|||
} |
|||
|
|||
public readonly ScrollPhysics physics; |
|||
|
|||
public readonly ScrollContext context; |
|||
|
|||
public readonly bool keepScrollOffset; |
|||
|
|||
public readonly string debugLabel; |
|||
|
|||
public double minScrollExtent { |
|||
get { return this._minScrollExtent.Value; } |
|||
} |
|||
|
|||
double? _minScrollExtent; |
|||
|
|||
public double maxScrollExtent { |
|||
get { return this._maxScrollExtent.Value; } |
|||
} |
|||
|
|||
double? _maxScrollExtent; |
|||
|
|||
public override double pixels { |
|||
get { return this._pixels.Value; } |
|||
} |
|||
|
|||
internal double? _pixels; |
|||
|
|||
public double viewportDimension { |
|||
get { return this._viewportDimension.Value; } |
|||
} |
|||
|
|||
double? _viewportDimension; |
|||
|
|||
public bool haveDimensions { |
|||
get { return this._haveDimensions; } |
|||
} |
|||
|
|||
bool _haveDimensions = false; |
|||
|
|||
public abstract AxisDirection axisDirection { get; } |
|||
|
|||
protected virtual void absorb(ScrollPosition other) { |
|||
D.assert(other != null); |
|||
D.assert(other.context == this.context); |
|||
D.assert(this._pixels == null); |
|||
this._minScrollExtent = other.minScrollExtent; |
|||
this._maxScrollExtent = other.maxScrollExtent; |
|||
this._pixels = other._pixels; |
|||
this._viewportDimension = other.viewportDimension; |
|||
|
|||
D.assert(this.activity == null); |
|||
D.assert(other.activity != null); |
|||
this._activity = other.activity; |
|||
other._activity = null; |
|||
if (other.GetType() != this.GetType()) { |
|||
this.activity.resetActivity(); |
|||
} |
|||
|
|||
this.context.setIgnorePointer(this.activity.shouldIgnorePointer); |
|||
this.isScrollingNotifier.value = this.activity.isScrolling; |
|||
} |
|||
|
|||
public virtual double setPixels(double newPixels) { |
|||
D.assert(this._pixels != null); |
|||
D.assert(this.context.vsync.schedulerBinding.schedulerPhase <= SchedulerPhase.transientCallbacks); |
|||
if (newPixels != this.pixels) { |
|||
double overscroll = this.applyBoundaryConditions(newPixels); |
|||
D.assert(() => { |
|||
double delta = newPixels - this.pixels; |
|||
if (overscroll.abs() > delta.abs()) { |
|||
throw new UIWidgetsError( |
|||
string.Format( |
|||
"{0}.applyBoundaryConditions returned invalid overscroll value.\n" + |
|||
"setPixels() was called to change the scroll offset from {1} to {2}.\n" + |
|||
"That is a delta of {3} units.\n" + |
|||
"{0}.applyBoundaryConditions reported an overscroll of {4} units." |
|||
, this.GetType(), this.pixels, newPixels, delta, overscroll)); |
|||
} |
|||
|
|||
return true; |
|||
}); |
|||
|
|||
double oldPixels = this.pixels; |
|||
this._pixels = newPixels - overscroll; |
|||
if (this._pixels != oldPixels) { |
|||
this.notifyListeners(); |
|||
this.didUpdateScrollPositionBy(this.pixels - oldPixels); |
|||
} |
|||
|
|||
if (overscroll != 0.0) { |
|||
this.didOverscrollBy(overscroll); |
|||
return overscroll; |
|||
} |
|||
} |
|||
|
|||
return 0.0; |
|||
} |
|||
|
|||
public void correctPixels(double value) { |
|||
this._pixels = value; |
|||
} |
|||
|
|||
public override void correctBy(double correction) { |
|||
D.assert( |
|||
this._pixels != null, |
|||
"An initial pixels value must exist by caling correctPixels on the ScrollPosition" |
|||
); |
|||
|
|||
this._pixels += correction; |
|||
this._didChangeViewportDimensionOrReceiveCorrection = true; |
|||
} |
|||
|
|||
protected void forcePixels(double value) { |
|||
D.assert(this._pixels != null); |
|||
this._pixels = value; |
|||
this.notifyListeners(); |
|||
} |
|||
|
|||
protected void saveScrollOffset() { |
|||
var pageStorage = PageStorage.of(this.context.storageContext); |
|||
if (pageStorage != null) { |
|||
pageStorage.writeState(this.context.storageContext, this.pixels); |
|||
} |
|||
} |
|||
|
|||
protected void restoreScrollOffset() { |
|||
if (this._pixels == null) { |
|||
var pageStorage = PageStorage.of(this.context.storageContext); |
|||
if (pageStorage != null) { |
|||
object valueRaw = pageStorage.readState(this.context.storageContext); |
|||
if (valueRaw != null) { |
|||
this.correctPixels((double) valueRaw); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected double applyBoundaryConditions(double value) { |
|||
double result = this.physics.applyBoundaryConditions(this, value); |
|||
D.assert(() => { |
|||
double delta = value - this.pixels; |
|||
if (result.abs() > delta.abs()) { |
|||
throw new UIWidgetsError( |
|||
string.Format( |
|||
"{0}.applyBoundaryConditions returned invalid overscroll value.\n" + |
|||
"The method was called to consider a change from {1} to {2}, which is a " + |
|||
"delta of {3:F1} units. However, it returned an overscroll of " + |
|||
"${4:F1} units, which has a greater magnitude than the delta. " + |
|||
"The applyBoundaryConditions method is only supposed to reduce the possible range " + |
|||
"of movement, not increase it.\n" + |
|||
"The scroll extents are {5} .. {6}, and the " + |
|||
"viewport dimension is {7}.", |
|||
this.physics.GetType(), this.pixels, value, delta, result, |
|||
this.minScrollExtent, this.maxScrollExtent, this.viewportDimension)); |
|||
} |
|||
|
|||
return true; |
|||
}); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
bool _didChangeViewportDimensionOrReceiveCorrection = true; |
|||
|
|||
public override bool applyViewportDimension(double viewportDimension) { |
|||
if (this._viewportDimension != viewportDimension) { |
|||
this._viewportDimension = viewportDimension; |
|||
this._didChangeViewportDimensionOrReceiveCorrection = true; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
public override bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) { |
|||
if (!PhysicsUtils.nearEqual(this._minScrollExtent, minScrollExtent, Tolerance.defaultTolerance.distance) || |
|||
!PhysicsUtils.nearEqual(this._maxScrollExtent, maxScrollExtent, Tolerance.defaultTolerance.distance) || |
|||
this._didChangeViewportDimensionOrReceiveCorrection) { |
|||
this._minScrollExtent = minScrollExtent; |
|||
this._maxScrollExtent = maxScrollExtent; |
|||
this._haveDimensions = true; |
|||
this.applyNewDimensions(); |
|||
this._didChangeViewportDimensionOrReceiveCorrection = false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
protected virtual void applyNewDimensions() { |
|||
D.assert(this._pixels != null); |
|||
this.activity.applyNewDimensions(); |
|||
} |
|||
|
|||
public IPromise ensureVisible(RenderObject renderObject, |
|||
double alignment = 0.0, |
|||
TimeSpan? duration = null, |
|||
Curve curve = null |
|||
) { |
|||
D.assert(renderObject.attached); |
|||
RenderAbstractViewport viewport = RenderAbstractViewportUtils.of(renderObject); |
|||
D.assert(viewport != null); |
|||
|
|||
double target = viewport.getOffsetToReveal(renderObject, alignment).offset.clamp( |
|||
this.minScrollExtent, this.maxScrollExtent); |
|||
|
|||
if (target == this.pixels) { |
|||
return Promise.Resolved(); |
|||
} |
|||
|
|||
duration = duration ?? TimeSpan.Zero; |
|||
if (duration == TimeSpan.Zero) { |
|||
this.jumpTo(target); |
|||
return Promise.Resolved(); |
|||
} |
|||
|
|||
curve = curve ?? Curves.ease; |
|||
return this.animateTo(target, duration: duration.Value, curve: curve); |
|||
} |
|||
|
|||
public readonly ValueNotifier<bool> isScrollingNotifier = new ValueNotifier<bool>(false); |
|||
|
|||
public override bool allowImplicitScrolling { |
|||
get { return this.physics.allowImplicitScrolling; } |
|||
} |
|||
|
|||
public abstract ScrollHoldController hold(VoidCallback holdCancelCallback); |
|||
|
|||
public abstract Drag drag(DragStartDetails details, VoidCallback dragCancelCallback); |
|||
|
|||
protected ScrollActivity activity { |
|||
get { return this._activity; } |
|||
} |
|||
|
|||
ScrollActivity _activity; |
|||
|
|||
public virtual void beginActivity(ScrollActivity newActivity) { |
|||
if (newActivity == null) { |
|||
return; |
|||
} |
|||
|
|||
bool wasScrolling, oldIgnorePointer; |
|||
if (this._activity != null) { |
|||
oldIgnorePointer = this._activity.shouldIgnorePointer; |
|||
wasScrolling = this._activity.isScrolling; |
|||
if (wasScrolling && !newActivity.isScrolling) { |
|||
this.didEndScroll(); |
|||
} |
|||
|
|||
this._activity.dispose(); |
|||
} else { |
|||
oldIgnorePointer = false; |
|||
wasScrolling = false; |
|||
} |
|||
|
|||
this._activity = newActivity; |
|||
if (oldIgnorePointer != this.activity.shouldIgnorePointer) { |
|||
this.context.setIgnorePointer(this.activity.shouldIgnorePointer); |
|||
} |
|||
|
|||
this.isScrollingNotifier.value = this.activity.isScrolling; |
|||
if (!wasScrolling && this._activity.isScrolling) { |
|||
this.didStartScroll(); |
|||
} |
|||
} |
|||
|
|||
public void didStartScroll() { |
|||
this.activity.dispatchScrollStartNotification( |
|||
ScrollMetricsUtils.copyWith(this), this.context.notificationContext); |
|||
} |
|||
|
|||
public void didUpdateScrollPositionBy(double delta) { |
|||
this.activity.dispatchScrollUpdateNotification( |
|||
ScrollMetricsUtils.copyWith(this), this.context.notificationContext, delta); |
|||
} |
|||
|
|||
public void didEndScroll() { |
|||
this.activity.dispatchScrollEndNotification( |
|||
ScrollMetricsUtils.copyWith(this), this.context.notificationContext); |
|||
if (this.keepScrollOffset) { |
|||
this.saveScrollOffset(); |
|||
} |
|||
} |
|||
|
|||
public void didOverscrollBy(double value) { |
|||
D.assert(this.activity.isScrolling); |
|||
this.activity.dispatchOverscrollNotification( |
|||
ScrollMetricsUtils.copyWith(this), this.context.notificationContext, value); |
|||
} |
|||
|
|||
public void didUpdateScrollDirection(ScrollDirection direction) { |
|||
new UserScrollNotification(metrics: |
|||
ScrollMetricsUtils.copyWith(this), context: this.context.notificationContext, direction: direction |
|||
).dispatch(this.context.notificationContext); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
D.assert(this._pixels != null); |
|||
if (this.activity != null) { |
|||
this.activity.dispose(); |
|||
this._activity = null; |
|||
} |
|||
|
|||
base.dispose(); |
|||
} |
|||
|
|||
protected override void debugFillDescription(List<String> description) { |
|||
if (this.debugLabel != null) { |
|||
description.Add(this.debugLabel); |
|||
} |
|||
|
|||
base.debugFillDescription(description); |
|||
description.Add(string.Format("range: {0:F1}..{1:F1}", this.minScrollExtent, this.maxScrollExtent)); |
|||
description.Add(string.Format("viewport: {0:F1}", this.viewportDimension)); |
|||
} |
|||
} |
|||
} |
|
|||
namespace UIWidgets.gestures { |
|||
public delegate void GestureLongPressCallback(); |
|||
|
|||
public class LongPressGestureRecognizer : PrimaryPointerGestureRecognizer { |
|||
public LongPressGestureRecognizer(GestureBinding binding = null, object debugOwner = null) : |
|||
base(binding: binding, deadline: Constants.kLongPressTimeout, debugOwner: debugOwner) { |
|||
} |
|||
|
|||
public GestureLongPressCallback onLongPress; |
|||
|
|||
protected override void didExceedDeadline() { |
|||
this.resolve(GestureDisposition.accepted); |
|||
if (this.onLongPress != null) { |
|||
this.invokeCallback<object>("onLongPress", () => { |
|||
this.onLongPress(); |
|||
return null; |
|||
}); |
|||
} |
|||
} |
|||
|
|||
protected override void handlePrimaryPointer(PointerEvent evt) { |
|||
if (evt is PointerUpEvent) { |
|||
this.resolve(GestureDisposition.rejected); |
|||
} |
|||
} |
|||
|
|||
public override string debugDescription { |
|||
get { return "long press"; } |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3315b2f4cd844e3c81aa0f074b4914a3 |
|||
timeCreated: 1537166837 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.gestures; |
|||
using UIWidgets.rendering; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public abstract class GestureRecognizerFactory { |
|||
public abstract GestureRecognizer constructorRaw(); |
|||
|
|||
public abstract void initializerRaw(GestureRecognizer instance); |
|||
|
|||
internal abstract bool _debugAssertTypeMatches(Type type); |
|||
} |
|||
|
|||
public abstract class GestureRecognizerFactory<T> : GestureRecognizerFactory where T : GestureRecognizer { |
|||
public override GestureRecognizer constructorRaw() { |
|||
return this.constructor(); |
|||
} |
|||
|
|||
public override void initializerRaw(GestureRecognizer instance) { |
|||
this.initializer((T) instance); |
|||
} |
|||
|
|||
public abstract T constructor(); |
|||
|
|||
public abstract void initializer(T instance); |
|||
|
|||
internal override bool _debugAssertTypeMatches(Type type) { |
|||
D.assert(type == typeof(T), |
|||
"GestureRecognizerFactory of type " + typeof(T) + " was used where type $type was specified."); |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
public delegate T GestureRecognizerFactoryConstructor<T>() where T : GestureRecognizer; |
|||
|
|||
public delegate void GestureRecognizerFactoryInitializer<T>(T instance) where T : GestureRecognizer; |
|||
|
|||
public class GestureRecognizerFactoryWithHandlers<T> : GestureRecognizerFactory<T> where T : GestureRecognizer { |
|||
public GestureRecognizerFactoryWithHandlers(GestureRecognizerFactoryConstructor<T> constructor, |
|||
GestureRecognizerFactoryInitializer<T> initializer) { |
|||
D.assert(constructor != null); |
|||
D.assert(initializer != null); |
|||
|
|||
this._constructor = constructor; |
|||
this._initializer = initializer; |
|||
} |
|||
|
|||
readonly GestureRecognizerFactoryConstructor<T> _constructor; |
|||
|
|||
readonly GestureRecognizerFactoryInitializer<T> _initializer; |
|||
|
|||
public override T constructor() { |
|||
return this._constructor(); |
|||
} |
|||
|
|||
public override void initializer(T instance) { |
|||
this._initializer(instance); |
|||
} |
|||
} |
|||
|
|||
public class GestureDetector : StatelessWidget { |
|||
public GestureDetector( |
|||
Key key = null, |
|||
Widget child = null, |
|||
GestureTapDownCallback onTapDown = null, |
|||
GestureTapUpCallback onTapUp = null, |
|||
GestureTapCallback onTap = null, |
|||
GestureTapCancelCallback onTapCancel = null, |
|||
GestureDoubleTapCallback onDoubleTap = null, |
|||
GestureLongPressCallback onLongPress = null, |
|||
GestureDragDownCallback onVerticalDragDown = null, |
|||
GestureDragStartCallback onVerticalDragStart = null, |
|||
GestureDragUpdateCallback onVerticalDragUpdate = null, |
|||
GestureDragEndCallback onVerticalDragEnd = null, |
|||
GestureDragCancelCallback onVerticalDragCancel = null, |
|||
GestureDragDownCallback onHorizontalDragDown = null, |
|||
GestureDragStartCallback onHorizontalDragStart = null, |
|||
GestureDragUpdateCallback onHorizontalDragUpdate = null, |
|||
GestureDragEndCallback onHorizontalDragEnd = null, |
|||
GestureDragCancelCallback onHorizontalDragCancel = null, |
|||
GestureDragDownCallback onPanDown = null, |
|||
GestureDragStartCallback onPanStart = null, |
|||
GestureDragUpdateCallback onPanUpdate = null, |
|||
GestureDragEndCallback onPanEnd = null, |
|||
GestureDragCancelCallback onPanCancel = null, |
|||
HitTestBehavior behavior = HitTestBehavior.deferToChild) : base(key) { |
|||
D.assert(() => { |
|||
bool haveVerticalDrag = |
|||
onVerticalDragStart != null || onVerticalDragUpdate != null || |
|||
onVerticalDragEnd != null; |
|||
bool haveHorizontalDrag = |
|||
onHorizontalDragStart != null || onHorizontalDragUpdate != null || |
|||
onHorizontalDragEnd != null; |
|||
bool havePan = onPanStart != null || onPanUpdate != null || onPanEnd != null; |
|||
if (havePan) { |
|||
if (haveVerticalDrag && haveHorizontalDrag) { |
|||
throw new UIWidgetsError( |
|||
"Incorrect GestureDetector arguments.\n" + |
|||
"Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a pan gesture recognizer " + |
|||
"will result in the pan gesture recognizer being ignored, since the other two will catch all drags." |
|||
); |
|||
} |
|||
} |
|||
|
|||
return true; |
|||
}); |
|||
|
|||
this.child = child; |
|||
this.onTapDown = onTapDown; |
|||
this.onTapUp = onTapUp; |
|||
this.onTap = onTap; |
|||
this.onTapCancel = onTapCancel; |
|||
this.onDoubleTap = onDoubleTap; |
|||
this.onLongPress = onLongPress; |
|||
this.onVerticalDragDown = onVerticalDragDown; |
|||
this.onVerticalDragStart = onVerticalDragStart; |
|||
this.onVerticalDragUpdate = onVerticalDragUpdate; |
|||
this.onVerticalDragEnd = onVerticalDragEnd; |
|||
this.onVerticalDragCancel = onVerticalDragCancel; |
|||
this.onHorizontalDragDown = onHorizontalDragDown; |
|||
this.onHorizontalDragStart = onHorizontalDragStart; |
|||
this.onHorizontalDragUpdate = onHorizontalDragUpdate; |
|||
this.onHorizontalDragEnd = onHorizontalDragEnd; |
|||
this.onHorizontalDragCancel = onHorizontalDragCancel; |
|||
this.onPanDown = onPanDown; |
|||
this.onPanStart = onPanStart; |
|||
this.onPanUpdate = onPanUpdate; |
|||
this.onPanEnd = onPanEnd; |
|||
this.onPanCancel = onPanCancel; |
|||
this.behavior = behavior; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
public readonly GestureTapDownCallback onTapDown; |
|||
public readonly GestureTapUpCallback onTapUp; |
|||
public readonly GestureTapCallback onTap; |
|||
public readonly GestureTapCancelCallback onTapCancel; |
|||
public readonly GestureDoubleTapCallback onDoubleTap; |
|||
public readonly GestureLongPressCallback onLongPress; |
|||
public readonly GestureDragDownCallback onVerticalDragDown; |
|||
public readonly GestureDragStartCallback onVerticalDragStart; |
|||
public readonly GestureDragUpdateCallback onVerticalDragUpdate; |
|||
public readonly GestureDragEndCallback onVerticalDragEnd; |
|||
public readonly GestureDragCancelCallback onVerticalDragCancel; |
|||
public readonly GestureDragDownCallback onHorizontalDragDown; |
|||
public readonly GestureDragStartCallback onHorizontalDragStart; |
|||
public readonly GestureDragUpdateCallback onHorizontalDragUpdate; |
|||
public readonly GestureDragEndCallback onHorizontalDragEnd; |
|||
public readonly GestureDragCancelCallback onHorizontalDragCancel; |
|||
public readonly GestureDragDownCallback onPanDown; |
|||
public readonly GestureDragStartCallback onPanStart; |
|||
public readonly GestureDragUpdateCallback onPanUpdate; |
|||
public readonly GestureDragEndCallback onPanEnd; |
|||
public readonly GestureDragCancelCallback onPanCancel; |
|||
public readonly HitTestBehavior behavior; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
var gestures = new Dictionary<Type, GestureRecognizerFactory>(); |
|||
|
|||
if (this.onTapDown != null || |
|||
this.onTapUp != null || |
|||
this.onTap != null || |
|||
this.onTapCancel != null) { |
|||
gestures[typeof(TapGestureRecognizer)] = |
|||
new GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>( |
|||
() => new TapGestureRecognizer(debugOwner: this), |
|||
instance => { |
|||
instance.onTapDown = this.onTapDown; |
|||
instance.onTapUp = this.onTapUp; |
|||
instance.onTap = this.onTap; |
|||
instance.onTapCancel = this.onTapCancel; |
|||
} |
|||
); |
|||
} |
|||
|
|||
if (this.onDoubleTap != null) { |
|||
gestures[typeof(DoubleTapGestureRecognizer)] = |
|||
new GestureRecognizerFactoryWithHandlers<DoubleTapGestureRecognizer>( |
|||
() => new DoubleTapGestureRecognizer(debugOwner: this), |
|||
instance => { instance.onDoubleTap = this.onDoubleTap; } |
|||
); |
|||
} |
|||
|
|||
if (this.onLongPress != null) { |
|||
gestures[typeof(LongPressGestureRecognizer)] = |
|||
new GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>( |
|||
() => new LongPressGestureRecognizer(debugOwner: this), |
|||
instance => { instance.onLongPress = this.onLongPress; } |
|||
); |
|||
} |
|||
|
|||
if (this.onVerticalDragDown != null || |
|||
this.onVerticalDragStart != null || |
|||
this.onVerticalDragUpdate != null || |
|||
this.onVerticalDragEnd != null || |
|||
this.onVerticalDragCancel != null) { |
|||
gestures[typeof(VerticalDragGestureRecognizer)] = |
|||
new GestureRecognizerFactoryWithHandlers<VerticalDragGestureRecognizer>( |
|||
() => new VerticalDragGestureRecognizer(debugOwner: this), |
|||
instance => { |
|||
instance.onDown = this.onVerticalDragDown; |
|||
instance.onStart = this.onVerticalDragStart; |
|||
instance.onUpdate = this.onVerticalDragUpdate; |
|||
instance.onEnd = this.onVerticalDragEnd; |
|||
instance.onCancel = this.onVerticalDragCancel; |
|||
} |
|||
); |
|||
} |
|||
|
|||
if (this.onHorizontalDragDown != null || |
|||
this.onHorizontalDragStart != null || |
|||
this.onHorizontalDragUpdate != null || |
|||
this.onHorizontalDragEnd != null || |
|||
this.onHorizontalDragCancel != null) { |
|||
gestures[typeof(HorizontalDragGestureRecognizer)] = |
|||
new GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>( |
|||
() => new HorizontalDragGestureRecognizer(debugOwner: this), |
|||
instance => { |
|||
instance.onDown = this.onHorizontalDragDown; |
|||
instance.onStart = this.onHorizontalDragStart; |
|||
instance.onUpdate = this.onHorizontalDragUpdate; |
|||
instance.onEnd = this.onHorizontalDragEnd; |
|||
instance.onCancel = this.onHorizontalDragCancel; |
|||
} |
|||
); |
|||
} |
|||
|
|||
if (this.onPanDown != null || |
|||
this.onPanStart != null || |
|||
this.onPanUpdate != null || |
|||
this.onPanEnd != null || |
|||
this.onPanCancel != null) { |
|||
gestures[typeof(PanGestureRecognizer)] = |
|||
new GestureRecognizerFactoryWithHandlers<PanGestureRecognizer>( |
|||
() => new PanGestureRecognizer(debugOwner: this), |
|||
instance => { |
|||
instance.onDown = this.onPanDown; |
|||
instance.onStart = this.onPanStart; |
|||
instance.onUpdate = this.onPanUpdate; |
|||
instance.onEnd = this.onPanEnd; |
|||
instance.onCancel = this.onPanCancel; |
|||
} |
|||
); |
|||
} |
|||
|
|||
return new RawGestureDetector( |
|||
gestures: gestures, |
|||
behavior: this.behavior, |
|||
child: this.child |
|||
); |
|||
} |
|||
} |
|||
|
|||
public class RawGestureDetector : StatefulWidget { |
|||
public RawGestureDetector( |
|||
Key key = null, |
|||
Widget child = null, |
|||
Dictionary<Type, GestureRecognizerFactory> gestures = null, |
|||
HitTestBehavior? behavior = null |
|||
) : base(key: key) { |
|||
D.assert(gestures != null); |
|||
this.child = child; |
|||
this.gestures = gestures ?? new Dictionary<Type, GestureRecognizerFactory>(); |
|||
this.behavior = behavior; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly Dictionary<Type, GestureRecognizerFactory> gestures; |
|||
|
|||
public readonly HitTestBehavior? behavior; |
|||
|
|||
public override State createState() { |
|||
return new RawGestureDetectorState(); |
|||
} |
|||
} |
|||
|
|||
public class RawGestureDetectorState : State<RawGestureDetector> { |
|||
Dictionary<Type, GestureRecognizer> _recognizers = new Dictionary<Type, GestureRecognizer>(); |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
this._syncAll(this.widget.gestures); |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
base.didUpdateWidget(oldWidget); |
|||
this._syncAll(this.widget.gestures); |
|||
} |
|||
|
|||
public void replaceGestureRecognizers(Dictionary<Type, GestureRecognizerFactory> gestures) { |
|||
D.assert(() => { |
|||
if (!this.context.findRenderObject().owner.debugDoingLayout) { |
|||
throw new UIWidgetsError( |
|||
"Unexpected call to replaceGestureRecognizers() method of RawGestureDetectorState.\n" + |
|||
"The replaceGestureRecognizers() method can only be called during the layout phase. " + |
|||
"To set the gesture recognizers at other times, trigger a new build using setState() " + |
|||
"and provide the new gesture recognizers as constructor arguments to the corresponding " + |
|||
"RawGestureDetector or GestureDetector object."); |
|||
} |
|||
|
|||
return true; |
|||
}); |
|||
this._syncAll(gestures); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
foreach (GestureRecognizer recognizer in this._recognizers.Values) { |
|||
recognizer.dispose(); |
|||
} |
|||
|
|||
this._recognizers = null; |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _syncAll(Dictionary<Type, GestureRecognizerFactory> gestures) { |
|||
D.assert(this._recognizers != null); |
|||
var oldRecognizers = this._recognizers; |
|||
this._recognizers = new Dictionary<Type, GestureRecognizer>(); |
|||
|
|||
foreach (Type type in gestures.Keys) { |
|||
D.assert(gestures[type] != null); |
|||
D.assert(gestures[type]._debugAssertTypeMatches(type)); |
|||
D.assert(!this._recognizers.ContainsKey(type)); |
|||
this._recognizers[type] = oldRecognizers[type] ?? gestures[type].constructorRaw(); |
|||
D.assert(this._recognizers[type].GetType() == type, |
|||
"GestureRecognizerFactory of type " + type + " created a GestureRecognizer of type " + |
|||
this._recognizers[type].GetType() + |
|||
". The GestureRecognizerFactory must be specialized with the type of the class that it returns from its constructor method."); |
|||
gestures[type].initializerRaw(this._recognizers[type]); |
|||
} |
|||
|
|||
foreach (Type type in oldRecognizers.Keys) { |
|||
if (!this._recognizers.ContainsKey(type)) { |
|||
oldRecognizers[type].dispose(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void _handlePointerDown(PointerDownEvent evt) { |
|||
D.assert(this._recognizers != null); |
|||
foreach (GestureRecognizer recognizer in this._recognizers.Values) { |
|||
recognizer.addPointer(evt); |
|||
} |
|||
} |
|||
|
|||
HitTestBehavior _defaultBehavior { |
|||
get { return this.widget.child == null ? HitTestBehavior.translucent : HitTestBehavior.deferToChild; } |
|||
} |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
Widget result = new Listener( |
|||
onPointerDown: this._handlePointerDown, |
|||
behavior: this.widget.behavior ?? this._defaultBehavior, |
|||
child: this.widget.child |
|||
); |
|||
return result; |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
if (this._recognizers == null) { |
|||
properties.add(DiagnosticsNode.message("DISPOSED")); |
|||
} else { |
|||
List<String> gestures = this._recognizers.Values.Select(recognizer => recognizer.debugDescription) |
|||
.ToList(); |
|||
properties.add(new EnumerableProperty<string>("gestures", gestures, ifEmpty: "<none>")); |
|||
properties.add(new EnumerableProperty<GestureRecognizer>("recognizers", this._recognizers.Values, |
|||
level: DiagnosticLevel.fine)); |
|||
} |
|||
|
|||
properties.add(new EnumProperty<HitTestBehavior?>("behavior", this.widget.behavior, |
|||
defaultValue: Diagnostics.kNullDefaultValue)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c9c16577359d413ab2306df2227987dd |
|||
timeCreated: 1537165902 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UIWidgets.foundation; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public interface PageStorageKey { |
|||
} |
|||
|
|||
public class PageStorageKey<T> : ValueKey<T>, PageStorageKey { |
|||
public PageStorageKey(T value) : base(value) { |
|||
} |
|||
} |
|||
|
|||
class _StorageEntryIdentifier : IEquatable<_StorageEntryIdentifier> { |
|||
internal _StorageEntryIdentifier(List<PageStorageKey> keys) { |
|||
D.assert(keys != null); |
|||
this.keys = keys; |
|||
} |
|||
|
|||
public readonly List<PageStorageKey> keys; |
|||
|
|||
public bool isNotEmpty { |
|||
get { return this.keys.isNotEmpty(); } |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return string.Format("StorageEntryIdentifier({0})", |
|||
string.Join(":", this.keys.Select(x => x.ToString()).ToArray())); |
|||
} |
|||
|
|||
public bool Equals(_StorageEntryIdentifier other) { |
|||
if (object.ReferenceEquals(null, other)) return false; |
|||
if (object.ReferenceEquals(this, other)) return true; |
|||
return this.keys.SequenceEqual(other.keys); |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (object.ReferenceEquals(null, obj)) return false; |
|||
if (object.ReferenceEquals(this, obj)) return true; |
|||
if (obj.GetType() != this.GetType()) return false; |
|||
return this.Equals((_StorageEntryIdentifier) obj); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
if (this.keys == null || this.keys.isEmpty()) { |
|||
return 0; |
|||
} |
|||
|
|||
var hashCode = this.keys[0].GetHashCode(); |
|||
for (var i = 1; i < this.keys.Count; i++) { |
|||
hashCode = (hashCode * 397) ^ this.keys[i].GetHashCode(); |
|||
} |
|||
|
|||
return hashCode; |
|||
} |
|||
|
|||
public static bool operator ==(_StorageEntryIdentifier left, _StorageEntryIdentifier right) { |
|||
return object.Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(_StorageEntryIdentifier left, _StorageEntryIdentifier right) { |
|||
return !object.Equals(left, right); |
|||
} |
|||
} |
|||
|
|||
public class PageStorageBucket { |
|||
static bool _maybeAddKey(BuildContext context, List<PageStorageKey> keys) { |
|||
Widget widget = context.widget; |
|||
Key key = widget.key; |
|||
if (key is PageStorageKey) { |
|||
keys.Add((PageStorageKey) key); |
|||
} |
|||
|
|||
return !(widget is PageStorage); |
|||
} |
|||
|
|||
List<PageStorageKey> _allKeys(BuildContext context) { |
|||
List<PageStorageKey> keys = new List<PageStorageKey>(); |
|||
if (_maybeAddKey(context, keys)) { |
|||
context.visitAncestorElements(element => _maybeAddKey(element, keys)); |
|||
} |
|||
|
|||
return keys; |
|||
} |
|||
|
|||
_StorageEntryIdentifier _computeIdentifier(BuildContext context) { |
|||
return new _StorageEntryIdentifier(this._allKeys(context)); |
|||
} |
|||
|
|||
Dictionary<object, object> _storage; |
|||
|
|||
public void writeState(BuildContext context, object data, object identifier = null) { |
|||
this._storage = this._storage ?? new Dictionary<object, object>(); |
|||
if (identifier != null) { |
|||
this._storage[identifier] = data; |
|||
} else { |
|||
_StorageEntryIdentifier contextIdentifier = this._computeIdentifier(context); |
|||
if (contextIdentifier.isNotEmpty) { |
|||
this._storage[contextIdentifier] = data; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public object readState(BuildContext context, object identifier = null) { |
|||
if (this._storage == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (identifier != null) { |
|||
return this._storage[identifier]; |
|||
} |
|||
|
|||
_StorageEntryIdentifier contextIdentifier = this._computeIdentifier(context); |
|||
return contextIdentifier.isNotEmpty ? this._storage[contextIdentifier] : null; |
|||
} |
|||
} |
|||
|
|||
|
|||
public class PageStorage : StatelessWidget { |
|||
public PageStorage( |
|||
Key key, |
|||
PageStorageBucket bucket, |
|||
Widget child |
|||
) : base(key: key) { |
|||
D.assert(bucket != null); |
|||
this.bucket = bucket; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly PageStorageBucket bucket; |
|||
|
|||
public static PageStorageBucket of(BuildContext context) { |
|||
PageStorage widget = (PageStorage) context.ancestorWidgetOfExactType(typeof(PageStorage)); |
|||
return widget == null ? null : widget.bucket; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return this.child; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 45b0579fc707492f9c779c21360b8881 |
|||
timeCreated: 1537153497 |
|
|||
using UIWidgets.foundation; |
|||
using UIWidgets.painting; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public class ScrollBehavior { |
|||
public Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) { |
|||
return child; |
|||
} |
|||
|
|||
public ScrollPhysics getScrollPhysics(BuildContext context) { |
|||
return new BouncingScrollPhysics(); |
|||
} |
|||
|
|||
public virtual bool shouldNotify(ScrollBehavior oldDelegate) { |
|||
return false; |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return this.GetType().ToString(); |
|||
} |
|||
} |
|||
|
|||
public class ScrollConfiguration : InheritedWidget { |
|||
public ScrollConfiguration( |
|||
Key key = null, |
|||
ScrollBehavior behavior = null, |
|||
Widget child = null |
|||
) : base(key: key, child: child) { |
|||
D.assert(behavior != null); |
|||
this.behavior = behavior; |
|||
} |
|||
|
|||
public readonly ScrollBehavior behavior; |
|||
|
|||
public static ScrollBehavior of(BuildContext context) { |
|||
ScrollConfiguration configuration = |
|||
(ScrollConfiguration) context.inheritFromWidgetOfExactType(typeof(ScrollConfiguration)); |
|||
if (configuration != null) { |
|||
return configuration.behavior; |
|||
} |
|||
|
|||
return new ScrollBehavior(); |
|||
} |
|||
|
|||
public override bool updateShouldNotify(InheritedWidget oldWidgetRaw) { |
|||
var oldWidget = (ScrollConfiguration) oldWidgetRaw; |
|||
|
|||
D.assert(this.behavior != null); |
|||
return this.behavior.GetType() != oldWidget.behavior.GetType() |
|||
|| (this.behavior != oldWidget.behavior && this.behavior.shouldNotify(oldWidget.behavior)); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<ScrollBehavior>("behavior", this.behavior)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 64f86fe6ce0a475fa47b21a73a250752 |
|||
timeCreated: 1537163722 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using RSG; |
|||
using UIWidgets.animation; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.ui; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public class ScrollController : ChangeNotifier { |
|||
public ScrollController( |
|||
double initialScrollOffset = 0.0, |
|||
bool keepScrollOffset = true, |
|||
string debugLabel = null |
|||
) { |
|||
this._initialScrollOffset = initialScrollOffset; |
|||
this.keepScrollOffset = keepScrollOffset; |
|||
this.debugLabel = debugLabel; |
|||
} |
|||
|
|||
public virtual double initialScrollOffset { |
|||
get { return this._initialScrollOffset; } |
|||
} |
|||
|
|||
readonly double _initialScrollOffset; |
|||
|
|||
public readonly bool keepScrollOffset; |
|||
|
|||
public readonly string debugLabel; |
|||
|
|||
public IEnumerable<ScrollPosition> positions { |
|||
get { return this._positions; } |
|||
} |
|||
|
|||
readonly List<ScrollPosition> _positions = new List<ScrollPosition>(); |
|||
|
|||
public bool hasClients { |
|||
get { return this._positions.isNotEmpty(); } |
|||
} |
|||
|
|||
public ScrollPosition position { |
|||
get { |
|||
D.assert(this._positions.isNotEmpty(), "ScrollController not attached to any scroll views."); |
|||
D.assert(this._positions.Count == 1, "ScrollController attached to multiple scroll views."); |
|||
return this._positions.Single(); |
|||
} |
|||
} |
|||
|
|||
public double offset { |
|||
get { return this.position.pixels; } |
|||
} |
|||
|
|||
|
|||
public IPromise animateTo(double to, |
|||
TimeSpan duration, |
|||
Curve curve |
|||
) { |
|||
D.assert(this._positions.isNotEmpty(), "ScrollController not attached to any scroll views."); |
|||
List<IPromise> animations = new List<IPromise>(this._positions.Count); |
|||
for (int i = 0; i < this._positions.Count; i += 1) { |
|||
animations[i] = this._positions[i].animateTo(to, duration: duration, curve: curve); |
|||
} |
|||
|
|||
return Promise.All(animations); |
|||
} |
|||
|
|||
public void jumpTo(double value) { |
|||
D.assert(this._positions.isNotEmpty(), "ScrollController not attached to any scroll views."); |
|||
foreach (ScrollPosition position in new List<ScrollPosition>(this._positions)) { |
|||
position.jumpTo(value); |
|||
} |
|||
} |
|||
|
|||
public virtual void attach(ScrollPosition position) { |
|||
D.assert(!this._positions.Contains(position)); |
|||
this._positions.Add(position); |
|||
position.addListener(this.notifyListeners); |
|||
} |
|||
|
|||
public virtual void detach(ScrollPosition position) { |
|||
D.assert(this._positions.Contains(position)); |
|||
position.removeListener(this.notifyListeners); |
|||
this._positions.Remove(position); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
foreach (ScrollPosition position in this._positions) { |
|||
position.removeListener(this.notifyListeners); |
|||
} |
|||
|
|||
base.dispose(); |
|||
} |
|||
|
|||
public ScrollPosition createScrollPosition( |
|||
ScrollPhysics physics, |
|||
ScrollContext context, |
|||
ScrollPosition oldPosition |
|||
) { |
|||
return new ScrollPositionWithSingleContext( |
|||
physics: physics, |
|||
context: context, |
|||
initialPixels: this.initialScrollOffset, |
|||
keepScrollOffset: this.keepScrollOffset, |
|||
oldPosition: oldPosition, |
|||
debugLabel: this.debugLabel |
|||
); |
|||
} |
|||
|
|||
public override string ToString() { |
|||
List<string> description = new List<string>(); |
|||
this.debugFillDescription(description); |
|||
return string.Format("{0}({1})", Diagnostics.describeIdentity(this), |
|||
string.Join(", ", description.ToArray())); |
|||
} |
|||
|
|||
protected virtual void debugFillDescription(List<string> description) { |
|||
if (this.debugLabel != null) { |
|||
description.Add(this.debugLabel); |
|||
} |
|||
|
|||
if (this.initialScrollOffset != 0.0) { |
|||
description.Add(string.Format("initialScrollOffset: {0:F1}, ", this.initialScrollOffset)); |
|||
} |
|||
|
|||
if (this._positions.isEmpty()) { |
|||
description.Add("no clients"); |
|||
} else if (this._positions.Count == 1) { |
|||
description.Add(string.Format("one client, offset {0:F1}", this.offset)); |
|||
} else { |
|||
description.Add(this._positions.Count + " clients"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class TrackingScrollController : ScrollController { |
|||
public TrackingScrollController( |
|||
double initialScrollOffset = 0.0, |
|||
bool keepScrollOffset = true, |
|||
String debugLabel = null |
|||
) : base(initialScrollOffset: initialScrollOffset, |
|||
keepScrollOffset: keepScrollOffset, |
|||
debugLabel: debugLabel) { |
|||
} |
|||
|
|||
readonly Dictionary<ScrollPosition, VoidCallback> _positionToListener = |
|||
new Dictionary<ScrollPosition, VoidCallback>(); |
|||
|
|||
ScrollPosition _lastUpdated; |
|||
double? _lastUpdatedOffset; |
|||
|
|||
public ScrollPosition mostRecentlyUpdatedPosition { |
|||
get { return this._lastUpdated; } |
|||
} |
|||
|
|||
public override double initialScrollOffset { |
|||
get { return this._lastUpdatedOffset ?? base.initialScrollOffset; } |
|||
} |
|||
|
|||
public override void attach(ScrollPosition position) { |
|||
base.attach(position); |
|||
D.assert(!this._positionToListener.ContainsKey(position)); |
|||
this._positionToListener[position] = () => { |
|||
this._lastUpdated = position; |
|||
this._lastUpdatedOffset = position.pixels; |
|||
}; |
|||
position.addListener(this._positionToListener[position]); |
|||
} |
|||
|
|||
public override void detach(ScrollPosition position) { |
|||
base.detach(position); |
|||
D.assert(this._positionToListener.ContainsKey(position)); |
|||
position.removeListener(this._positionToListener[position]); |
|||
this._positionToListener.Remove(position); |
|||
if (this._lastUpdated == position) { |
|||
this._lastUpdated = null; |
|||
} |
|||
|
|||
if (this._positionToListener.isEmpty()) { |
|||
this._lastUpdatedOffset = null; |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
foreach (ScrollPosition position in this.positions) { |
|||
D.assert(this._positionToListener.ContainsKey(position)); |
|||
position.removeListener(this._positionToListener[position]); |
|||
} |
|||
|
|||
base.dispose(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1ae725e691fc4453b2fe1a0e5d40c642 |
|||
timeCreated: 1537160307 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RSG; |
|||
using UIWidgets.animation; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.gestures; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.physics; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.ui; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public class ScrollPositionWithSingleContext : ScrollPosition, ScrollActivityDelegate { |
|||
public ScrollPositionWithSingleContext( |
|||
ScrollPhysics physics = null, |
|||
ScrollContext context = null, |
|||
double? initialPixels = 0.0, |
|||
bool keepScrollOffset = true, |
|||
ScrollPosition oldPosition = null, |
|||
string debugLabel = null |
|||
) : base( |
|||
physics: physics, |
|||
context: context, |
|||
keepScrollOffset: keepScrollOffset, |
|||
oldPosition: oldPosition, |
|||
debugLabel: debugLabel |
|||
) { |
|||
if (this._pixels == null && initialPixels != null) { |
|||
this.correctPixels(initialPixels.Value); |
|||
} |
|||
|
|||
if (this.activity == null) { |
|||
this.goIdle(); |
|||
} |
|||
|
|||
D.assert(this.activity != null); |
|||
} |
|||
|
|||
|
|||
double _heldPreviousVelocity = 0.0; |
|||
|
|||
public override AxisDirection axisDirection { |
|||
get { return this.context.axisDirection; } |
|||
} |
|||
|
|||
public override double setPixels(double newPixels) { |
|||
D.assert(this.activity.isScrolling); |
|||
return base.setPixels(newPixels); |
|||
} |
|||
|
|||
protected override void absorb(ScrollPosition other) { |
|||
base.absorb(other); |
|||
if (!(other is ScrollPositionWithSingleContext)) { |
|||
this.goIdle(); |
|||
return; |
|||
} |
|||
|
|||
this.activity.updateDelegate(this); |
|||
ScrollPositionWithSingleContext typedOther = (ScrollPositionWithSingleContext) other; |
|||
this._userScrollDirection = typedOther._userScrollDirection; |
|||
D.assert(this._currentDrag == null); |
|||
if (typedOther._currentDrag != null) { |
|||
this._currentDrag = typedOther._currentDrag; |
|||
this._currentDrag.updateDelegate(this); |
|||
typedOther._currentDrag = null; |
|||
} |
|||
} |
|||
|
|||
protected override void applyNewDimensions() { |
|||
base.applyNewDimensions(); |
|||
this.context.setCanDrag(this.physics.shouldAcceptUserOffset(this)); |
|||
} |
|||
|
|||
public override void beginActivity(ScrollActivity newActivity) { |
|||
this._heldPreviousVelocity = 0.0; |
|||
if (newActivity == null) { |
|||
return; |
|||
} |
|||
|
|||
D.assert(newActivity.del == this); |
|||
base.beginActivity(newActivity); |
|||
if (this._currentDrag != null) { |
|||
this._currentDrag.dispose(); |
|||
this._currentDrag = null; |
|||
} |
|||
|
|||
if (!this.activity.isScrolling) { |
|||
this.updateUserScrollDirection(ScrollDirection.idle); |
|||
} |
|||
} |
|||
|
|||
public virtual void applyUserOffset(double delta) { |
|||
this.updateUserScrollDirection(delta > 0.0 ? ScrollDirection.forward : ScrollDirection.reverse); |
|||
this.setPixels(this.pixels - this.physics.applyPhysicsToUserOffset(this, delta)); |
|||
} |
|||
|
|||
public void goIdle() { |
|||
this.beginActivity(new IdleScrollActivity(this)); |
|||
} |
|||
|
|||
public void goBallistic(double velocity) { |
|||
D.assert(this._pixels != null); |
|||
Simulation simulation = this.physics.createBallisticSimulation(this, velocity); |
|||
if (simulation != null) { |
|||
this.beginActivity(new BallisticScrollActivity(this, simulation, this.context.vsync)); |
|||
} else { |
|||
this.goIdle(); |
|||
} |
|||
} |
|||
|
|||
public override ScrollDirection userScrollDirection { |
|||
get { return this._userScrollDirection; } |
|||
} |
|||
|
|||
ScrollDirection _userScrollDirection = ScrollDirection.idle; |
|||
|
|||
protected void updateUserScrollDirection(ScrollDirection value) { |
|||
if (this.userScrollDirection == value) { |
|||
return; |
|||
} |
|||
|
|||
this._userScrollDirection = value; |
|||
this.didUpdateScrollDirection(value); |
|||
} |
|||
|
|||
public override IPromise animateTo(double to, |
|||
TimeSpan duration, |
|||
Curve curve |
|||
) { |
|||
if (PhysicsUtils.nearEqual(to, this.pixels, this.physics.tolerance.distance)) { |
|||
this.jumpTo(to); |
|||
return Promise.Resolved(); |
|||
} |
|||
|
|||
DrivenScrollActivity activity = new DrivenScrollActivity( |
|||
this, |
|||
from: this.pixels, |
|||
to: to, |
|||
duration: duration, |
|||
curve: curve, |
|||
vsync: this.context.vsync |
|||
); |
|||
this.beginActivity(activity); |
|||
return activity.done; |
|||
} |
|||
|
|||
public override void jumpTo(double value) { |
|||
this.goIdle(); |
|||
if (this.pixels != value) { |
|||
double oldPixels = this.pixels; |
|||
this.forcePixels(value); |
|||
this.notifyListeners(); |
|||
this.didStartScroll(); |
|||
this.didUpdateScrollPositionBy(this.pixels - oldPixels); |
|||
this.didEndScroll(); |
|||
} |
|||
|
|||
this.goBallistic(0.0); |
|||
} |
|||
|
|||
public override ScrollHoldController hold(VoidCallback holdCancelCallback) { |
|||
double previousVelocity = this.activity.velocity; |
|||
HoldScrollActivity holdActivity = new HoldScrollActivity( |
|||
del: this, |
|||
onHoldCanceled: holdCancelCallback |
|||
); |
|||
this.beginActivity(holdActivity); |
|||
this._heldPreviousVelocity = previousVelocity; |
|||
return holdActivity; |
|||
} |
|||
|
|||
ScrollDragController _currentDrag; |
|||
|
|||
public override Drag drag(DragStartDetails details, VoidCallback dragCancelCallback) { |
|||
ScrollDragController drag = new ScrollDragController( |
|||
del: this, |
|||
details: details, |
|||
onDragCanceled: dragCancelCallback, |
|||
carriedVelocity: this.physics.carriedMomentum(this._heldPreviousVelocity), |
|||
motionStartDistanceThreshold: this.physics.dragStartDistanceMotionThreshold |
|||
); |
|||
this.beginActivity(new DragScrollActivity(this, drag)); |
|||
D.assert(this._currentDrag == null); |
|||
this._currentDrag = drag; |
|||
return drag; |
|||
} |
|||
|
|||
public override void dispose() { |
|||
if (this._currentDrag != null) { |
|||
this._currentDrag.dispose(); |
|||
this._currentDrag = null; |
|||
} |
|||
|
|||
base.dispose(); |
|||
} |
|||
|
|||
protected override void debugFillDescription(List<String> description) { |
|||
base.debugFillDescription(description); |
|||
description.Add(this.context.GetType().ToString()); |
|||
description.Add(this.physics.ToString()); |
|||
description.Add(this.activity.ToString()); |
|||
description.Add(this.userScrollDirection.ToString()); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9379d18fbd274c9b834f6d440e39959d |
|||
timeCreated: 1537159068 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using RSG; |
|||
using UIWidgets.animation; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.gestures; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.scheduler; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public delegate Widget ViewportBuilder(BuildContext context, ViewportOffset position); |
|||
|
|||
public class Scrollable : StatefulWidget { |
|||
public Scrollable( |
|||
Key key = null, |
|||
AxisDirection axisDirection = AxisDirection.down, |
|||
ScrollController controller = null, |
|||
ScrollPhysics physics = null, |
|||
ViewportBuilder viewportBuilder = null |
|||
) : base(key: key) { |
|||
D.assert(viewportBuilder != null); |
|||
|
|||
this.axisDirection = axisDirection; |
|||
this.controller = controller; |
|||
this.physics = physics; |
|||
this.viewportBuilder = viewportBuilder; |
|||
} |
|||
|
|||
public readonly AxisDirection axisDirection; |
|||
|
|||
public readonly ScrollController controller; |
|||
|
|||
public readonly ScrollPhysics physics; |
|||
|
|||
public readonly ViewportBuilder viewportBuilder; |
|||
|
|||
public Axis axis { |
|||
get { return AxisUtils.axisDirectionToAxis(this.axisDirection); } |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new ScrollableState(); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new EnumProperty<AxisDirection>("axisDirection", this.axisDirection)); |
|||
properties.add(new DiagnosticsProperty<ScrollPhysics>("physics", this.physics)); |
|||
} |
|||
|
|||
public static ScrollableState of(BuildContext context) { |
|||
_ScrollableScope widget = (_ScrollableScope) context.inheritFromWidgetOfExactType(typeof(_ScrollableScope)); |
|||
return widget == null ? null : widget.scrollable; |
|||
} |
|||
|
|||
public static IPromise ensureVisible(BuildContext context, |
|||
double alignment = 0.0, |
|||
TimeSpan? duration = null, |
|||
Curve curve = null |
|||
) { |
|||
duration = duration ?? TimeSpan.Zero; |
|||
curve = curve ?? Curves.ease; |
|||
List<IPromise> futures = new List<IPromise>(); |
|||
|
|||
ScrollableState scrollable = Scrollable.of(context); |
|||
while (scrollable != null) { |
|||
futures.Add(scrollable.position.ensureVisible( |
|||
context.findRenderObject(), |
|||
alignment: alignment, |
|||
duration: duration, |
|||
curve: curve |
|||
)); |
|||
context = scrollable.context; |
|||
scrollable = Scrollable.of(context); |
|||
} |
|||
|
|||
if (futures.isEmpty() || duration == TimeSpan.Zero) { |
|||
return Promise.Resolved(); |
|||
} |
|||
|
|||
if (futures.Count == 1) { |
|||
return futures.Single(); |
|||
} |
|||
|
|||
return Promise.All(futures); |
|||
} |
|||
} |
|||
|
|||
class _ScrollableScope : InheritedWidget { |
|||
internal _ScrollableScope( |
|||
Key key = null, |
|||
ScrollableState scrollable = null, |
|||
ScrollPosition position = null, |
|||
Widget child = null |
|||
) : base(key: key, child: child) { |
|||
D.assert(scrollable != null); |
|||
D.assert(child != null); |
|||
this.scrollable = scrollable; |
|||
this.position = position; |
|||
} |
|||
|
|||
public readonly ScrollableState scrollable; |
|||
public readonly ScrollPosition position; |
|||
|
|||
public override bool updateShouldNotify(InheritedWidget old) { |
|||
return this.position != ((_ScrollableScope) old).position; |
|||
} |
|||
} |
|||
|
|||
public class ScrollableState : TickerProviderStateMixin<Scrollable>, ScrollContext { |
|||
public SchedulerBinding schedulerBinding { get; set; } |
|||
|
|||
public ScrollPosition position { |
|||
get { return this._position; } |
|||
} |
|||
|
|||
ScrollPosition _position; |
|||
|
|||
public AxisDirection axisDirection { |
|||
get { return this.widget.axisDirection; } |
|||
} |
|||
|
|||
ScrollBehavior _configuration; |
|||
|
|||
ScrollPhysics _physics; |
|||
|
|||
void _updatePosition() { |
|||
this._configuration = ScrollConfiguration.of(this.context); |
|||
this._physics = this._configuration.getScrollPhysics(this.context); |
|||
if (this.widget.physics != null) { |
|||
this._physics = this.widget.physics.applyTo(this._physics); |
|||
} |
|||
|
|||
ScrollController controller = this.widget.controller; |
|||
ScrollPosition oldPosition = this.position; |
|||
if (oldPosition != null) { |
|||
if (controller != null) { |
|||
controller.detach(oldPosition); |
|||
} |
|||
|
|||
this.schedulerBinding.window.scheduleMicrotask(oldPosition.dispose); |
|||
} |
|||
|
|||
if (controller != null) { |
|||
this._position = controller.createScrollPosition(this._physics, this, oldPosition); |
|||
} |
|||
|
|||
this._position = this._position |
|||
?? new ScrollPositionWithSingleContext(physics: this._physics, context: this, |
|||
oldPosition: oldPosition); |
|||
|
|||
D.assert(this.position != null); |
|||
if (controller != null) { |
|||
controller.attach(this.position); |
|||
} |
|||
} |
|||
|
|||
public override void didChangeDependencies() { |
|||
base.didChangeDependencies(); |
|||
this._updatePosition(); |
|||
} |
|||
|
|||
bool _shouldUpdatePosition(Scrollable oldWidget) { |
|||
ScrollPhysics newPhysics = this.widget.physics; |
|||
ScrollPhysics oldPhysics = oldWidget.physics; |
|||
do { |
|||
Type newPhysicsType = newPhysics != null ? newPhysics.GetType() : null; |
|||
Type oldPhysicsType = oldPhysics != null ? oldPhysics.GetType() : null; |
|||
|
|||
if (newPhysicsType != oldPhysicsType) { |
|||
return true; |
|||
} |
|||
|
|||
if (newPhysics != null) { |
|||
newPhysics = newPhysics.parent; |
|||
} |
|||
|
|||
if (oldPhysics != null) { |
|||
oldPhysics = oldPhysics.parent; |
|||
} |
|||
} while (newPhysics != null || oldPhysics != null); |
|||
|
|||
Type controllerType = widget.controller == null ? null : widget.controller.GetType(); |
|||
Type oldControllerType = oldWidget.controller == null ? null : oldWidget.controller.GetType(); |
|||
return controllerType != oldControllerType; |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidgetRaw) { |
|||
Scrollable oldWidget = (Scrollable) oldWidgetRaw; |
|||
base.didUpdateWidget(oldWidget); |
|||
|
|||
if (this.widget.controller != oldWidget.controller) { |
|||
if (oldWidget.controller != null) { |
|||
oldWidget.controller.detach(this.position); |
|||
} |
|||
|
|||
if (this.widget.controller != null) { |
|||
this.widget.controller.attach(this.position); |
|||
} |
|||
} |
|||
|
|||
if (this._shouldUpdatePosition(oldWidget)) { |
|||
this._updatePosition(); |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
if (this.widget.controller != null) { |
|||
this.widget.controller.detach(this.position); |
|||
} |
|||
|
|||
this.position.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
GlobalKey<RawGestureDetectorState> _gestureDetectorKey = GlobalKey<RawGestureDetectorState>.key(); |
|||
GlobalKey _ignorePointerKey = GlobalKey.key(); |
|||
|
|||
Dictionary<Type, GestureRecognizerFactory> _gestureRecognizers = |
|||
new Dictionary<Type, GestureRecognizerFactory>(); |
|||
|
|||
bool _shouldIgnorePointer = false; |
|||
|
|||
bool _lastCanDrag; |
|||
Axis _lastAxisDirection; |
|||
|
|||
public void setCanDrag(bool canDrag) { |
|||
if (canDrag == this._lastCanDrag && (!canDrag || this.widget.axis == this._lastAxisDirection)) { |
|||
return; |
|||
} |
|||
|
|||
if (!canDrag) { |
|||
this._gestureRecognizers = new Dictionary<Type, GestureRecognizerFactory>(); |
|||
} else { |
|||
switch (this.widget.axis) { |
|||
case Axis.vertical: |
|||
this._gestureRecognizers = new Dictionary<Type, GestureRecognizerFactory>(); |
|||
this._gestureRecognizers.Add(typeof(VerticalDragGestureRecognizer), |
|||
new GestureRecognizerFactoryWithHandlers<VerticalDragGestureRecognizer>( |
|||
() => new VerticalDragGestureRecognizer(), |
|||
instance => { |
|||
instance.onDown = this._handleDragDown; |
|||
instance.onStart = this._handleDragStart; |
|||
instance.onUpdate = this._handleDragUpdate; |
|||
instance.onEnd = this._handleDragEnd; |
|||
instance.onCancel = this._handleDragCancel; |
|||
instance.minFlingDistance = |
|||
this._physics == null ? (double?) null : this._physics.minFlingDistance; |
|||
instance.minFlingVelocity = |
|||
this._physics == null ? (double?) null : this._physics.minFlingVelocity; |
|||
instance.maxFlingVelocity = |
|||
this._physics == null ? (double?) null : this._physics.maxFlingVelocity; |
|||
} |
|||
)); |
|||
break; |
|||
case Axis.horizontal: |
|||
this._gestureRecognizers = new Dictionary<Type, GestureRecognizerFactory>(); |
|||
this._gestureRecognizers.Add(typeof(HorizontalDragGestureRecognizer), |
|||
new GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>( |
|||
() => new HorizontalDragGestureRecognizer(), |
|||
instance => { |
|||
instance.onDown = this._handleDragDown; |
|||
instance.onStart = this._handleDragStart; |
|||
instance.onUpdate = this._handleDragUpdate; |
|||
instance.onEnd = this._handleDragEnd; |
|||
instance.onCancel = this._handleDragCancel; |
|||
instance.minFlingDistance = |
|||
this._physics == null ? (double?) null : this._physics.minFlingDistance; |
|||
instance.minFlingVelocity = |
|||
this._physics == null ? (double?) null : this._physics.minFlingVelocity; |
|||
instance.maxFlingVelocity = |
|||
this._physics == null ? (double?) null : this._physics.maxFlingVelocity; |
|||
} |
|||
)); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
this._lastCanDrag = canDrag; |
|||
this._lastAxisDirection = this.widget.axis; |
|||
if (this._gestureDetectorKey.currentState != null) { |
|||
this._gestureDetectorKey.currentState.replaceGestureRecognizers(this._gestureRecognizers); |
|||
} |
|||
} |
|||
|
|||
public TickerProvider vsync { |
|||
get { return this; } |
|||
} |
|||
|
|||
public void setIgnorePointer(bool value) { |
|||
if (this._shouldIgnorePointer == value) { |
|||
return; |
|||
} |
|||
|
|||
this._shouldIgnorePointer = value; |
|||
if (this._ignorePointerKey.currentContext != null) { |
|||
var renderBox = (RenderIgnorePointer) this._ignorePointerKey.currentContext.findRenderObject(); |
|||
renderBox.ignoring = this._shouldIgnorePointer; |
|||
} |
|||
} |
|||
|
|||
public BuildContext notificationContext { |
|||
get { return this._gestureDetectorKey.currentContext; } |
|||
} |
|||
|
|||
public BuildContext storageContext { |
|||
get { return this.context; } |
|||
} |
|||
|
|||
Drag _drag; |
|||
|
|||
ScrollHoldController _hold; |
|||
|
|||
void _handleDragDown(DragDownDetails details) { |
|||
D.assert(this._drag == null); |
|||
D.assert(this._hold == null); |
|||
this._hold = this.position.hold(this._disposeHold); |
|||
} |
|||
|
|||
void _handleDragStart(DragStartDetails details) { |
|||
D.assert(this._drag == null); |
|||
this._drag = this.position.drag(details, this._disposeDrag); |
|||
D.assert(this._drag != null); |
|||
D.assert(this._hold == null); |
|||
} |
|||
|
|||
void _handleDragUpdate(DragUpdateDetails details) { |
|||
D.assert(this._hold == null || this._drag == null); |
|||
if (this._drag != null) { |
|||
this._drag.update(details); |
|||
} |
|||
} |
|||
|
|||
void _handleDragEnd(DragEndDetails details) { |
|||
D.assert(this._hold == null || this._drag == null); |
|||
if (this._drag != null) { |
|||
this._drag.end(details); |
|||
} |
|||
|
|||
D.assert(this._drag == null); |
|||
} |
|||
|
|||
void _handleDragCancel() { |
|||
D.assert(this._hold == null || this._drag == null); |
|||
if (this._hold != null) { |
|||
this._hold.cancel(); |
|||
} |
|||
|
|||
if (this._drag != null) { |
|||
this._drag.cancel(); |
|||
} |
|||
|
|||
D.assert(this._hold == null); |
|||
D.assert(this._drag == null); |
|||
} |
|||
|
|||
void _disposeHold() { |
|||
this._hold = null; |
|||
} |
|||
|
|||
void _disposeDrag() { |
|||
this._drag = null; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
D.assert(this.position != null); |
|||
|
|||
Widget result = new RawGestureDetector( |
|||
key: this._gestureDetectorKey, |
|||
gestures: this._gestureRecognizers, |
|||
behavior: HitTestBehavior.opaque, |
|||
child: new IgnorePointer( |
|||
key: this._ignorePointerKey, |
|||
ignoring: this._shouldIgnorePointer, |
|||
child: new _ScrollableScope( |
|||
scrollable: this, |
|||
position: this.position, |
|||
child: this.widget.viewportBuilder(context, this.position) |
|||
) |
|||
) |
|||
); |
|||
|
|||
return this._configuration.buildViewportChrome(context, result, this.widget.axisDirection); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<ScrollPosition>("position", this.position)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c3917312a54a4263a839cd628ae99010 |
|||
timeCreated: 1537160124 |
撰写
预览
正在加载...
取消
保存
Reference in new issue