|
|
|
|
|
|
if (children.isEmpty()) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return new Container(child: children[Mathf.Abs(index % children.Count)]); |
|
|
|
return new IndexedSemantics(child: children[Mathf.Abs(index % children.Count)]); |
|
|
|
} |
|
|
|
|
|
|
|
public bool shouldRebuild(ListWheelChildDelegate oldDelegate) { |
|
|
|
|
|
|
public Widget build(BuildContext context, int index) { |
|
|
|
if (childCount == null) { |
|
|
|
Widget child = builder(context, index); |
|
|
|
return child == null ? null : new Container(child: child); |
|
|
|
return child == null ? null : new IndexedSemantics(child: child); |
|
|
|
} |
|
|
|
|
|
|
|
if (index < 0 || index >= childCount) { |
|
|
|
|
|
|
return new Container(child: builder(context, index)); |
|
|
|
return new IndexedSemantics(child: builder(context, index)); |
|
|
|
} |
|
|
|
|
|
|
|
public int trueIndexOf(int index) { |
|
|
|
|
|
|
|
|
|
|
class ListWheelScrollViewUtils { |
|
|
|
public static int _getItemFromOffset( |
|
|
|
float? offset = null, |
|
|
|
float? itemExtent = null, |
|
|
|
float? minScrollExtent = null, |
|
|
|
float? maxScrollExtent = null |
|
|
|
float offset , |
|
|
|
float itemExtent , |
|
|
|
float minScrollExtent , |
|
|
|
float maxScrollExtent |
|
|
|
var _itemExtent = itemExtent ?? 1.0f; |
|
|
|
return (_clipOffsetToScrollableRange(offset ?? 0.0f , minScrollExtent ?? 0.0f, maxScrollExtent ?? 0.0f) / _itemExtent).round(); |
|
|
|
return (_clipOffsetToScrollableRange(offset, minScrollExtent, maxScrollExtent) / itemExtent).round(); |
|
|
|
} |
|
|
|
public static float _clipOffsetToScrollableRange( |
|
|
|
float offset, |
|
|
|
|
|
|
() => |
|
|
|
"The selectedItem property cannot be read when multiple scroll views are attached to the same FixedExtentScrollController." |
|
|
|
); |
|
|
|
_FixedExtentScrollPosition position = (_FixedExtentScrollPosition) this.position; |
|
|
|
_FixedExtentScrollPosition position = (_FixedExtentScrollPosition) this.position; |
|
|
|
return position.itemIndex; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
TimeSpan? duration = null, |
|
|
|
Curve curve = null |
|
|
|
TimeSpan duration, |
|
|
|
Curve curve |
|
|
|
|
|
|
|
duration: duration ?? new TimeSpan(0,0,0,0,0), |
|
|
|
duration: duration, |
|
|
|
|
|
|
|
return Future.wait<object>(futures); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
public interface IFixedExtentMetrics { |
|
|
|
int itemIndex { set; get; } |
|
|
|
|
|
|
|
/*FixedExtentMetrics copyWith( |
|
|
|
float? minScrollExtent = null, |
|
|
|
float? maxScrollExtent = null, |
|
|
|
float? pixels = null, |
|
|
|
float? viewportDimension = null, |
|
|
|
AxisDirection? axisDirection = null, |
|
|
|
int? itemIndex = null |
|
|
|
);*/ |
|
|
|
|
|
|
|
FixedExtentMetrics copyWith( |
|
|
|
float? minScrollExtent = null, |
|
|
|
float? maxScrollExtent = null, |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class FixedExtentMetrics : FixedScrollMetrics, IFixedExtentMetrics { |
|
|
|
public FixedExtentMetrics( |
|
|
|
/*public FixedExtentMetrics( |
|
|
|
float? minScrollExtent = null, |
|
|
|
float? maxScrollExtent = null, |
|
|
|
float? pixels = null, |
|
|
|
|
|
|
axisDirection: axisDirection |
|
|
|
) { |
|
|
|
this.itemIndex = itemIndex ?? 0; |
|
|
|
}*/ |
|
|
|
public FixedExtentMetrics( |
|
|
|
float minScrollExtent , |
|
|
|
float maxScrollExtent, |
|
|
|
float pixels , |
|
|
|
float viewportDimension , |
|
|
|
AxisDirection axisDirection , |
|
|
|
int itemIndex |
|
|
|
) : base( |
|
|
|
minScrollExtent: minScrollExtent , |
|
|
|
maxScrollExtent: maxScrollExtent , |
|
|
|
pixels: pixels , |
|
|
|
viewportDimension: viewportDimension , |
|
|
|
axisDirection: axisDirection |
|
|
|
) { |
|
|
|
this.itemIndex = itemIndex; |
|
|
|
} |
|
|
|
|
|
|
|
public int itemIndex { get; set; } |
|
|
|
|
|
|
) : base( |
|
|
|
physics: physics, |
|
|
|
context: context, |
|
|
|
initialPixels: _getItemExtentFromScrollContext(context) * initialItem, |
|
|
|
initialPixels: _getItemExtentFromScrollContext(context) * (initialItem ?? 0.0f), |
|
|
|
keepScrollOffset: keepScrollOffset, |
|
|
|
oldPosition: oldPosition, |
|
|
|
debugLabel: debugLabel |
|
|
|
|
|
|
|
|
|
|
static float _getItemExtentFromScrollContext(ScrollContext context) { |
|
|
|
_FixedExtentScrollableState scrollable = (_FixedExtentScrollableState) context; |
|
|
|
return scrollable.itemExtent ?? 0.0f; |
|
|
|
return scrollable.itemExtent; |
|
|
|
} |
|
|
|
|
|
|
|
public float itemExtent { |
|
|
|
|
|
|
|
|
|
|
class _FixedExtentScrollable : Scrollable { |
|
|
|
public _FixedExtentScrollable( |
|
|
|
float itemExtent, |
|
|
|
ScrollPhysics physics = null, |
|
|
|
float? itemExtent = null, |
|
|
|
ScrollPhysics physics = null, |
|
|
|
|
|
|
|
) : base( |
|
|
|
key: key, |
|
|
|
axisDirection: axisDirection, |
|
|
|
|
|
|
this.itemExtent = itemExtent; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly float? itemExtent; |
|
|
|
public readonly float itemExtent; |
|
|
|
|
|
|
|
public override State createState() { |
|
|
|
return new _FixedExtentScrollableState(); |
|
|
|
|
|
|
class _FixedExtentScrollableState : ScrollableState { |
|
|
|
public float? itemExtent { |
|
|
|
public float itemExtent { |
|
|
|
get { |
|
|
|
_FixedExtentScrollable actualWidget = (_FixedExtentScrollable) widget; |
|
|
|
return actualWidget.itemExtent; |
|
|
|
|
|
|
public class ListWheelScrollView : StatefulWidget { |
|
|
|
public ListWheelScrollView( |
|
|
|
List<Widget> children, |
|
|
|
float itemExtent, |
|
|
|
Key key = null, |
|
|
|
ScrollController controller = null, |
|
|
|
ScrollPhysics physics = null, |
|
|
|
|
|
|
bool useMagnifier = false, |
|
|
|
float magnification = 1.0f, |
|
|
|
float overAndUnderCenterOpacity = 1.0f, |
|
|
|
float? itemExtent = null, |
|
|
|
float squeeze = 1.0f, |
|
|
|
ValueChanged<int> onSelectedItemChanged = null, |
|
|
|
bool clipToSize = true, |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public ListWheelScrollView ( |
|
|
|
float itemExtent, |
|
|
|
Key key = null, |
|
|
|
ScrollController controller = null, |
|
|
|
ScrollPhysics physics = null, |
|
|
|
|
|
|
bool useMagnifier = false, |
|
|
|
float magnification = 1.0f, |
|
|
|
float? itemExtent = null, |
|
|
|
float squeeze = 1.0f, |
|
|
|
ValueChanged<int> onSelectedItemChanged = null, |
|
|
|
float overAndUnderCenterOpacity = 1.0f, |
|
|
|
|
|
|
public readonly float offAxisFraction; |
|
|
|
public readonly bool useMagnifier; |
|
|
|
public readonly float magnification; |
|
|
|
public readonly float? itemExtent; |
|
|
|
public readonly float itemExtent; |
|
|
|
public readonly float overAndUnderCenterOpacity; |
|
|
|
public readonly float squeeze; |
|
|
|
public readonly ValueChanged<int> onSelectedItemChanged; |
|
|
|