@@ -26,6 +26,21 @@ pub enum AnimationTimingFunction {
26
26
AnimationCurve ( style_property_enum:: ArkUI_AnimationCurve ) ,
27
27
EasingFunction ( EasingFunction ) ,
28
28
}
29
+
30
+ #[ derive( Debug , Clone ) ]
31
+ pub enum AnimationDirection {
32
+ Normal ,
33
+ Reverse ,
34
+ Alternate ,
35
+ AlternateReverse ,
36
+ }
37
+
38
+ #[ derive( Debug , Clone ) ]
39
+ pub enum AnimationPlayState {
40
+ Paused ,
41
+ Running ,
42
+ }
43
+
29
44
#[ derive( Debug , Clone ) ]
30
45
pub struct AnimationMulti {
31
46
pub animation_names : Vec < String > ,
@@ -34,6 +49,8 @@ pub struct AnimationMulti {
34
49
pub animation_iterations : Vec < f32 > ,
35
50
pub animation_fill_modes : Vec < AnimationFillMode > ,
36
51
pub animation_timeing_functions : Vec < AnimationTimingFunction > ,
52
+ pub animation_directions : Vec < style_property_enum:: ArkUI_AnimationDirection > ,
53
+ pub animation_play_states : Vec < style_property_enum:: ArkUI_AnimationPlayState > ,
37
54
}
38
55
39
56
impl From < ( String , & Property < ' _ > ) > for AnimationMulti {
@@ -44,6 +61,8 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
44
61
let mut animation_iterations: Vec < f32 > = vec ! [ ] ; // 1.0
45
62
let mut animation_fill_modes: Vec < AnimationFillMode > = vec ! [ ] ;
46
63
let mut animation_timeing_functions: Vec < AnimationTimingFunction > = vec ! [ ] ; // EasingFunction::Ease
64
+ let mut animation_directions: Vec < style_property_enum:: ArkUI_AnimationDirection > = vec ! [ ] ; // ArkUI_AnimationDirection::ARKUI_ANIMATION_DIRECTION_NORMAL
65
+ let mut animation_play_states: Vec < style_property_enum:: ArkUI_AnimationPlayState > = vec ! [ ] ; // ArkUI_AnimationPlayState::ARKUI_ANIMATION_PLAY_STATE_RUNNING
47
66
48
67
match value. 1 {
49
68
// Property::AnimationName(_, _) => todo!(),
@@ -104,7 +123,21 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
104
123
} ) ;
105
124
animation_timeing_functions. push ( animation_timeing_function. unwrap_or (
106
125
AnimationTimingFunction :: EasingFunction ( EasingFunction :: Ease ) ,
107
- ) )
126
+ ) ) ;
127
+
128
+ let animation_direction = Some ( match animation. direction {
129
+ animation:: AnimationDirection :: Normal => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_NORMAL ,
130
+ animation:: AnimationDirection :: Reverse => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_REVERSE ,
131
+ animation:: AnimationDirection :: Alternate => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_ALTERNATE ,
132
+ animation:: AnimationDirection :: AlternateReverse => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_ALTERNATE_REVERSE ,
133
+ } ) ;
134
+ animation_directions. push ( animation_direction. unwrap_or ( style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_NORMAL ) ) ;
135
+
136
+ let animation_play_state = Some ( match animation. play_state {
137
+ animation:: AnimationPlayState :: Paused => style_property_enum:: ArkUI_AnimationPlayState :: ARKUI_ANIMATION_PLAY_STATE_PAUSED ,
138
+ animation:: AnimationPlayState :: Running => style_property_enum:: ArkUI_AnimationPlayState :: ARKUI_ANIMATION_PLAY_STATE_RUNNING ,
139
+ } ) ;
140
+ animation_play_states. push ( animation_play_state. unwrap_or ( style_property_enum:: ArkUI_AnimationPlayState :: ARKUI_ANIMATION_PLAY_STATE_RUNNING ) ) ;
108
141
} ) ;
109
142
}
110
143
Property :: AnimationDelay ( delay, _) => {
@@ -155,6 +188,26 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
155
188
) ) ;
156
189
}
157
190
}
191
+ Property :: AnimationDirection ( direction, _) => {
192
+ for direction_elem in direction {
193
+ let animation_direction = Some ( match direction_elem {
194
+ animation:: AnimationDirection :: Normal => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_NORMAL ,
195
+ animation:: AnimationDirection :: Reverse => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_REVERSE ,
196
+ animation:: AnimationDirection :: Alternate => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_ALTERNATE ,
197
+ animation:: AnimationDirection :: AlternateReverse => style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_ALTERNATE_REVERSE ,
198
+ } ) ;
199
+ animation_directions. push ( animation_direction. unwrap_or ( style_property_enum:: ArkUI_AnimationDirection :: ARKUI_ANIMATION_DIRECTION_NORMAL ) ) ;
200
+ }
201
+ }
202
+ Property :: AnimationPlayState ( play_state, _) => {
203
+ for play_state_elem in play_state {
204
+ let animation_play_state = Some ( match play_state_elem {
205
+ animation:: AnimationPlayState :: Paused => style_property_enum:: ArkUI_AnimationPlayState :: ARKUI_ANIMATION_PLAY_STATE_PAUSED ,
206
+ animation:: AnimationPlayState :: Running => style_property_enum:: ArkUI_AnimationPlayState :: ARKUI_ANIMATION_PLAY_STATE_RUNNING ,
207
+ } ) ;
208
+ animation_play_states. push ( animation_play_state. unwrap_or ( style_property_enum:: ArkUI_AnimationPlayState :: ARKUI_ANIMATION_PLAY_STATE_RUNNING ) ) ;
209
+ }
210
+ }
158
211
_ => { }
159
212
}
160
213
@@ -165,6 +218,8 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
165
218
animation_fill_modes,
166
219
animation_iterations,
167
220
animation_timeing_functions,
221
+ animation_directions,
222
+ animation_play_states,
168
223
}
169
224
}
170
225
}
@@ -303,6 +358,48 @@ impl ToExpr for AnimationMulti {
303
358
) ) ;
304
359
}
305
360
361
+ if !self . animation_directions . is_empty ( ) {
362
+ let directions = & self . animation_directions ;
363
+ let array_elements: Vec < _ > = directions
364
+ . into_iter ( )
365
+ . map ( |direction| {
366
+ let expr = generate_expr_enum ! ( * direction) ;
367
+ Some ( ExprOrSpread {
368
+ spread : None ,
369
+ expr : Box :: new ( expr) ,
370
+ } )
371
+ } )
372
+ . collect ( ) ;
373
+ exprs. push ( (
374
+ CSSPropertyType :: AnimationDirection ,
375
+ Expr :: Array ( ArrayLit {
376
+ span : DUMMY_SP ,
377
+ elems : array_elements,
378
+ } ) ,
379
+ ) ) ;
380
+ }
381
+
382
+ if !self . animation_play_states . is_empty ( ) {
383
+ let play_states = & self . animation_play_states ;
384
+ let array_elements: Vec < _ > = play_states
385
+ . into_iter ( )
386
+ . map ( |play_state| {
387
+ let expr = generate_expr_enum ! ( * play_state) ;
388
+ Some ( ExprOrSpread {
389
+ spread : None ,
390
+ expr : Box :: new ( expr) ,
391
+ } )
392
+ } )
393
+ . collect ( ) ;
394
+ exprs. push ( (
395
+ CSSPropertyType :: AnimationPlayState ,
396
+ Expr :: Array ( ArrayLit {
397
+ span : DUMMY_SP ,
398
+ elems : array_elements,
399
+ } ) ,
400
+ ) ) ;
401
+ }
402
+
306
403
PropertyTuple :: Array ( exprs)
307
404
}
308
405
}
0 commit comments