-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationApp.cs
More file actions
60 lines (52 loc) · 1.73 KB
/
Copy pathAnimationApp.cs
File metadata and controls
60 lines (52 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using UniMob;
using UniMob.UI;
using UniMob.UI.Widgets;
using UnityEngine;
namespace Samples.Animation
{
public class AnimationApp : UniMobUIApp
{
public float duration = 1f;
public FloatTween opacity = new FloatTween(0, 1);
public Vector2Tween position = new Vector2Tween(Vector2.up, Vector2.down);
private AnimationController _controller;
protected override void Initialize()
{
_controller = new AnimationController(Lifetime, duration);
_controller.Forward();
Atom.Reaction(Lifetime, () => _controller.Status, OnControllerStatusChanged,
debugName: "AnimationApp.OnControllerStatusChanged reaction");
}
private void OnControllerStatusChanged(AnimationStatus status)
{
switch (status)
{
case AnimationStatus.Completed:
_controller.Reverse();
break;
case AnimationStatus.Dismissed:
_controller.Forward();
break;
}
}
protected override Widget Build(BuildContext context)
{
return new Container
{
Size = WidgetSize.Stretched,
BackgroundColor = Color.white,
Child = new CompositeTransition
{
Opacity = opacity.Animate(_controller),
Position = position.Animate(_controller),
Child = new Container
{
BackgroundColor = Color.black,
Size = WidgetSize.Fixed(300, 200),
}
}
};
}
}
}