-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainView.ux
164 lines (129 loc) · 5.09 KB
/
MainView.ux
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<App>
<Android.StatusBarConfig Color="#0000" IsVisible="false" />
<iOS.StatusBarConfig IsVisible="false" />
<Font File="Assets/Fonts/iconmonstr-iconic-font.ttf" ux:Global="Iconic" />
<string ux:Global="btns.play" ux:Value="" />
<string ux:Global="btns.pause" ux:Value="" />
<string ux:Global="btns.stop" ux:Value="" />
<string ux:Global="btns.loop" ux:Value="" />
<string ux:Global="btns.autoReverseAnimation" ux:Value="" />
<JavaScript>
var Observable = require('FuseJS/Observable');
var Environment = require('FuseJS/Environment');
var animationCounter = 0;
var animations = [
'Assets/Animations/Check Mark Success Data.json',
'Assets/Animations/427-happy-birthday.json',
];
var urlToJSON = new Observable('Assets/Animations/Check Mark Success Data.json');
function changeAnimation() {
animationCounter += 1;
if (animationCounter >= animations.length) {
animationCounter = 0;
}
urlToJSON.value = animations[animationCounter];
}
var isAnimationPlaying = Observable(false); //need to do via JS
var contentMode = Observable("scaleaspectfit");
var loopAnimation = Observable(false);
var autoReverseAnimation = Observable(false);
var play = Observable(false);
var pause = Observable(false);
var stop = Observable(false);
var progress = Observable(0);
var isDefaultPlay = true;
var animationCompleted = Observable(false);
animationCompleted.onValueChanged(module, function(val){
if (isDefaultPlay) {
isDefaultPlay = false;
} else {
play.value = !val;
}
});
function toggleLoop() {
loopAnimation.value = !loopAnimation.value;
}
function toggleAutoReverseAnimation() {
autoReverseAnimation.value = !autoReverseAnimation.value;
}
function playAnimation() {
play.value = true;
}
function pauseAnimation() {
pause.value = true;
}
function stopAnimation() {
stop.value = true;
}
module.exports = {
urlToJSON,
contentMode,
loopAnimation,
autoReverseAnimation,
play,
pause,
stop,
progress,
changeAnimation,
playAnimation,
pauseAnimation,
stopAnimation,
toggleLoop,
toggleAutoReverseAnimation,
animationCompleted,
};
</JavaScript>
<ScrollView>
<StackPanel Margin="0,20">
<NativeViewHost Width="100%" Height="320">
<RBT.Animation.Lottie ux:Name="myPlayer" File="{urlToJSON}" ContentMode="{contentMode}" LoopAnimation="{loopAnimation}" Play="{play}" Pause="{pause}" Stop="{stop}" Progress="{progress}" AutoReverseAnimation="{autoReverseAnimation}" AnimationCompleted="{animationCompleted}" />
</NativeViewHost>
<StackPanel Dock="Bottom" Padding="20">
<StackPanel Alignment="Center" Orientation="Horizontal" Margin="20,0,0,0">
<ControlButton ux:Name="playBtn" Icon="{Resource btns.play}" Clicked="{playAnimation}"/>
<ControlButton ux:Name="pauseBtn" Icon="{Resource btns.pause}" Clicked="{pauseAnimation}"/>
<ControlButton ux:Name="stopBtn" Icon="{Resource btns.stop}" Clicked="{stopAnimation}"/>
<ControlButton ux:Name="loopBtn" Icon="{Resource btns.loop}" Clicked="{toggleLoop}"/>
<ControlButton ux:Name="autoReverseAnimationBtn" Icon="{Resource btns.autoReverseAnimation}" Clicked="{toggleAutoReverseAnimation}"/>
<WhileTrue Value="{autoReverseAnimation}">
<Change autoReverseAnimationBtn.TextColor="#ffffff" />
<Change autoReverseAnimationBtn.BackgroundColor="#1188ff" />
</WhileTrue>
<WhileTrue Value="{play}">
<Change playBtn.TextColor="#ffffff" />
<Change playBtn.BackgroundColor="#1188ff" />
</WhileTrue>
<WhileTrue Value="{pause}">
<Change pauseBtn.TextColor="#ffffff" />
<Change pauseBtn.BackgroundColor="#1188ff" />
</WhileTrue>
<WhileTrue Value="{stop}">
<Change stopBtn.TextColor="#ffffff" />
<Change stopBtn.BackgroundColor="#1188ff" />
</WhileTrue>
<WhileTrue Value="{loopAnimation}">
<Change loopBtn.TextColor="#ffffff" />
<Change loopBtn.BackgroundColor="#1188ff" />
</WhileTrue>
</StackPanel>
<Slider Value="{progress}" Minimum="0" Maximum="1" Padding="20, 30" />
<Text FontSize="12" Value="File: {urlToJSON}" Padding="5" />
<iOS>
<Text FontSize="12" Value="iOS Content Mode: {contentMode}" Padding="5" />
<Text FontSize="12" Value="iOS Auto Reverse Animation: {autoReverseAnimation}" Padding="5" />
</iOS>
<Button Dock="Bottom" Text="SWITCH ANIMATION" Clicked="{changeAnimation}" Padding="20"/>
</StackPanel>
</StackPanel>
</ScrollView>
<Panel ux:Class="ControlButton" Padding="16,14" Margin="0,0,5,0" HitTestMode="LocalBounds" TextColor="#1188ff" BorderColor="#1188ff" BackgroundColor="#ffffff">
<string ux:Property="Icon" />
<string ux:Property="TextColor" />
<string ux:Property="BorderColor" />
<string ux:Property="BackgroundColor" />
<Text FontSize="14" Value="{ReadProperty Icon}" Color="{Property TextColor}" Font="Iconic" />
<Rectangle Layer="Background" Color="{Property BackgroundColor}" CornerRadius="7">
<Stroke Width="1" Color="{Property BorderColor}" />
</Rectangle>
</Panel>
</App>