浏览代码

fix dismissible bug

/siyaoH-1.17-PlatformMessage
xingwei.zhu 4 年前
当前提交
c8002cef
共有 3 个文件被更改,包括 156 次插入44 次删除
  1. 1
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs
  2. 87
      com.unity.uiwidgets/Runtime/widgets/dismissible.cs
  3. 112
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NavigatorPopSample.cs

1
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {

87
com.unity.uiwidgets/Runtime/widgets/dismissible.cs


}
_dragUnderway = false;
_confirmStartResizeAnimation().then_((value) => {
if (_moveController.isCompleted && value) {
_startResizeAnimation();
}
else {
float flingVelocity = _directionIsXAxis
? details.velocity.pixelsPerSecond.dx
: details.velocity.pixelsPerSecond.dy;
switch (_describeFlingGesture(details.velocity)) {
case _FlingGestureKind.forward:
D.assert(_dragExtent != 0.0f);
D.assert(!_moveController.isDismissed);
if ((widget.dismissThresholds.getOrDefault(_dismissDirection) ??
_kDismissThreshold) >= 1.0) {
_moveController.reverse();
break;
}
if (_moveController.isCompleted) {
_confirmStartResizeAnimation().then_((value) => {
if (value) {
_startResizeAnimation();
return;
}
});
}
_dragExtent = flingVelocity.sign();
_moveController.fling(velocity: flingVelocity.abs() * _kFlingVelocityScale);
break;
case _FlingGestureKind.reverse:
D.assert(_dragExtent != 0.0f);
D.assert(!_moveController.isDismissed);
_dragExtent = flingVelocity.sign();
_moveController.fling(velocity: -flingVelocity.abs() * _kFlingVelocityScale);
break;
case _FlingGestureKind.none:
if (!_moveController.isDismissed) {
// we already know it's not completed, we check that above
if (_moveController.value >
(widget.dismissThresholds.getOrDefault(_dismissDirection) ??
_kDismissThreshold)) {
_moveController.forward();
}
else {
_moveController.reverse();
}
}
float flingVelocity = _directionIsXAxis
? details.velocity.pixelsPerSecond.dx
: details.velocity.pixelsPerSecond.dy;
switch (_describeFlingGesture(details.velocity)) {
case _FlingGestureKind.forward:
D.assert(_dragExtent != 0.0f);
D.assert(!_moveController.isDismissed);
if ((widget.dismissThresholds.getOrDefault(_dismissDirection) ??
_kDismissThreshold) >= 1.0) {
_moveController.reverse();
break;
}
break;
_dragExtent = flingVelocity.sign();
_moveController.fling(velocity: flingVelocity.abs() * _kFlingVelocityScale);
break;
case _FlingGestureKind.reverse:
D.assert(_dragExtent != 0.0f);
D.assert(!_moveController.isDismissed);
_dragExtent = flingVelocity.sign();
_moveController.fling(velocity: -flingVelocity.abs() * _kFlingVelocityScale);
break;
case _FlingGestureKind.none:
if (!_moveController.isDismissed) {
// we already know it's not completed, we check that above
if (_moveController.value >
(widget.dismissThresholds.getOrDefault(_dismissDirection) ??
_kDismissThreshold)) {
_moveController.forward();
}
else {
_moveController.reverse();
}
}
});
break;
}
}
void _handleDismissStatusChanged(AnimationStatus status) {

D.assert(() => {
if (_resizeAnimation.status != AnimationStatus.forward) {
D.assert(_resizeAnimation.status == AnimationStatus.completed);
throw new UIWidgetsError(new List<DiagnosticsNode>{
throw new UIWidgetsError(new List<DiagnosticsNode> {
new ErrorSummary("A dismissed Dismissible widget is still part of the tree."),
new ErrorHint(
"Make sure to implement the onDismissed handler and to immediately remove the Dismissible " +

children.Add(content);
content = new Stack(children: children);
}
return new GestureDetector(

112
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/NavigatorPopSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample
{
public class NavigatorPopSample : UIWidgetsPanel
{
protected override void main()
{
ui_.runApp(new MaterialApp(
title: "Returning Data",
home: new PopDemo()));
}
protected new void OnEnable()
{
base.OnEnable();
}
}
public class PopDemo : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new Scaffold(
appBar: new AppBar(
title: new Text("Returning Data Demo")
),
body: new Center(child: new SelectionButton())
);
}
}
internal class SelectionButton : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new RaisedButton(
onPressed: () => { _navigateAndDisplaySelection(context); },
child: new Text("Pick an option, any option!")
);
}
// A method that launches the SelectionScreen and awaits the result from
// Navigator.pop!
private void _navigateAndDisplaySelection(BuildContext context)
{
// Navigator.push returns a Future that will complete after we call
// Navigator.pop on the Selection Screen!
Future<bool> result = Navigator.push<bool>(
context,
new MaterialPageRoute(builder: (subContext) => new SelectionScreen())
);
// After the Selection Screen returns a result, show it in a Snackbar!
result.then(value =>
{
bool res = (bool) value;
Scaffold
.of(context)
.showSnackBar(new SnackBar(content: new Text($"{res}")));
});
}
}
internal class SelectionScreen : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new Scaffold(
appBar: new AppBar(
title: new Text("Pick an option")
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget>
{
new Padding(
padding: EdgeInsets.all(8.0f),
child: new RaisedButton(
onPressed: () =>
{
// Close the screen and return "Yep!" as the result
Navigator.pop(context, true);
},
child: new Text("Yep!")
)
),
new Padding(
padding: EdgeInsets.all(8.0f),
child: new RaisedButton(
onPressed: () =>
{
// Close the screen and return "Nope!" as the result
Navigator.pop(context, false);
},
child: new Text("Nope.")
)
)
}
)
)
);
}
}
}
正在加载...
取消
保存