浏览代码

fix date_ picker

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
515e769d
共有 8 个文件被更改,包括 627 次插入1591 次删除
  1. 10
      com.unity.uiwidgets/Runtime/animation/tween.cs
  2. 858
      com.unity.uiwidgets/Runtime/cupertino/context_menu.cs
  3. 995
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
  4. 6
      com.unity.uiwidgets/Runtime/cupertino/localization.cs
  5. 317
      com.unity.uiwidgets/Runtime/cupertino/picker.cs
  6. 25
      com.unity.uiwidgets/Runtime/cupertino/text_theme.cs
  7. 5
      com.unity.uiwidgets/Runtime/painting/edge_insets.cs
  8. 2
      com.unity.uiwidgets/Runtime/painting/text_painter.cs

10
com.unity.uiwidgets/Runtime/animation/tween.cs


}
}
public abstract class Tween<T> : Animatable<T>, IEquatable<Tween<T>> {
public class Tween<T> : Animatable<T>, IEquatable<Tween<T>> {
public Tween(T begin, T end) {
this.begin = begin;
this.end = end;

public virtual T end { get; set; }
public abstract T lerp(float t);
public virtual T lerp(float t) {
D.assert(begin != null);
D.assert(end != null);
return default; //begin + (end - begin) * t as T;
}
public override T transform(float t) {
if (t == 0.0)
return begin;

858
com.unity.uiwidgets/Runtime/cupertino/context_menu.cs


)
);
}
public override Widget build(BuildContext context) {
List<Widget> widgets = new List<Widget>();
widgets.Add(new AnimatedBuilder(
builder: _buildAnimation,
animation: widget.controller
));
return new Stack(
children: widgets
);
public override Widget build(BuildContext context) {
List<Widget> widgets = new List<Widget>();
widgets.Add(new AnimatedBuilder(
builder: _buildAnimation,
animation: widget.controller)
);
return new Stack(
children: widgets
);
public class _ContextMenuRoute : PopupRoute {
public _ContextMenuRoute(
List<Widget> actions = null,
_ContextMenuLocation contextMenuLocation = default,
string barrierLabel = null,
_ContextMenuPreviewBuilderChildless builder = null,
ImageFilter filter = null,
Rect previousChildRect = null,
RouteSettings settings = null
) : base(
filter: filter,
settings: settings
){
D.assert(actions != null && actions.isNotEmpty());
D.assert(contextMenuLocation != null);
this.barrierLabel = barrierLabel;
_actions = actions;
_builder = builder;
_contextMenuLocation = contextMenuLocation;
_previousChildRect = previousChildRect;
}
public readonly static Color _kModalBarrierColor = new Color(0x6604040F);
public readonly TimeSpan _kModalPopupTransitionDuration =new TimeSpan(0, 0, 0, 0, 335);
public readonly List<Widget> _actions;
public readonly _ContextMenuPreviewBuilderChildless _builder;
public readonly GlobalKey _childGlobalKey = new LabeledGlobalKey<State<StatefulWidget>>();
public readonly _ContextMenuLocation _contextMenuLocation;
public bool _externalOffstage = false;
public bool _internalOffstage = false;
public Orientation _lastOrientation;
public readonly Rect _previousChildRect;
public float _scale = 1.0f;
public readonly GlobalKey _sheetGlobalKey = new LabeledGlobalKey<State<StatefulWidget>>();//GlobalKey();
public readonly static CurveTween _curve = new CurveTween(
curve: Curves.easeOutBack
);
public readonly static CurveTween _curveReverse = new CurveTween(
curve: Curves.easeInBack
);
public readonly static RectTween _rectTween = new RectTween();
public readonly static Animatable<Rect> _rectAnimatable = _rectTween.chain(_curve);
public readonly static RectTween _rectTweenReverse = new RectTween();
public readonly static Animatable<Rect> _rectAnimatableReverse = _rectTweenReverse.chain(_curveReverse);
public class _ContextMenuRoute : PopupRoute {
public _ContextMenuRoute(
List<Widget> actions = null,
_ContextMenuLocation contextMenuLocation = default,
string barrierLabel = null,
_ContextMenuPreviewBuilderChildless builder = null,
ImageFilter filter = null,
Rect previousChildRect = null,
RouteSettings settings = null
) : base(filter: filter, settings: settings){
D.assert(actions != null && actions.isNotEmpty());
D.assert(contextMenuLocation != null);
this.barrierLabel = barrierLabel;
_actions = actions;
_builder = builder;
_contextMenuLocation = contextMenuLocation;
_previousChildRect = previousChildRect;
}
public readonly static Color _kModalBarrierColor = new Color(0x6604040F);
public readonly TimeSpan _kModalPopupTransitionDuration =new TimeSpan(0, 0, 0, 0, 335);
public readonly List<Widget> _actions;
public readonly _ContextMenuPreviewBuilderChildless _builder;
public readonly GlobalKey _childGlobalKey = new LabeledGlobalKey<State<StatefulWidget>>();
public readonly _ContextMenuLocation _contextMenuLocation;
public bool _externalOffstage = false;
public bool _internalOffstage = false;
public Orientation _lastOrientation;
public readonly Rect _previousChildRect;
public float _scale = 1.0f;
public readonly GlobalKey _sheetGlobalKey = new LabeledGlobalKey<State<StatefulWidget>>();//GlobalKey();
public readonly static CurveTween _curve = new CurveTween(
curve: Curves.easeOutBack
);
public readonly static CurveTween _curveReverse = new CurveTween(
curve: Curves.easeInBack
);
public readonly static RectTween _rectTween = new RectTween();
public readonly static Animatable<Rect> _rectAnimatable = _rectTween.chain(_curve);
public readonly static RectTween _rectTweenReverse = new RectTween();
public readonly static Animatable<Rect> _rectAnimatableReverse = _rectTweenReverse.chain(_curveReverse);
public readonly static RectTween _sheetRectTween = new RectTween();
public readonly Animatable<Rect> _sheetRectAnimatable = _sheetRectTween.chain(_curve);
public readonly Animatable<Rect> _sheetRectAnimatableReverse = _sheetRectTween.chain(_curveReverse);
public readonly static Tween< float> _sheetScaleTween = new FloatTween(0.0f,0.0f);
public readonly static Animatable< float> _sheetScaleAnimatable = _sheetScaleTween.chain(_curve);
public readonly static Animatable< float> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(_curveReverse);
public readonly Tween< float> _opacityTween = new FloatTween(begin: 0.0f, end: 1.0f);
public Animation< float> _sheetOpacity;
public readonly static RectTween _sheetRectTween = new RectTween();
public readonly Animatable<Rect> _sheetRectAnimatable = _sheetRectTween.chain(_curve);
public readonly Animatable<Rect> _sheetRectAnimatableReverse = _sheetRectTween.chain(_curveReverse);
public readonly static Tween< float> _sheetScaleTween = new FloatTween(0.0f,0.0f);
public readonly static Animatable< float> _sheetScaleAnimatable = _sheetScaleTween.chain(_curve);
public readonly static Animatable< float> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(_curveReverse);
public readonly Tween< float> _opacityTween = new FloatTween(begin: 0.0f, end: 1.0f);
public Animation< float> _sheetOpacity;
public readonly string barrierLabel;
public readonly string barrierLabel;
public Color barrierColor {
get { return _kModalBarrierColor; }
}
public bool barrierDismissible{
get { return false; }
}
public Color barrierColor {
get { return _kModalBarrierColor; }
}
public bool barrierDismissible{
get { return false; }
}
public bool semanticsDismissible {
get { return true; }
}
public bool semanticsDismissible {
get { return true; }
}
public TimeSpan transitionDuration {
get {
return _kModalPopupTransitionDuration;
public TimeSpan transitionDuration {
get {
return _kModalPopupTransitionDuration;
}
}
/*public static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation) {
switch (contextMenuLocation) {
case _ContextMenuLocation.center:
return AlignmentDirectional.topCenter;
case _ContextMenuLocation.right:
return AlignmentDirectional.topEnd;
default:
return AlignmentDirectional.topStart;
}
}*/
public static Rect _getScaledRect(GlobalKey globalKey, float scale) {
Rect childRect = CupertinoContextMenuUtils._getRect(globalKey);
Size sizeScaled = childRect.size * scale;
Offset offsetScaled = new Offset(
childRect.left + (childRect.size.width - sizeScaled.width) / 2,
childRect.top + (childRect.size.height - sizeScaled.height) / 2
);
return offsetScaled & sizeScaled;
}
public static Rect _getSheetRectBegin(Orientation orientation, _ContextMenuLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
switch (contextMenuLocation) {
case _ContextMenuLocation.center:
Offset target1 = (orientation == Orientation.portrait)
? childRect.bottomCenter
: childRect.topCenter;
Offset centered = target1 - new Offset(sheetRect.width / 2, 0.0f);
return centered & sheetRect.size;
case _ContextMenuLocation.right:
Offset target2 = ((orientation == Orientation.portrait)
? childRect.bottomRight
: childRect.topRight);
return (target2 - new Offset(sheetRect.width, 0.0f)) & sheetRect.size;
default:
Offset target3 = orientation == Orientation.portrait
? childRect.bottomLeft
: childRect.topLeft;
return target3 & sheetRect.size;
}
}
public void _onDismiss(BuildContext context, float scale, float opacity) {
_scale = scale;
_opacityTween.end = opacity;
_sheetOpacity = _opacityTween.animate(
new CurvedAnimation(
parent: animation,
curve: new Interval(0.9f, 1.0f)
));
Navigator.of(context).pop<object>();
}
public void _updateTweenRects() {
Rect childRect = _scale == null
? CupertinoContextMenuUtils._getRect(_childGlobalKey)
: _getScaledRect(_childGlobalKey, _scale);
_rectTween.begin = _previousChildRect;
_rectTween.end = childRect;
Rect childRectOriginal = CupertinoContextMenuUtils.fromCenter(
center: _previousChildRect.center,
width: _previousChildRect.width / CupertinoContextMenuUtils._kOpenScale,
height: _previousChildRect.height / CupertinoContextMenuUtils._kOpenScale
);
Rect sheetRect = CupertinoContextMenuUtils._getRect(_sheetGlobalKey);
Rect sheetRectBegin = _getSheetRectBegin(
_lastOrientation,
_contextMenuLocation,
childRectOriginal,
sheetRect
);
_sheetRectTween.begin = sheetRectBegin;
_sheetRectTween.end = sheetRect;
_sheetScaleTween.begin = 0.0f;
_sheetScaleTween.end = _scale;
_rectTweenReverse.begin = childRectOriginal;
_rectTweenReverse.end = childRect;
}
public static Rect _getScaledRect(GlobalKey globalKey, float scale) {
Rect childRect = CupertinoContextMenuUtils._getRect(globalKey);
Size sizeScaled = childRect.size * scale;
Offset offsetScaled = new Offset(
childRect.left + (childRect.size.width - sizeScaled.width) / 2,
childRect.top + (childRect.size.height - sizeScaled.height) / 2
);
return offsetScaled & sizeScaled;
}
/*public static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation) {
switch (contextMenuLocation) {
case _ContextMenuLocation.center:
return AlignmentDirectional.topCenter;
case _ContextMenuLocation.right:
return AlignmentDirectional.topEnd;
default:
return AlignmentDirectional.topStart;
public void _setOffstageInternally() {
base.offstage = _externalOffstage || _internalOffstage;
changedInternalState();
}*/
public static Rect _getSheetRectBegin(Orientation orientation, _ContextMenuLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
switch (contextMenuLocation) {
case _ContextMenuLocation.center:
Offset target1 = (orientation == Orientation.portrait)
? childRect.bottomCenter
: childRect.topCenter;
Offset centered = target1 - new Offset(sheetRect.width / 2, 0.0f);
return centered & sheetRect.size;
case _ContextMenuLocation.right:
Offset target2 = ((orientation == Orientation.portrait)
? childRect.bottomRight
: childRect.topRight);
return (target2 - new Offset(sheetRect.width, 0.0f)) & sheetRect.size;
default:
Offset target3 = orientation == Orientation.portrait
? childRect.bottomLeft
: childRect.topLeft;
return target3 & sheetRect.size;
public bool didPop(object result) {
_updateTweenRects();
return base.didPop(result);
}
public void _onDismiss(BuildContext context, float scale, float opacity) {
_scale = scale;
_opacityTween.end = opacity;
_sheetOpacity = _opacityTween.animate(
new CurvedAnimation(
parent: animation,
curve: new Interval(0.9f, 1.0f)
));
Navigator.of(context).pop<object>();
}
public void _updateTweenRects() {
Rect childRect = _scale == null
? CupertinoContextMenuUtils._getRect(_childGlobalKey)
: _getScaledRect(_childGlobalKey, _scale);
_rectTween.begin = _previousChildRect;
_rectTween.end = childRect;
Rect childRectOriginal = CupertinoContextMenuUtils.fromCenter(
center: _previousChildRect.center,
width: _previousChildRect.width / CupertinoContextMenuUtils._kOpenScale,
height: _previousChildRect.height / CupertinoContextMenuUtils._kOpenScale
);
Rect sheetRect = CupertinoContextMenuUtils._getRect(_sheetGlobalKey);
Rect sheetRectBegin = _getSheetRectBegin(
_lastOrientation,
_contextMenuLocation,
childRectOriginal,
sheetRect
);
_sheetRectTween.begin = sheetRectBegin;
_sheetRectTween.end = sheetRect;
_sheetScaleTween.begin = 0.0f;
_sheetScaleTween.end = _scale;
_rectTweenReverse.begin = childRectOriginal;
_rectTweenReverse.end = childRect;
}
public void _setOffstageInternally() {
base.offstage = _externalOffstage || _internalOffstage;
changedInternalState();
}
public bool didPop(object result) {
_updateTweenRects();
return base.didPop(result);
}
public bool offstage{
set{

}
public TickerFuture didPush() {
_internalOffstage = true;
_setOffstageInternally();
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timeSpan)=>{
_updateTweenRects();
_internalOffstage = false;
_setOffstageInternally();
});
return base.didPush();
}
public Animation<float> createAnimation() {
Animation< float> animation = base.createAnimation();
_sheetOpacity = _opacityTween.animate(new CurvedAnimation(
parent: animation,
curve: Curves.linear
));
return animation;
}
public override Widget buildPage(BuildContext context, Animation< float> animation, Animation< float> secondaryAnimation) {
return null;
}
public override Widget buildTransitions(BuildContext context1, Animation< float> animation, Animation< float> secondaryAnimation, Widget child) {
return new OrientationBuilder(
builder: (BuildContext context2, Orientation orientation)=>{
_lastOrientation = orientation;
if (!animation.isCompleted) {
bool reverse = animation.status == AnimationStatus.reverse;
Rect rect = reverse
? _rectAnimatableReverse.evaluate(animation)
: _rectAnimatable.evaluate(animation);
Rect sheetRect = reverse
? _sheetRectAnimatableReverse.evaluate(animation)
: _sheetRectAnimatable.evaluate(animation);
float sheetScale = reverse
? _sheetScaleAnimatableReverse.evaluate(animation)
: _sheetScaleAnimatable.evaluate(animation);
List<Widget> widgets = new List<Widget>();
widgets.Add(
Positioned.fromRect(
rect: sheetRect,
child: new Opacity(
opacity: _sheetOpacity.value,
child: Transform.scale(
//alignment: getSheetAlignment(_contextMenuLocation),
scale: sheetScale,
child: new _ContextMenuSheet(
key: _sheetGlobalKey,
public TickerFuture didPush() {
_internalOffstage = true;
_setOffstageInternally();
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timeSpan)=>{
_updateTweenRects();
_internalOffstage = false;
_setOffstageInternally();
});
return base.didPush();
}
public Animation<float> createAnimation() {
Animation< float> animation = base.createAnimation();
_sheetOpacity = _opacityTween.animate(new CurvedAnimation(
parent: animation,
curve: Curves.linear
));
return animation;
}
public override Widget buildPage(BuildContext context, Animation< float> animation, Animation< float> secondaryAnimation) {
return null;
}
public override Widget buildTransitions(BuildContext context1, Animation< float> animation, Animation< float> secondaryAnimation, Widget child) {
return new OrientationBuilder(
builder: (BuildContext context2, Orientation orientation)=>{
_lastOrientation = orientation;
if (!animation.isCompleted) {
bool reverse = animation.status == AnimationStatus.reverse;
Rect rect = reverse
? _rectAnimatableReverse.evaluate(animation)
: _rectAnimatable.evaluate(animation);
Rect sheetRect = reverse
? _sheetRectAnimatableReverse.evaluate(animation)
: _sheetRectAnimatable.evaluate(animation);
float sheetScale = reverse
? _sheetScaleAnimatableReverse.evaluate(animation)
: _sheetScaleAnimatable.evaluate(animation);
List<Widget> widgets = new List<Widget>();
widgets.Add(
Positioned.fromRect(
rect: sheetRect,
child: new Opacity(
opacity: _sheetOpacity.value,
child: Transform.scale(
//alignment: getSheetAlignment(_contextMenuLocation),
scale: sheetScale,
child: new _ContextMenuSheet(
key: _sheetGlobalKey,
actions: _actions,
contextMenuLocation: _contextMenuLocation,
orientation: orientation
)
)
)
)
);
widgets.Add(
Positioned.fromRect(
key: _childGlobalKey,
rect: rect,
child: _builder(context2, animation)
));
return new Stack(
children: widgets
);
}
return new _ContextMenuRouteStatic(
child: _builder(context1, animation),
childGlobalKey: _childGlobalKey,
orientation: orientation
)
)
)
)
);
widgets.Add(
Positioned.fromRect(
key: _childGlobalKey,
rect: rect,
child: _builder(context2, animation)
)
);
return new Stack(
children: widgets
);
}
return new _ContextMenuRouteStatic(
actions: _actions,
child: _builder(context1, animation),
childGlobalKey: _childGlobalKey,
contextMenuLocation: _contextMenuLocation,
onDismiss: _onDismiss,
orientation: orientation,
sheetGlobalKey: _sheetGlobalKey
);
onDismiss: _onDismiss,
orientation: orientation,
sheetGlobalKey: _sheetGlobalKey
);
}
);
);
}
public class _ContextMenuRouteStatic : StatefulWidget {
public _ContextMenuRouteStatic(
Key key = null,
List<Widget> actions = null,
Widget child = null,
GlobalKey childGlobalKey = null,
_ContextMenuLocation contextMenuLocation = default,
_DismissCallback onDismiss =default,
Orientation orientation = default,
GlobalKey sheetGlobalKey = null
) : base(key: key) {
D.assert(contextMenuLocation != null);
D.assert(orientation != null);
this.actions = actions;
this.child = child;
this.childGlobalKey = childGlobalKey;
this.contextMenuLocation = contextMenuLocation;
this.onDismiss = onDismiss;
this.orientation = orientation;
this.sheetGlobalKey = sheetGlobalKey;
}
public readonly List<Widget> actions;
public readonly Widget child;
public readonly GlobalKey childGlobalKey;
public readonly _ContextMenuLocation contextMenuLocation;
public readonly _DismissCallback onDismiss;
public readonly Orientation orientation;
public readonly GlobalKey sheetGlobalKey;
public class _ContextMenuRouteStatic : StatefulWidget {
public _ContextMenuRouteStatic(
Key key = null,
List<Widget> actions = null,
Widget child = null,
GlobalKey childGlobalKey = null,
_ContextMenuLocation contextMenuLocation = default,
_DismissCallback onDismiss =default,
Orientation orientation = default,
GlobalKey sheetGlobalKey = null
) : base(key: key) {
D.assert(contextMenuLocation != default);
D.assert(orientation != default);
this.actions = actions;
this.child = child;
this.childGlobalKey = childGlobalKey;
this.contextMenuLocation = contextMenuLocation;
this.onDismiss = onDismiss;
this.orientation = orientation;
this.sheetGlobalKey = sheetGlobalKey;
}
public readonly List<Widget> actions;
public readonly Widget child;
public readonly GlobalKey childGlobalKey;
public readonly _ContextMenuLocation contextMenuLocation;
public readonly _DismissCallback onDismiss;
public readonly Orientation orientation;
public readonly GlobalKey sheetGlobalKey;
public override State createState() {
return new _ContextMenuRouteStaticState();
public override State createState() {
return new _ContextMenuRouteStaticState();
}
}
public class _ContextMenuRouteStaticState : TickerProviderStateMixin<_ContextMenuRouteStatic> {
public readonly static float _kMinScale = 0.8f;
public readonly static float _kSheetScaleThreshold = 0.9f;
public readonly static float _kPadding = 20.0f;
public readonly static float _kDamping = 400.0f;
public readonly static TimeSpan _kMoveControllerDuration = new TimeSpan(0,0,0,600);
public Offset _dragOffset;
public float _lastScale = 1.0f;
public AnimationController _moveController;
public AnimationController _sheetController;
public Animation<Offset> _moveAnimation;
public Animation< float> _sheetScaleAnimation;
public Animation< float> _sheetOpacityAnimation;
public static float _getScale(Orientation orientation, float maxDragDistance, float dy) {
float dyDirectional = dy <= 0.0 ? dy : -dy;
return Mathf.Max(
_kMinScale,
(maxDragDistance + dyDirectional) / maxDragDistance
);
}
void _onPanStart(DragStartDetails details) {
_moveController.setValue(1.0f) ;
_setDragOffset(Offset.zero);
}
void _onPanUpdate(DragUpdateDetails details) {
_setDragOffset(_dragOffset + details.delta);
}
void _onPanEnd(DragEndDetails details) {
if (details.velocity.pixelsPerSecond.dy.abs() >= CupertinoContextMenuUtils.kMinFlingVelocity) {
bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
float finalPosition = flingIsAway
? _moveAnimation.value.dy + 100.0f
: 0.0f;
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
_sheetController.forward();
} else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
_sheetController.reverse();
}
public class _ContextMenuRouteStaticState : TickerProviderStateMixin<_ContextMenuRouteStatic> {
public readonly static float _kMinScale = 0.8f;
public readonly static float _kSheetScaleThreshold = 0.9f;
public readonly static float _kPadding = 20.0f;
public readonly static float _kDamping = 400.0f;
public readonly static TimeSpan _kMoveControllerDuration = TimeSpan.FromMilliseconds(600);
Offset _dragOffset;
public float _lastScale = 1.0f;
public AnimationController _moveController;
public AnimationController _sheetController;
public Animation<Offset> _moveAnimation;
public Animation< float> _sheetScaleAnimation;
public Animation< float> _sheetOpacityAnimation;
public static float _getScale(Orientation orientation, float maxDragDistance, float dy) {
float dyDirectional = dy <= 0.0f ? dy : -dy;
return Mathf.Max(
_kMinScale,
(maxDragDistance + dyDirectional) / maxDragDistance
);
}
void _onPanStart(DragStartDetails details) {
_moveController.setValue(1.0f) ;
_setDragOffset(Offset.zero);
}
void _onPanUpdate(DragUpdateDetails details) {
_setDragOffset(_dragOffset + details.delta);
}
void _onPanEnd(DragEndDetails details) {
if (details.velocity.pixelsPerSecond.dy.abs() >= CupertinoContextMenuUtils.kMinFlingVelocity) {
bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
float finalPosition = flingIsAway
? _moveAnimation.value.dy + 100.0f
: 0.0f;
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
_sheetController.forward();
} else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
_sheetController.reverse();
}
_moveAnimation = new OffsetTween(
begin: new Offset(0.0f, _moveAnimation.value.dy),
end:new Offset(0.0f, finalPosition)
).animate(_moveController);
_moveController.reset();
_moveController.duration = new TimeSpan(0,0,0,64);
_moveController.forward();
_moveController.addStatusListener(_flingStatusListener);
return;
}
if (_lastScale == _kMinScale) {
widget.onDismiss(context, _lastScale, _sheetOpacityAnimation.value);
return;
}
// Otherwise animate back home.
_moveController.addListener(_moveListener);
_moveController.reverse();
_moveAnimation = new OffsetTween(
begin: new Offset(0.0f, _moveAnimation.value.dy),
end:new Offset(0.0f, finalPosition)
).animate(_moveController);
_moveController.reset();
_moveController.duration = TimeSpan.FromMilliseconds(64);
_moveController.forward();
_moveController.addStatusListener(_flingStatusListener);
return;
}
if (_lastScale == _kMinScale) {
widget.onDismiss(context, _lastScale, _sheetOpacityAnimation.value);
return;
}
_moveController.addListener(_moveListener);
_moveController.reverse();
void _moveListener() {
if (_lastScale > _kSheetScaleThreshold) {
_moveController.removeListener(_moveListener);
if (_sheetController.status != AnimationStatus.dismissed) {
_sheetController.reverse();
void _moveListener() {
if (_lastScale > _kSheetScaleThreshold) {
_moveController.removeListener(_moveListener);
if (_sheetController.status != AnimationStatus.dismissed) {
_sheetController.reverse();
}
}
void _flingStatusListener(AnimationStatus status) {
if (status != AnimationStatus.completed) {
return;
}
_moveController.duration = _kMoveControllerDuration;
_moveController.removeStatusListener(_flingStatusListener);
if (_moveAnimation.value.dy == 0.0) {
return;
}
widget.onDismiss(context, _lastScale, _sheetOpacityAnimation.value);
void _flingStatusListener(AnimationStatus status) {
if (status != AnimationStatus.completed) {
return;
}
_moveController.duration = _kMoveControllerDuration;
_moveController.removeStatusListener(_flingStatusListener);
if (_moveAnimation.value.dy == 0.0) {
return;
}
widget.onDismiss(context, _lastScale, _sheetOpacityAnimation.value);
Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
switch (contextMenuLocation) {
case _ContextMenuLocation.center:
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topRight;
case _ContextMenuLocation.right:
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topLeft;
default:
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topRight;
}
Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
switch (contextMenuLocation) {
case _ContextMenuLocation.center:
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topRight;
case _ContextMenuLocation.right:
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topLeft;
default:
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topRight;
}
// Allow horizontal and negative vertical movement, but damp it.
float endX = _kPadding * dragOffset.dx / _kDamping;
float endY = dragOffset.dy >= 0.0
? dragOffset.dy
: _kPadding * dragOffset.dy / _kDamping;
setState(() =>{
_dragOffset = dragOffset;
_moveAnimation = new OffsetTween(
begin: Offset.zero,
end: new Offset(
endX.clamp(-_kPadding, _kPadding) ,
endY
)
).animate(
new CurvedAnimation(
parent: _moveController,
curve: Curves.elasticIn
)
float endX = _kPadding * dragOffset.dx / _kDamping;
float endY = dragOffset.dy >= 0.0
? dragOffset.dy
: _kPadding * dragOffset.dy / _kDamping;
setState(() =>{
_dragOffset = dragOffset;
_moveAnimation = new OffsetTween(
begin: Offset.zero,
end: new Offset(
endX.clamp(-_kPadding, _kPadding) ,
endY
)).animate(
new CurvedAnimation(
parent: _moveController,
curve: Curves.elasticIn
)
if (_lastScale <= _kSheetScaleThreshold
&& _sheetController.status != AnimationStatus.forward
&& _sheetScaleAnimation.value != 0.0f) {
_sheetController.forward();
} else if (_lastScale > _kSheetScaleThreshold
&& _sheetController.status != AnimationStatus.reverse
&& _sheetScaleAnimation.value != 1.0f) {
_sheetController.reverse();
}
});
if (_lastScale <= _kSheetScaleThreshold && _sheetController.status != AnimationStatus.forward
&& _sheetScaleAnimation.value != 0.0f) {
_sheetController.forward();
} else if (_lastScale > _kSheetScaleThreshold && _sheetController.status != AnimationStatus.reverse
&& _sheetScaleAnimation.value != 1.0f) {
_sheetController.reverse();
}
});
List<Widget> _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
Expanded child = new Expanded(
child: new Align(
alignment: _getChildAlignment(
widget.orientation,
widget.contextMenuLocation
),
child: new AnimatedBuilder(
animation: _moveController,
builder: _buildChildAnimation,
child: widget.child
)
)
);
Container spacer = new Container(
width: _kPadding,
height: _kPadding
);
Expanded sheet = new Expanded(
child: new AnimatedBuilder(
animation: _sheetController,
builder: _buildSheetAnimation,
child: new _ContextMenuSheet(
key: widget.sheetGlobalKey,
actions: widget.actions,
contextMenuLocation: widget.contextMenuLocation,
orientation: widget.orientation
)
)
);
List<Widget> centerWidgets = new List<Widget>();
centerWidgets.Add(child);
centerWidgets.Add(spacer);
centerWidgets.Add(sheet);
List<Widget> rightWidgets = new List<Widget>();
rightWidgets.Add(sheet);
rightWidgets.Add(spacer);
rightWidgets.Add(child);
List<Widget> _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
Expanded child = new Expanded(
child: new Align(
alignment: _getChildAlignment(
widget.orientation,
widget.contextMenuLocation
),
child: new AnimatedBuilder(
animation: _moveController,
builder: _buildChildAnimation,
child: widget.child
)
)
);
Container spacer = new Container(
width: _kPadding,
height: _kPadding
);
Expanded sheet = new Expanded(
child: new AnimatedBuilder(
animation: _sheetController,
builder: _buildSheetAnimation,
child: new _ContextMenuSheet(
key: widget.sheetGlobalKey,
actions: widget.actions,
contextMenuLocation: widget.contextMenuLocation,
orientation: widget.orientation
)
)
);
List<Widget> centerWidgets = new List<Widget>();
centerWidgets.Add(child);
centerWidgets.Add(spacer);
centerWidgets.Add(sheet);
List<Widget> rightWidgets = new List<Widget>();
rightWidgets.Add(sheet);
rightWidgets.Add(spacer);
rightWidgets.Add(child);
switch (contextMenuLocation) {
case _ContextMenuLocation.center:
return new List<Widget>{child, spacer, sheet};

vsync: this
);
_sheetController = new AnimationController(
duration: new TimeSpan(0,0,0,100),
//reverseDuration: new TimeSpan(0,0,0,300),/// TBC ???
duration: TimeSpan.FromMilliseconds(100),
reverseDuration: TimeSpan.FromMilliseconds(300),/// TBC ???
vsync: this
);
_sheetScaleAnimation = new FloatTween(

T offValue = default,
float? intervalOn = null,
float? intervalOff = null
) /*: super(
first: new Tween<T>(begin: offValue, end: onValue).animate(
new CurvedAnimation(
parent: controller,
curve: new Interval(intervalOn, intervalOn)
)
),
next: new Tween<T>(begin: onValue, end: offValue).animate(
new CurvedAnimation(
parent: controller,
curve: new Interval(intervalOff, intervalOff)
)
)
)*////?????
) : base(
first: new Tween<T>(begin: offValue, end: onValue).animate(
new CurvedAnimation(
parent: controller,
curve: new Interval(intervalOn == null ? 0.0f : (float)intervalOn, intervalOn == null ? 0.0f : (float)intervalOn)
)
),
next: new Tween<T>(begin: onValue, end: offValue).animate(
new CurvedAnimation(
parent: controller,
curve: new Interval(intervalOff == null ? 0.0f : (float)intervalOff, intervalOff == null ? 0.0f : (float)intervalOff)
)
)
)
{
D.assert(intervalOn != null && intervalOn >= 0.0 && intervalOn <= 1.0);
D.assert(intervalOff !=null && intervalOff >= 0.0 && intervalOff <= 1.0);

public override T value {
get {
return next.value; // == _offValue ? next.value : first.value; ????/
return next.value.Equals( _offValue) ? next.value : first.value;
}
}

995
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
文件差异内容过多而无法显示
查看文件

6
com.unity.uiwidgets/Runtime/cupertino/localization.cs


public abstract string postMeridiemAbbreviation { get; }
public abstract string todayLabel { get; }
public abstract string alertDialogLabel { get; }
public abstract string timerPickerHour(int hour);

public override string postMeridiemAbbreviation {
get { return "PM"; }
}
public override string todayLabel {
get { return "Today"; }
}
public override string alertDialogLabel {

317
com.unity.uiwidgets/Runtime/cupertino/picker.cs


public const float _kDefaultDiameterRatio = 1.35f;
public const float _kDefaultPerspective = 0.004f;
public const float _kForegroundScreenOpacityFraction = 0.7f;
public const float _kOverAndUnderCenterOpacity = 0.447f;
float itemExtent,
ValueChanged<int> onSelectedItemChanged,
List<Widget> children = null,
float diameterRatio = CupertinoPickerUtils._kDefaultDiameterRatio,
float? diameterRatio = null,
bool looping = false,
ListWheelChildDelegate childDelegate = null
float? squeeze = null,
float? itemExtent = null,
ValueChanged<int> onSelectedItemChanged = null,
List<Widget> children = null,
bool looping = false
D.assert(children != null || childDelegate != null);
D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage);
diameterRatio = diameterRatio == null ? CupertinoPickerUtils._kDefaultDiameterRatio : diameterRatio;
squeeze = squeeze == null ? CupertinoDatePickerUtils._kSqueeze : squeeze;
D.assert(children != null);
D.assert(diameterRatio > 0.0f, ()=>RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(itemExtent != null);
this.childDelegate = childDelegate ?? (looping
? (ListWheelChildDelegate) new ListWheelChildLoopingListDelegate(
children: children)
: (ListWheelChildDelegate) new ListWheelChildListDelegate(children: children));
this.itemExtent = itemExtent;
this.onSelectedItemChanged = onSelectedItemChanged;
D.assert(squeeze > 0);
this.backgroundColor = backgroundColor ?? CupertinoPickerUtils._kDefaultBackground;
this.backgroundColor = backgroundColor;
this.squeeze = squeeze;
this.itemExtent = itemExtent;
this.onSelectedItemChanged = onSelectedItemChanged;
childDelegate = looping
? (ListWheelChildDelegate) new ListWheelChildLoopingListDelegate(children: children)
: new ListWheelChildListDelegate(children: children);
float itemExtent,
ValueChanged<int> onSelectedItemChanged,
IndexedWidgetBuilder itemBuilder,
float diameterRatio = CupertinoPickerUtils._kDefaultDiameterRatio,
float? diameterRatio = null,
float? squeeze = null,
float? itemExtent = null,
ValueChanged<int> onSelectedItemChanged = null,
IndexedWidgetBuilder itemBuilder = null,
diameterRatio = diameterRatio == null ? CupertinoPickerUtils._kDefaultDiameterRatio : diameterRatio;
squeeze = squeeze == null ? CupertinoDatePickerUtils._kSqueeze : squeeze;
D.assert(diameterRatio > 0.0f, () => RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(diameterRatio > 0.0f,()=> RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(itemExtent != null);
return new CupertinoPicker(
itemExtent: itemExtent,
onSelectedItemChanged: onSelectedItemChanged,
key: key,
diameterRatio: diameterRatio,
backgroundColor: backgroundColor,
offAxisFraction: offAxisFraction,
useMagnifier: useMagnifier,
magnification: magnification,
scrollController: scrollController,
childDelegate: new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount)
);
D.assert(squeeze > 0);
CupertinoPicker picker = new CupertinoPicker(
key,
diameterRatio ,
backgroundColor,
offAxisFraction ,
useMagnifier ,
magnification ,
scrollController,
squeeze ,
itemExtent,
onSelectedItemChanged);
picker.childDelegate = new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount);
return picker;
public readonly float diameterRatio;
public readonly float? diameterRatio;
public readonly float itemExtent;
public readonly float? itemExtent;
public readonly ListWheelChildDelegate childDelegate;
public ListWheelChildDelegate childDelegate;
public readonly float? squeeze;
public override State createState() {
return new _CupertinoPickerState();

class _CupertinoPickerState : State<CupertinoPicker> {
FixedExtentScrollController _controller;
int _lastHapticIndex;
public override void initState() {
base.initState();
if (widget.scrollController == null) {

}
void _handleSelectedItemChanged(int index) {
//bool hasSuitableHapticHardware;
/*switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
hasSuitableHapticHardware = true;
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
hasSuitableHapticHardware = false;
break;
}*/
/*D.assert(hasSuitableHapticHardware != null);
if (hasSuitableHapticHardware && index != _lastHapticIndex) {
_lastHapticIndex = index;
HapticFeedback.selectionClick();
}*/
Widget _buildGradientScreen() {
if (widget.backgroundColor != null && widget.backgroundColor.alpha < 255) {
return new Container();
}
Widget _buildMagnifierScreen() {
Color resolvedBorderColor = CupertinoDynamicColor.resolve(CupertinoPickerUtils._kHighlighterBorder, context);
Color widgetBackgroundColor = widget.backgroundColor ?? new Color(0xFFFFFFFF);
return Positioned.fill(
child: new IgnorePointer(
return new IgnorePointer(
child: new Center(
gradient: new LinearGradient(
colors: new List<Color> {
widgetBackgroundColor,
widgetBackgroundColor.withAlpha(0xF2),
widgetBackgroundColor.withAlpha(0xDD),
widgetBackgroundColor.withAlpha(0),
widgetBackgroundColor.withAlpha(0),
widgetBackgroundColor.withAlpha(0xDD),
widgetBackgroundColor.withAlpha(0xF2),
widgetBackgroundColor,
},
stops: new List<float> {
0.0f, 0.05f, 0.09f, 0.22f, 0.78f, 0.91f, 0.95f, 1.0f
},
begin: Alignment.topCenter,
end: Alignment.bottomCenter
)
)
)
)
);
}
Widget _buildMagnifierScreen() {
Color foreground = widget.backgroundColor?.withAlpha(
(int) (widget.backgroundColor.alpha * CupertinoPickerUtils._kForegroundScreenOpacityFraction)
);
return new IgnorePointer(
child: new Column(
children: new List<Widget> {
new Expanded(
child: new Container(
color: foreground
border: new Border(
top: new BorderSide(width: 0.0f, color: resolvedBorderColor),
bottom: new BorderSide(width: 0.0f, color: resolvedBorderColor)
new Container(
decoration: new BoxDecoration(
border: new Border(
top: new BorderSide(width: 0.0f, color: CupertinoPickerUtils._kHighlighterBorder),
bottom: new BorderSide(width: 0.0f, color: CupertinoPickerUtils._kHighlighterBorder)
)
),
constraints: BoxConstraints.expand(
height: widget.itemExtent * widget.magnification
)
),
new Expanded(
child: new Container(
color: foreground
)
),
}
)
);
}
Widget _buildUnderMagnifierScreen() {
Color foreground = widget.backgroundColor?.withAlpha(
(int) (widget.backgroundColor.alpha * CupertinoPickerUtils._kForegroundScreenOpacityFraction)
);
return new Column(
children: new List<Widget> {
new Expanded(child: new Container()),
new Container(
color: foreground,
),
new Expanded(child: new Container())
}
)
)
public override Widget build(BuildContext context) {
Color resolvedBackgroundColor = CupertinoDynamicColor.resolve(widget.backgroundColor, context);
Widget _addBackgroundToChild(Widget child) {
return new DecoratedBox(
decoration: new BoxDecoration(
color: widget.backgroundColor
),
child: child
);
}
public override Widget build(BuildContext context) {
Widget result = new Stack(
children: new List<Widget> {
Positioned.fill(
Widget result = new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.pickerTextStyle,
child: new Stack(
children: new List<Widget>{
Positioned.fill(
child: new _CupertinoPickerSemantics(
scrollController: widget.scrollController ?? _controller,
physics: new FixedExtentScrollPhysics(),
diameterRatio: widget.diameterRatio,
physics: new FixedExtentScrollPhysics(),
diameterRatio: (float)widget.diameterRatio,
itemExtent: widget.itemExtent,
overAndUnderCenterOpacity: CupertinoPickerUtils._kOverAndUnderCenterOpacity,
itemExtent: (float)widget.itemExtent,
squeeze: (float)widget.squeeze,
)
),
_buildGradientScreen(),
_buildMagnifierScreen()
}
);
if (widget.backgroundColor != null && widget.backgroundColor.alpha < 255) {
result = new Stack(
children: new List<Widget> {
_buildUnderMagnifierScreen(), _addBackgroundToChild(result),
),
_buildMagnifierScreen(),
)
return new DecoratedBox(
decoration: new BoxDecoration(color: resolvedBackgroundColor),
child: result
);
}
}
public class _CupertinoPickerSemantics : SingleChildRenderObjectWidget {
public _CupertinoPickerSemantics(
Key key = null,
Widget child = null,
FixedExtentScrollController scrollController = null
) : base(key: key, child: child) {
this.scrollController = scrollController;
}
public readonly FixedExtentScrollController scrollController;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCupertinoPickerSemantics(scrollController, Directionality.of(context));
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (_RenderCupertinoPickerSemantics) renderObject;
((_RenderCupertinoPickerSemantics)renderObject).textDirection = Directionality.of(context);
((_RenderCupertinoPickerSemantics) renderObject).controller = scrollController;
}
}
public class _RenderCupertinoPickerSemantics : RenderProxyBox {
public _RenderCupertinoPickerSemantics(FixedExtentScrollController controller, TextDirection textDirection) {
this.controller = controller;
_textDirection = textDirection;
}
public FixedExtentScrollController controller {
get { return _controller; }
set {
if (value == _controller)
return;
if (_controller != null)
_controller.removeListener(_handleScrollUpdate);
else
_currentIndex = value.initialItem == 0 ? 0 : value.initialItem ;
value.addListener(_handleScrollUpdate);
_controller = value;
else {
result = _addBackgroundToChild(result);
}
FixedExtentScrollController _controller;
public TextDirection textDirection {
get { return _textDirection; }
set {
if (textDirection == value)
return;
_textDirection = value;
//markNeedsSemanticsUpdate();
}
TextDirection _textDirection;
return result;
int _currentIndex = 0;
void _handleIncrease() {
controller.jumpToItem(_currentIndex + 1);
}
void _handleDecrease() {
if (_currentIndex == 0)
return;
controller.jumpToItem(_currentIndex - 1);
void _handleScrollUpdate() {
if (controller.selectedItem == _currentIndex)
return;
_currentIndex = controller.selectedItem;
//markNeedsSemanticsUpdate();
}
}

25
com.unity.uiwidgets/Runtime/cupertino/text_theme.cs


TextStyle pickerTextStyle = null,
TextStyle dateTimePickerTextStyle = null
) {
D.assert((_navActionTextStyle != null && _actionTextStyle != null) || _primaryColor != null);
_defaults = defaults ?? new _TextThemeDefaultsBuilder(CupertinoColors.label, CupertinoColors.inactiveGray);
_primaryColor = primaryColor ?? CupertinoColors.systemBlue;
_textStyle = textStyle;
_actionTextStyle = actionTextStyle;

_navActionTextStyle = navActionTextStyle;
_pickerTextStyle = pickerTextStyle;
_dateTimePickerTextStyle = dateTimePickerTextStyle;
_defaults = defaults ??
//new _TextThemeDefaultsBuilder(Color.white,Color.white);
new _TextThemeDefaultsBuilder(CupertinoColors.label, CupertinoColors.inactiveGray);
D.assert((_navActionTextStyle != null && _actionTextStyle != null) || _primaryColor != null);
}
/*public static CupertinoTextThemeData _raw(
_TextThemeDefaultsBuilder _defaults,

public new CupertinoTextThemeData copyWith(
Color primaryColor,
TextStyle textStyle,
TextStyle actionTextStyle,
TextStyle tabLabelTextStyle,
TextStyle navTitleTextStyle,
TextStyle navLargeTitleTextStyle,
TextStyle navActionTextStyle,
TextStyle pickerTextStyle,
TextStyle dateTimePickerTextStyle
Color primaryColor = null,
TextStyle textStyle = null,
TextStyle actionTextStyle = null,
TextStyle tabLabelTextStyle = null,
TextStyle navTitleTextStyle = null,
TextStyle navLargeTitleTextStyle = null,
TextStyle navActionTextStyle = null,
TextStyle pickerTextStyle = null,
TextStyle dateTimePickerTextStyle = null
) {
return new CupertinoTextThemeData(
_defaults,

5
com.unity.uiwidgets/Runtime/painting/edge_insets.cs


}
float horizontal {
public float horizontal {
get { return _left + _right + _start + _end; }
}

public static EdgeInsetsDirectional only() {
return new EdgeInsetsDirectional(0f, 0f, 0f, 0f);
}
public static EdgeInsetsDirectional only( float start = 0.0f, float top = 0.0f,float end = 0.0f,float bottom = 0.0f) {
return new EdgeInsetsDirectional(start,top,end,bottom);
}
static EdgeInsetsDirectional zero = only();

2
com.unity.uiwidgets/Runtime/painting/text_painter.cs


_textHeightBehavior = textHeightBehavior;
}
void markNeedsLayout() {
public void markNeedsLayout() {
_paragraph = null;
_needsLayout = true;
_previousCaretPosition = null;

正在加载...
取消
保存