@@ -26,6 +26,21 @@ pub enum AnimationTimingFunction {
2626 AnimationCurve ( style_property_enum:: ArkUI_AnimationCurve ) ,
2727 EasingFunction ( EasingFunction ) ,
2828}
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+
2944#[ derive( Debug , Clone ) ]
3045pub struct AnimationMulti {
3146 pub animation_names : Vec < String > ,
@@ -34,6 +49,8 @@ pub struct AnimationMulti {
3449 pub animation_iterations : Vec < f32 > ,
3550 pub animation_fill_modes : Vec < AnimationFillMode > ,
3651 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 > ,
3754}
3855
3956impl From < ( String , & Property < ' _ > ) > for AnimationMulti {
@@ -44,6 +61,8 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
4461 let mut animation_iterations: Vec < f32 > = vec ! [ ] ; // 1.0
4562 let mut animation_fill_modes: Vec < AnimationFillMode > = vec ! [ ] ;
4663 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
4766
4867 match value. 1 {
4968 // Property::AnimationName(_, _) => todo!(),
@@ -104,7 +123,21 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
104123 } ) ;
105124 animation_timeing_functions. push ( animation_timeing_function. unwrap_or (
106125 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 ) ) ;
108141 } ) ;
109142 }
110143 Property :: AnimationDelay ( delay, _) => {
@@ -155,6 +188,26 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
155188 ) ) ;
156189 }
157190 }
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+ }
158211 _ => { }
159212 }
160213
@@ -165,6 +218,8 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
165218 animation_fill_modes,
166219 animation_iterations,
167220 animation_timeing_functions,
221+ animation_directions,
222+ animation_play_states,
168223 }
169224 }
170225}
@@ -303,6 +358,48 @@ impl ToExpr for AnimationMulti {
303358 ) ) ;
304359 }
305360
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+
306403 PropertyTuple :: Array ( exprs)
307404 }
308405}
0 commit comments