Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e0d028d

Browse files
author
mayintao3
committed
feat: 添加animationDirection和animationplaystate的解析
1 parent 06e5bda commit e0d028d

File tree

3 files changed

+126
-1
lines changed

3 files changed

+126
-1
lines changed

‎src/style_propetries/animation_multi.rs

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)]
3045
pub 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

3956
impl 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
}

‎src/style_propetries/style_property_enum.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,27 @@ pub enum BoxOrient {
415415
InlineAxis,
416416
BlockAxis,
417417
}
418+
419+
#[repr(u32)]
420+
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
421+
#[allow(non_camel_case_types)]
422+
pub enum ArkUI_AnimationDirection {
423+
/** 正常播放 */
424+
ARKUI_ANIMATION_DIRECTION_NORMAL = 0,
425+
/** 反向播放 */
426+
ARKUI_ANIMATION_DIRECTION_REVERSE,
427+
/** 交替播放 */
428+
ARKUI_ANIMATION_DIRECTION_ALTERNATE,
429+
/** 反向交替播放 */
430+
ARKUI_ANIMATION_DIRECTION_ALTERNATE_REVERSE,
431+
}
432+
433+
#[repr(u32)]
434+
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
435+
#[allow(non_camel_case_types)]
436+
pub enum ArkUI_AnimationPlayState {
437+
/** 暂停状态 */
438+
ARKUI_ANIMATION_PLAY_STATE_PAUSED = 0,
439+
/** 运行状态 */
440+
ARKUI_ANIMATION_PLAY_STATE_RUNNING,
441+
}

‎src/style_propetries/style_property_type.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ pub enum CSSPropertyType {
110110
Border = 105, // 复合属性
111111
BorderStyle = 106, // 复合属性
112112
Gap = 107, // 复合属性
113+
AnimationDirection = 108,
114+
AnimationPlayState = 109,
115+
// ...
116+
All = 99999, // used for transition-property
113117
}
114118

115119
pub fn string_to_css_property_type(property: &str) -> CSSPropertyType {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /