Skip to content

Commit b41ff1b

Browse files
author
mayintao3
committed
feat: 添加 animation-fill-mode 的解析
1 parent f67d88d commit b41ff1b

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/style_propetries/animation.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ impl
138138
_ => AnimationTimingFunction::EasingFunction(timing_function.get(0).unwrap().clone()),
139139
});
140140
}
141+
Property::AnimationFillMode(fill_mode, _) => {
142+
animation_fill_mode = Some(fill_mode.get(0).unwrap().clone());
143+
}
141144
_ => {}
142145
}
143146

@@ -176,11 +179,13 @@ impl ToExpr for Animation {
176179
))
177180
}
178181
if let Some(fill_mode) = &self.animation_fill_mode {
179-
// exprs.push((CSSPropertyType::AnimationFillMode, generate_expr_enum!(*fill_mode)));
180-
exprs.push((
181-
CSSPropertyType::AnimationFillMode,
182-
generate_expr_lit_str!(fill_mode.to_css_string(PrinterOptions::default()).unwrap()),
183-
));
182+
let enum_value = match fill_mode {
183+
AnimationFillMode::None => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_NONE,
184+
AnimationFillMode::Forwards => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_FORWARDS,
185+
AnimationFillMode::Backwards => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_BACKWARDS,
186+
AnimationFillMode::Both => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_BOTH,
187+
};
188+
exprs.push((CSSPropertyType::AnimationFillMode, generate_expr_enum!(enum_value)));
184189
}
185190
if let Some(timeing_function) = &self.animation_timeing_function {
186191
match timeing_function {

src/style_propetries/animation_multi.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ impl From<(String, &Property<'_>)> for AnimationMulti {
208208
animation_play_states.push(animation_play_state.unwrap_or(style_property_enum::ArkUI_AnimationPlayState::ARKUI_ANIMATION_PLAY_STATE_RUNNING));
209209
}
210210
}
211+
Property::AnimationFillMode(fill_mode, _) => {
212+
for fill_mode_elem in fill_mode {
213+
animation_fill_modes.push(fill_mode_elem.clone());
214+
}
215+
}
211216
_ => {}
212217
}
213218

@@ -310,9 +315,13 @@ impl ToExpr for AnimationMulti {
310315
let array_elements: Vec<_> = fill_modes
311316
.into_iter()
312317
.map(|fill_mode| {
313-
// Assuming `generate_expr_lit_num!` generates a numeric expression
314-
let expr =
315-
generate_expr_lit_str!(fill_mode.to_css_string(PrinterOptions::default()).unwrap());
318+
let enum_value = match fill_mode {
319+
AnimationFillMode::None => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_NONE,
320+
AnimationFillMode::Forwards => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_FORWARDS,
321+
AnimationFillMode::Backwards => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_BACKWARDS,
322+
AnimationFillMode::Both => style_property_enum::ArkUI_AnimationFillMode::ARKUI_ANIMATION_FILL_MODE_BOTH,
323+
};
324+
let expr = generate_expr_enum!(enum_value);
316325
Some(ExprOrSpread {
317326
spread: None,
318327
expr: Box::new(expr),

0 commit comments

Comments
 (0)