浏览代码

fix modal_barrier.cs

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
bf06efc1
共有 1 个文件被更改,包括 91 次插入7 次删除
  1. 98
      com.unity.uiwidgets/Runtime/widgets/modal_barrier.cs

98
com.unity.uiwidgets/Runtime/widgets/modal_barrier.cs


using Unity.UIWidgets.animation;
using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.widgets {
public class ModalBarrier : StatelessWidget {

}
public override Widget build(BuildContext context) {
return new GestureDetector(
onTapDown: details => {
return new _ModalBarrierGestureDetector(
onDismiss: () => {
behavior: HitTestBehavior.opaque,
child: new ConstrainedBox(
constraints: BoxConstraints.expand(),
child: color == null ? null : new DecoratedBox(decoration: new BoxDecoration(color))
child: new MouseRegion(
opaque: true,
child: new ConstrainedBox(
constraints: BoxConstraints.expand(),
child: color == null ? null : new DecoratedBox(
decoration: new BoxDecoration(
color: color
)
)
)
)
);
}

return new ModalBarrier(color: color?.value, dismissible: dismissible);
}
}
public class _AnyTapGestureRecognizer : BaseTapGestureRecognizer {
public _AnyTapGestureRecognizer( Object debugOwner = null) : base(debugOwner: debugOwner) {}
public VoidCallback onAnyTapUp;
protected override bool isPointerAllowed(PointerDownEvent _event) {
if (onAnyTapUp == null)
return false;
return base.isPointerAllowed(_event);
}
protected override void handleTapDown(PointerDownEvent down = null) {
// Do nothing.
}
protected override void handleTapUp(PointerDownEvent down = null, PointerUpEvent up = null) {
if (onAnyTapUp != null)
onAnyTapUp();
}
protected override void handleTapCancel(PointerDownEvent down = null, PointerCancelEvent cancel = null, string reason = null) {
// Do nothing.
}
public override string debugDescription {
get {
return "any tap";
}
}
}
public class _AnyTapGestureRecognizerFactory : GestureRecognizerFactory<_AnyTapGestureRecognizer> {
public _AnyTapGestureRecognizerFactory(VoidCallback onAnyTapUp = null) {
this.onAnyTapUp = onAnyTapUp;
}
public readonly VoidCallback onAnyTapUp;
public override _AnyTapGestureRecognizer constructor() => new _AnyTapGestureRecognizer();
public override void initializer(_AnyTapGestureRecognizer instance) {
instance.onAnyTapUp = onAnyTapUp;
}
}
public class _ModalBarrierGestureDetector : StatelessWidget {
public _ModalBarrierGestureDetector(
Key key = null,
Widget child = null,
VoidCallback onDismiss = null
) : base(key: key) {
D.assert(child != null);
D.assert(onDismiss != null);
}
public readonly Widget child;
public readonly VoidCallback onDismiss;
public override Widget build(BuildContext context) {
Dictionary<Type, GestureRecognizerFactory> gestures = new Dictionary<Type, GestureRecognizerFactory>(){
{typeof(_AnyTapGestureRecognizer), new _AnyTapGestureRecognizerFactory(onAnyTapUp: onDismiss)}
};
return new RawGestureDetector(
gestures: gestures,
behavior: HitTestBehavior.opaque,
child: child
);
}
}
}
正在加载...
取消
保存