浏览代码

fix cupertino

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
7dd1e6b4
共有 7 个文件被更改,包括 345 次插入193 次删除
  1. 53
      com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
  2. 18
      com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs
  3. 23
      com.unity.uiwidgets/Runtime/cupertino/picker.cs
  4. 109
      com.unity.uiwidgets/Runtime/cupertino/route.cs
  5. 313
      com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs
  6. 12
      com.unity.uiwidgets/Runtime/gestures/drag_details.cs
  7. 10
      com.unity.uiwidgets/Runtime/widgets/scrollbar.cs

53
com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs


class _NavigationBarComponentsTransition {
public _NavigationBarComponentsTransition(
Animation<float> animation,
_TransitionableNavigationBar bottomNavBar,
_TransitionableNavigationBar topNavBar,
TextDirection directionality
Animation<float> animation = null,
_TransitionableNavigationBar bottomNavBar = null,
_TransitionableNavigationBar topNavBar = null,
TextDirection? directionality = null
) {
this.animation = animation;
bottomComponents = bottomNavBar.componentsKeys;

GlobalKey key = null,
RenderBox from = null
) {
//RenderBox componentBox = (RenderBox) key.currentContext.findRenderObject();
return RelativeRect.fromRect(
componentBox.localToGlobal(Offset.zero, ancestor: from) & componentBox.size, transitionBox
);

RenderBox toNavBarBox = null
) {
RelativeRect fromRect = positionInTransitionBox(fromKey, from: fromNavBarBox);
//RenderBox fromBox = (RenderBox) fromKey.currentContext.findRenderObject();
//RenderBox toBox = (RenderBox) toKey.currentContext.findRenderObject();
Rect toRect =
toBox.localToGlobal(
Offset.zero,

-fromBox.size.height / 2 + toBox.size.height / 2
- fromBox.size.height / 2 + toBox.size.height / 2
) & fromBox.size; // Keep the from render object"s size.
if (forwardDirection < 0) {

}
public Widget bottomLeading {
get {
//KeyedSubtree bottomLeading = (KeyedSubtree) bottomComponents.leadingKey.currentWidget;
get {
KeyedSubtree bottomLeading = bottomComponents.leadingKey.currentWidget as KeyedSubtree;
if (bottomLeading == null) {
return null;

public Widget bottomBackChevron {
get {
//KeyedSubtree bottomBackChevron = (KeyedSubtree) bottomComponents.backChevronKey.currentWidget;
rect: positionInTransitionBox(bottomComponents.backChevronKey,
from: bottomNavBarBox),
rect: positionInTransitionBox(bottomComponents.backChevronKey, from: bottomNavBarBox),
child: new FadeTransition(
opacity: fadeOutBy(0.6f),
child: new DefaultTextStyle(

public Widget bottomBackLabel {
get {
//KeyedSubtree bottomBackLabel = (KeyedSubtree) bottomComponents.backLabelKey.currentWidget;
KeyedSubtree bottomBackLabel = bottomComponents.backLabelKey.currentWidget as KeyedSubtree;
if (bottomBackLabel == null) {

public Widget bottomMiddle {
get {
//KeyedSubtree bottomMiddle = (KeyedSubtree) bottomComponents.middleKey.currentWidget;
//KeyedSubtree topBackLabel = (KeyedSubtree) topComponents.backLabelKey.currentWidget;
//KeyedSubtree topLeading = (KeyedSubtree) topComponents.leadingKey.currentWidget;
KeyedSubtree bottomMiddle = bottomComponents.middleKey.currentWidget as KeyedSubtree;
KeyedSubtree topBackLabel = topComponents.backLabelKey.currentWidget as KeyedSubtree;
KeyedSubtree topLeading = topComponents.leadingKey.currentWidget as KeyedSubtree;

child: new FadeTransition(
opacity: fadeOutBy(bottomHasUserMiddle == true ? 0.4f : 0.7f),
child: new Align(
alignment: Alignment.centerLeft,
alignment: AlignmentDirectional.centerStart,
child: new DefaultTextStyleTransition(
style: animation.drive(new TextStyleTween(
begin: bottomTitleTextStyle,

child: new FadeTransition(
opacity: fadeOutBy(0.6f),
child: new Align(
alignment: Alignment.centerLeft,
alignment: AlignmentDirectional.centerStart,
child: new DefaultTextStyleTransition(
style: animation.drive(new TextStyleTween(
begin: bottomLargeTitleTextStyle,

}
if (bottomLargeTitle != null && topLeading != null) {
RelativeRect from = positionInTransitionBox(bottomComponents.largeTitleKey,
from: bottomNavBarBox);
RelativeRect from = positionInTransitionBox(bottomComponents.largeTitleKey, from: bottomNavBarBox);
RelativeRectTween positionTween = new RelativeRectTween(
begin: from,
end: from.shift(

return null;
}
RelativeRect to =
positionInTransitionBox(topComponents.backChevronKey, from: topNavBarBox);
RelativeRect to = positionInTransitionBox(topComponents.backChevronKey, from: topNavBarBox);
RelativeRect from = to;
if (bottomBackChevron == null) {

RenderAnimatedOpacity topBackLabelOpacity =
(RenderAnimatedOpacity) topComponents.backLabelKey.currentContext?.findAncestorRenderObjectOfType<RenderAnimatedOpacity>();
/*ancestorRenderObjectOfType(
new TypeMatcher<RenderAnimatedOpacity>()
);*/
Animation<float> midClickOpacity = null;
if (topBackLabelOpacity != null && topBackLabelOpacity.opacity.value < 1.0f) {
midClickOpacity = animation.drive(new FloatTween(

return null;
}
RelativeRect to =
positionInTransitionBox(topComponents.largeTitleKey, from: topNavBarBox);
RelativeRect to = positionInTransitionBox(topComponents.largeTitleKey, from: topNavBarBox);
RelativeRectTween positionTween = new RelativeRectTween(
begin: to.shift(

18
com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs


public class CupertinoPageScaffold : StatefulWidget {
/// Creates a layout for pages with a navigation bar at the top.
public CupertinoPageScaffold(
Widget child,
bool resizeToAvoidBottomInset = true
bool resizeToAvoidBottomInset = true,
Widget child = null
) : base(key: key) {
D.assert(child != null);
this.child = child;

public readonly ScrollController _primaryScrollController = new ScrollController();
void _handleStatusBarTap() {
// Only act on the scroll controller if it has any attached scroll positions.
duration: new TimeSpan(0, 0, 0, 0, 500),
duration: TimeSpan.FromMilliseconds(500),
curve: Curves.linearToEaseOut
);
}

//List<Widget> stacked = new List<Widget>();
Widget paddedContent = widget.child;
MediaQueryData existingMediaQuery = MediaQuery.of(context);

: existingMediaQuery.viewInsets;
bool fullObstruction = widget.navigationBar.shouldFullyObstruct(context);
/*widget.navigationBar.fullObstruction == false
? CupertinoTheme.of(context).barBackgroundColor.alpha == 0xFF
: widget.navigationBar.fullObstruction;*/
if (fullObstruction == true) {
paddedContent = new MediaQuery(
data: existingMediaQuery

right: 0.0f,
height: existingMediaQuery.padding.top,
child: new GestureDetector(
//excludeFromSemantics: true,
onTap: _handleStatusBarTap
)

}
public abstract class ObstructingPreferredSizeWidget : PreferredSizeWidget {
protected ObstructingPreferredSizeWidget(Key key = null) : base(key: key) {}
// public virtual bool? fullObstruction { get; }
protected ObstructingPreferredSizeWidget(Key key = null) : base(key: key) {}
public abstract bool shouldFullyObstruct(BuildContext context);
}
}

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


namespace Unity.UIWidgets.cupertino {
static class CupertinoPickerUtils {
public static Color _kHighlighterBorder = new Color(0xFF7F7F7F);
public static Color _kHighlighterBorder = CupertinoDynamicColor.withBrightness(
color: new Color(0x33000000),
darkColor: new Color(0x33FFFFFF)
);
public const float _kDefaultDiameterRatio = 1.07f;
public const float _kDefaultPerspective = 0.003f;
public const float _kSqueeze = 1.45f;
public const float _kOverAndUnderCenterOpacity = 0.447f;
public const float _kDefaultDiameterRatio = 1.35f;
public const float _kDefaultPerspective = 0.004f;
public const float _kOverAndUnderCenterOpacity = 0.447f;
}
public class CupertinoPicker : StatefulWidget {

bool looping = false
) : base(key: key) {
diameterRatio = diameterRatio == null ? CupertinoPickerUtils._kDefaultDiameterRatio : diameterRatio;
squeeze = squeeze == null ? CupertinoDatePickerUtils._kSqueeze : squeeze;
squeeze = squeeze == null ? CupertinoPickerUtils._kSqueeze : squeeze;
D.assert(children != null);
D.assert(diameterRatio > 0.0f, ()=>RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(magnification > 0);

childDelegate = looping
? (ListWheelChildDelegate) new ListWheelChildLoopingListDelegate(children: children)
: new ListWheelChildListDelegate(children: children);
}
public static CupertinoPicker builder(

int? childCount = null
) {
diameterRatio = diameterRatio == null ? CupertinoPickerUtils._kDefaultDiameterRatio : diameterRatio;
squeeze = squeeze == null ? CupertinoDatePickerUtils._kSqueeze : squeeze;
squeeze = squeeze == null ? CupertinoPickerUtils._kSqueeze : squeeze;
D.assert(itemBuilder != null);
D.assert(diameterRatio > 0.0f,()=> RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(magnification > 0);

public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (_RenderCupertinoPickerSemantics) renderObject;
((_RenderCupertinoPickerSemantics)renderObject).textDirection = Directionality.of(context);
((_RenderCupertinoPickerSemantics) renderObject).controller = scrollController;
((_RenderCupertinoPickerSemantics)renderObject).controller = scrollController;
}
}
public class _RenderCupertinoPickerSemantics : RenderProxyBox {

_currentIndex = controller.selectedItem;
//markNeedsSemanticsUpdate();
}
}

109
com.unity.uiwidgets/Runtime/cupertino/route.cs


public const int _kMaxPageBackAnimationTime = 300; // Milliseconds.
public static readonly Color _kModalBarrierColor = new Color(0x6604040F);
public static readonly Color _kModalBarrierColor = CupertinoDynamicColor.withBrightness(
color: new Color(0x33000000),
darkColor: new Color(0x7A000000)
);
public static readonly TimeSpan _kModalPopupTransitionDuration = new TimeSpan(0, 0, 0, 0, 335);
public static readonly TimeSpan _kModalPopupTransitionDuration = TimeSpan.FromMilliseconds(335);
public static readonly Animatable<Offset> _kRightMiddleTween = new OffsetTween(
begin: new Offset(1.0f, 0.0f),

);
/*public static Future showCupertinoModalPopup(
BuildContext context,
WidgetBuilder builder
) {
return Navigator.of(context, rootNavigator: true).push(
new _CupertinoModalPopupRoute(
builder: builder,
barrierLabel: "Dismiss"
)
);
}*/
public static Future showCupertinoModalPopup(
BuildContext context = null,
WidgetBuilder builder = null,

) {
D.assert(useRootNavigator != null);
filter: filter,
semanticsDismissible: semanticsDismissible
)
filter: filter
)
);
}

public static Widget _buildCupertinoDialogTransitions(BuildContext context, Animation<float> animation,
Animation<float>
secondaryAnimation, Widget child) {
public static Widget _buildCupertinoDialogTransitions(
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child) {
CurvedAnimation fadeAnimation = new CurvedAnimation(
parent: animation,
curve: Curves.easeInOut

RouteSettings routeSettings = null
) {
D.assert(builder != null);
D.assert(useRootNavigator != null);
// This transition duration was eyeballed comparing with iOS
transitionDuration: new TimeSpan(0, 0, 0, 0, 250),
transitionDuration: TimeSpan.FromMilliseconds(250),
pageBuilder: (BuildContext context1, Animation<float> animation, Animation<float> secondaryAnimation)=> {
return builder(context1);
},

);
/*return _DialogRoute.showGeneralDialog(
context: context,
barrierDismissible: false,
barrierColor: _kModalBarrierColor,
transitionDuration: new TimeSpan(0, 0, 0, 0, 250),
pageBuilder:
(BuildContext _context, Animation<float> animation, Animation<float> secondaryAnimation) => {
return builder(_context);
},
transitionBuilder: _buildCupertinoDialogTransitions
);*/
}
}

return !Equals(left, right);
}
public int hashCode {
get { return edgeGradient.GetHashCode(); }
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<LinearGradient>("edgeGradient", edgeGradient));

if (gradient == null) {
return;
}
float deltaX = -configuration.size.width;
TextDirection textDirection = configuration.textDirection;
D.assert(textDirection != null);
float deltaX = 0.0f;
switch (textDirection) {
case TextDirection.rtl:
deltaX = configuration.size.width;
break;
case TextDirection.ltr:
deltaX = -configuration.size.width;
break;
}
Paint paint = new Paint();
paint.shader = gradient.createShader(rect);
Paint paint = new Paint() {
shader = gradient.createShader(rect, textDirection: textDirection)
};
canvas.drawRect(rect, paint);
}
}

public readonly Widget child;
public override Widget build(BuildContext context) {
/*return new SlideTransition(
position: _positionAnimation,
child: child
);*/
D.assert(WidgetsD.debugCheckHasDirectionality(context));
TextDirection textDirection = Directionality.of(context);
return new SlideTransition(

class _CupertinoBackGestureDetector : StatefulWidget {
public _CupertinoBackGestureDetector(
Widget child,
ValueGetter<bool> enabledCallback,
ValueGetter<_CupertinoBackGestureController> onStartPopGesture,
Key key = null
Key key = null,
ValueGetter<bool> enabledCallback = null,
ValueGetter<_CupertinoBackGestureController> onStartPopGesture = null,
Widget child = null
) : base(key: key) {
D.assert(enabledCallback != null);
D.assert(onStartPopGesture != null);

else {
animateForward = controller.value > 0.5;
}
/* animateForward = velocity > 0 ? false : true;
}
else {
animateForward = controller.value > 0.5 ? true : false;
}*/
if (animateForward) {
int droppedPageForwardAnimationTime = Mathf.Min(
MathUtils.lerpFloat(CupertinoRouteUtils._kMaxDroppedSwipePageForwardAnimationTime, 0f,

controller.animateTo(1.0f, duration: new TimeSpan(0, 0, 0, 0, droppedPageForwardAnimationTime),
controller.animateTo(1.0f, duration: TimeSpan.FromMilliseconds(droppedPageForwardAnimationTime),
curve: animationCurve);
}
else {

int droppedPageBackAnimationTime =
MathUtils.lerpFloat(0f, CupertinoRouteUtils._kMaxDroppedSwipePageForwardAnimationTime,
controller.value).floor();
controller.animateBack(0.0f, duration: new TimeSpan(0, 0, 0, 0, droppedPageBackAnimationTime),
controller.animateBack(0.0f, duration: TimeSpan.FromMilliseconds(droppedPageBackAnimationTime),
curve: animationCurve);
}
}

Color barrierColor = null,
string barrierLabel = null,
WidgetBuilder builder = null,
bool? semanticsDismissible = null,
ImageFilter filter = null,
RouteSettings settings = null
) : base(filter:filter,settings: settings) {

_semanticsDismissible = semanticsDismissible;
}
public readonly WidgetBuilder builder;

public bool? _semanticsDismissible;
public new Color barrierColor;
/*{
get { return CupertinoRouteUtils._kModalBarrierColor; }
}*/
public readonly Color barrierColor;
}
public bool semanticsDismissible {
get { return _semanticsDismissible ?? false; }
}
public override TimeSpan transitionDuration {

}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) {
//return builder(context);
public override Widget buildPage(BuildContext context, Animation<float> animation, Animation<float> secondaryAnimation) {
return new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevatedlayer,
child: new Builder(builder: builder)

313
com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
public static readonly Color _kScrollbarColor = new Color(0x99777777);
public const float _kScrollbarThickness = 2.5f;
public const float _kScrollbarMainAxisMargin = 4.0f;
public const float _kScrollbarCrossAxisMargin = 2.5f;
public static readonly Radius _kScrollbarRadius = Radius.circular(1.25f);
public static readonly TimeSpan _kScrollbarTimeToFade = new TimeSpan(0, 0, 0, 0, 50);
public static readonly TimeSpan _kScrollbarFadeDuration = new TimeSpan(0, 0, 0, 0, 250);
public static readonly TimeSpan _kScrollbarTimeToFade = TimeSpan.FromMilliseconds(50);
public static readonly TimeSpan _kScrollbarFadeDuration = TimeSpan.FromMilliseconds(250);
public static readonly TimeSpan _kScrollbarResizeDuration = TimeSpan.FromMilliseconds(100);
public static readonly Color _kScrollbarColor = CupertinoDynamicColor.withBrightness(
color: new Color(0x59000000),
darkColor: new Color(0x80FFFFFF)
);
public const float _kScrollbarThickness = 3f;
public const float _kScrollbarThicknessDragging = 8.0f;
public static Radius _kScrollbarRadius = Radius.circular(1.5f);
public static Radius _kScrollbarRadiusDragging = Radius.circular(4.0f);
public const float _kScrollbarMainAxisMargin = 3.0f;
public const float _kScrollbarCrossAxisMargin = 3.0f;
public static bool _hitTestInteractive(GlobalKey customPaintKey, Offset offset) {
if (customPaintKey.currentContext == null) {
return false;
}
CustomPaint customPaint = customPaintKey.currentContext.widget as CustomPaint;
ScrollbarPainter painter = customPaint.foregroundPainter as ScrollbarPainter;
RenderBox renderBox = customPaintKey.currentContext.findRenderObject() as RenderBox;
Offset localOffset = renderBox.globalToLocal(offset);
return painter.hitTestInteractive(localOffset);
}
Widget child,
Key key = null
Key key = null,
ScrollController controller = null,
bool isAlwaysShown = false,
Widget child = null
this.controller = controller;
this.isAlwaysShown = isAlwaysShown;
}
public readonly Widget child;

}
class _CupertinoScrollbarState : TickerProviderStateMixin<CupertinoScrollbar> {
GlobalKey _customPaintKey = GlobalKey.key();
ScrollbarPainter _painter;
TextDirection _textDirection;

AnimationController _thicknessAnimationController;
Drag _drag;
float _thickness {
get {
return CupertinoScrollbarUtils._kScrollbarThickness + _thicknessAnimationController.value * (CupertinoScrollbarUtils._kScrollbarThicknessDragging - CupertinoScrollbarUtils._kScrollbarThickness);
}
}
Radius _radius {
get {
return Radius.lerp(CupertinoScrollbarUtils._kScrollbarRadius, CupertinoScrollbarUtils._kScrollbarRadiusDragging, _thicknessAnimationController.value);
}
}
ScrollController _currentController;
ScrollController _controller {
get {
return widget.controller ?? PrimaryScrollController.of(context);
}
}
public override void initState() {
base.initState();

parent: _fadeoutAnimationController,
curve: Curves.fastOutSlowIn
);
_thicknessAnimationController = new AnimationController(
vsync: this,
duration: CupertinoScrollbarUtils._kScrollbarResizeDuration
);
_thicknessAnimationController.addListener(() => {
_painter.updateThickness(_thickness, _radius);
});
public override void didChangeDependencies() {
base.didChangeDependencies();
_textDirection = Directionality.of(context);
_painter = _buildCupertinoScrollbarPainter();
}
ScrollbarPainter _buildCupertinoScrollbarPainter() {
public ScrollbarPainter _buildCupertinoScrollbarPainter(BuildContext context) {
color: CupertinoScrollbarUtils._kScrollbarColor,
textDirection: _textDirection,
thickness: CupertinoScrollbarUtils._kScrollbarThickness,
color: CupertinoDynamicColor.resolve(CupertinoScrollbarUtils._kScrollbarColor, context),
textDirection: Directionality.of(context),
thickness: _thickness,
radius: CupertinoScrollbarUtils._kScrollbarRadius,
radius: _radius,
padding: MediaQuery.of(context).padding,
void _dragScrollbar(float primaryDelta) {
D.assert(_currentController != null);
float scrollOffsetLocal = _painter.getTrackToScroll(primaryDelta);
float scrollOffsetGlobal = scrollOffsetLocal + _currentController.position.pixels;
if (_drag == null) {
_drag = _currentController.position.drag(
new DragStartDetails(
globalPosition: new Offset(0.0f, scrollOffsetGlobal)
),
() =>{}
);
} else {
_drag.update(
new DragUpdateDetails(
delta: new Offset(0.0f, -scrollOffsetLocal),
primaryDelta: (float?) -1f * scrollOffsetLocal,
globalPosition: new Offset(0.0f, scrollOffsetGlobal)
)
);
}
}
void _startFadeoutTimer() {
if (!widget.isAlwaysShown) {
_fadeoutTimer?.cancel();
_fadeoutTimer = Timer.create(CupertinoScrollbarUtils._kScrollbarTimeToFade, () => {
_fadeoutAnimationController.reverse();
_fadeoutTimer = null;
});
}
}
bool _checkVertical() {
return _currentController.position.axis() == Axis.vertical;
}
float _pressStartY = 0.0f;
void _handleLongPressStart(LongPressStartDetails details) {
_currentController = _controller;
if (!_checkVertical()) {
return;
}
_pressStartY = details.localPosition.dy;
_fadeoutTimer?.cancel();
_fadeoutAnimationController.forward();
_dragScrollbar(details.localPosition.dy);
_dragScrollbarPositionY = details.localPosition.dy;
}
void _handleLongPress() {
if (!_checkVertical()) {
return;
}
_fadeoutTimer?.cancel();
_thicknessAnimationController.forward().then(
(_) => { return; }
);
}
void _handleLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
if (!_checkVertical()) {
return;
}
_dragScrollbar(details.localPosition.dy - _dragScrollbarPositionY);
_dragScrollbarPositionY = details.localPosition.dy;
}
void _handleLongPressEnd(LongPressEndDetails details) {
if (!_checkVertical()) {
return;
}
_handleDragScrollEnd(details.velocity.pixelsPerSecond.dy);
/*if (details.velocity.pixelsPerSecond.dy.abs() < 10 &&
(details.localPosition.dy - _pressStartY).abs() > 0) {
//HapticFeedback.mediumImpact();
}*/
_currentController = null;
}
void _handleDragScrollEnd(float trackVelocityY) {
_startFadeoutTimer();
_thicknessAnimationController.reverse();
_dragScrollbarPositionY = 0.0f;
float scrollVelocityY = _painter.getTrackToScroll(trackVelocityY);
_drag?.end(new DragEndDetails(
primaryVelocity: -scrollVelocityY,
velocity: new Velocity(
pixelsPerSecond: new Offset(
0.0f,
-scrollVelocityY
)
)
));
_drag = null;
}
ScrollMetrics metrics = notification.metrics;
if (metrics.maxScrollExtent <= metrics.minScrollExtent) {
return false;
}
if (_fadeoutAnimationController.status != AnimationStatus.forward) {
_fadeoutAnimationController.forward();
}
// Any movements always makes the scrollbar start showing up.
if (_fadeoutAnimationController.status != AnimationStatus.forward) {
_fadeoutAnimationController.forward();
}
_fadeoutTimer?.cancel();
_painter.update(notification.metrics, notification.metrics.axisDirection);
_fadeoutTimer?.cancel();
_painter.update(notification.metrics, notification.metrics.axisDirection);
} else if (notification is ScrollEndNotification) {
// On iOS, the scrollbar can only go away once the user lifted the finger.
if (_dragScrollbarPositionY == null) {
_startFadeoutTimer();
}
else if (notification is ScrollEndNotification) {
if (_dragScrollbarPositionY.Equals(0f)) {
_startFadeoutTimer();
return false;
}
Dictionary<Type, GestureRecognizerFactory> _gestures {
get {
Dictionary<Type, GestureRecognizerFactory> gestures =
new Dictionary<Type, GestureRecognizerFactory>();
gestures[typeof(_ThumbPressGestureRecognizer)] =
new GestureRecognizerFactoryWithHandlers<_ThumbPressGestureRecognizer>(
() => new _ThumbPressGestureRecognizer(
debugOwner: this,
customPaintKey: _customPaintKey
),
(_ThumbPressGestureRecognizer instance)=> {
instance.onLongPressStart = _handleLongPressStart;
instance.onLongPress = _handleLongPress;
instance.onLongPressMoveUpdate = _handleLongPressMoveUpdate;
instance.onLongPressEnd = _handleLongPressEnd;
);
/*_fadeoutTimer?.cancel();
_fadeoutTimer = Window.instance.run(CupertinoScrollbarUtils._kScrollbarTimeToFade, () => {
_fadeoutAnimationController.reverse();
_fadeoutTimer = null;
});*/
return gestures;
}
return false;
ScrollbarPainter _buildCupertinoScrollbarPainter() {
return new ScrollbarPainter(
color: CupertinoScrollbarUtils._kScrollbarColor,
textDirection: _textDirection,
thickness: CupertinoScrollbarUtils._kScrollbarThickness,
fadeoutOpacityAnimation: _fadeoutOpacityAnimation,
mainAxisMargin: CupertinoScrollbarUtils._kScrollbarMainAxisMargin,
crossAxisMargin: CupertinoScrollbarUtils._kScrollbarCrossAxisMargin,
radius: CupertinoScrollbarUtils._kScrollbarRadius,
minLength: CupertinoScrollbarUtils._kScrollbarMinLength,
minOverscrollLength: CupertinoScrollbarUtils._kScrollbarMinOverscrollLength
);
_thicknessAnimationController.dispose();
void _startFadeoutTimer() {
if (!widget.isAlwaysShown) {
_fadeoutTimer?.cancel();
_fadeoutTimer = Timer.create(CupertinoScrollbarUtils._kScrollbarTimeToFade, () => {
_fadeoutAnimationController.reverse();
_fadeoutTimer = null;
});
}
}
child: new CustomPaint(
foregroundPainter: _painter,
child: new RepaintBoundary(
child: widget.child
child: new RawGestureDetector(
gestures: _gestures,
child: new CustomPaint(
key: _customPaintKey,
foregroundPainter: _painter,
child: new RepaintBoundary(child: widget.child)
)
)
)

public class _ThumbPressGestureRecognizer : LongPressGestureRecognizer {
public _ThumbPressGestureRecognizer(
float? postAcceptSlopTolerance = null,
PointerDeviceKind kind = default,
object debugOwner = null,
GlobalKey customPaintKey = null
) : base(
postAcceptSlopTolerance: postAcceptSlopTolerance,
kind: kind,
debugOwner: debugOwner,
duration: TimeSpan.FromMilliseconds(100)
) {
_customPaintKey = customPaintKey;
}
public readonly GlobalKey _customPaintKey;
protected override bool isPointerAllowed(PointerDownEvent _event) {
if (!CupertinoScrollbarUtils._hitTestInteractive(_customPaintKey, _event.position)) {
return false;
}
return base.isPointerAllowed(_event);
}
}
}

12
com.unity.uiwidgets/Runtime/gestures/drag_details.cs


public class DragStartDetails {
public DragStartDetails(
TimeSpan sourceTimeStamp,
TimeSpan? sourceTimeStamp = null,
Offset globalPosition = null,
Offset localPosition = null
) {

}
public readonly TimeSpan sourceTimeStamp;
public readonly TimeSpan? sourceTimeStamp;
public readonly Offset globalPosition;
public readonly Offset localPosition;

public class DragUpdateDetails {
public DragUpdateDetails(
TimeSpan sourceTimeStamp,
TimeSpan? sourceTimeStamp = null,
bool isScroll = false) {
bool isScroll = false
)
{
this.sourceTimeStamp = sourceTimeStamp;
this.delta = delta ?? Offset.zero;
this.primaryDelta = primaryDelta;

|| primaryDelta == this.delta.dy && this.delta.dx == 0.0);
}
public readonly TimeSpan sourceTimeStamp;
public readonly TimeSpan? sourceTimeStamp;
public readonly Offset delta;

10
com.unity.uiwidgets/Runtime/widgets/scrollbar.cs


notifyListeners();
}
void updateThickness(float nextThickness, Radius nextRadius) {
public void updateThickness(float nextThickness, Radius nextRadius) {
thickness = nextThickness;
radius = nextRadius;
notifyListeners();

+ _lastMetrics.viewportDimension;
}
}
float getTrackToScroll(float thumbOffsetLocal) {
public float getTrackToScroll(float thumbOffsetLocal) {
float scrollableExtent = _lastMetrics.maxScrollExtent - _lastMetrics.minScrollExtent;
float thumbMovableExtent = _trackExtent - _thumbExtent();

_paintThumbCrossAxis(canvas, size, thumbOffset, thumbExtent, _lastAxisDirection.Value);
}
bool hitTestInteractive(Offset position) {
public bool hitTestInteractive(Offset position) {
if (_thumbRect == null) {
return false;
}

正在加载...
取消
保存