|
|
|
|
|
|
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 |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |