Xingwei Zhu
3 年前
当前提交
3d6e2ebc
共有 4 个文件被更改,包括 108 次插入 和 3 次删除
-
10AwesomeUIWidgets/Assets/Scripts/RaycastableScene/ItemPickerMainUIPanel.cs
-
30AwesomeUIWidgets/Assets/Scripts/RaycastableScene/LeftUIPanel.cs
-
68AwesomeUIWidgets/Assets/Scripts/RaycastableScene/animate_button.cs
-
3AwesomeUIWidgets/Assets/Scripts/RaycastableScene/animate_button.cs.meta
|
|||
using System; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace UIWidgetsSample.RaycastableScene |
|||
{ |
|||
public class AnimateButton : StatefulWidget |
|||
{ |
|||
public AnimateButton(Key key = null, Widget child = null, bool selected = false) : base(key: key) |
|||
{ |
|||
this.child = child; |
|||
this.selected = selected; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
public readonly bool selected; |
|||
|
|||
public override State createState() |
|||
{ |
|||
return new AnimateButtonState(); |
|||
} |
|||
} |
|||
|
|||
public class AnimateButtonState : SingleTickerProviderStateMixin<AnimateButton> |
|||
{ |
|||
private AnimationController selectAnim; |
|||
private Animation<Color> _colorTween; |
|||
|
|||
public override void initState() |
|||
{ |
|||
selectAnim = new AnimationController(vsync: this, duration: new TimeSpan(0, 0, 0, 0, 200)); |
|||
_colorTween = new ColorTween(begin: Colors.white, Colors.green).animate(selectAnim); |
|||
base.initState(); |
|||
} |
|||
|
|||
public override void dispose() |
|||
{ |
|||
base.dispose(); |
|||
selectAnim.dispose(); |
|||
} |
|||
|
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
if (widget.selected) |
|||
{ |
|||
selectAnim.forward(); |
|||
} |
|||
else |
|||
{ |
|||
selectAnim.reverse(); |
|||
} |
|||
|
|||
return new AnimatedBuilder( |
|||
animation: _colorTween, |
|||
builder: (build_context, child) => |
|||
{ |
|||
return new Container( |
|||
color: _colorTween.value, |
|||
child: widget.child); |
|||
} |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 96ea7736c64d4298849a9012085a0aa2 |
|||
timeCreated: 1627525724 |
撰写
预览
正在加载...
取消
保存
Reference in new issue