Skip to content

Commit ee55b97

Browse files
author
mayintao3
committed
feat: 拆分text-decoration
1 parent 5eadcf2 commit ee55b97

File tree

3 files changed

+52
-23
lines changed

3 files changed

+52
-23
lines changed

src/style_propetries/style_property_enum.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub enum ArkUI_AnimationCurve {
159159
#[allow(non_camel_case_types)]
160160
pub enum ArkUI_AnimationFillMode {
161161
// 动画未执行时不会将任何样式应用于目标,动画播放完成之后恢复初始默认状态。
162-
ARKUI_ANIMATION_FILL_MODE_NONE = 0 ,
162+
ARKUI_ANIMATION_FILL_MODE_NONE = 0,
163163
// 目标将保留动画执行期间最后一个关键帧的状态。
164164
ARKUI_ANIMATION_FILL_MODE_FORWARDS,
165165
// 动画将在应用于目标时立即应用第一个关键帧中定义的值,并在delay期间保留此值。
@@ -251,6 +251,22 @@ pub enum ArkUI_TextDecorationType {
251251
ARKUI_TEXT_DECORATION_TYPE_LINE_THROUGH,
252252
}
253253

254+
#[repr(u32)]
255+
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
256+
#[allow(non_camel_case_types)]
257+
pub enum ArkUI_TextDecorationStyle {
258+
/** Single solid line. */
259+
ARKUI_TEXT_DECORATION_STYLE_SOLID = 0,
260+
/** Double solid line. */
261+
ARKUI_TEXT_DECORATION_STYLE_DOUBLE,
262+
/** Dotted line. */
263+
ARKUI_TEXT_DECORATION_STYLE_DOTTED,
264+
/** Dashed line. */
265+
ARKUI_TEXT_DECORATION_STYLE_DASHED,
266+
/** Wavy line. */
267+
ARKUI_TEXT_DECORATION_STYLE_WAVY,
268+
}
269+
254270
#[repr(u32)]
255271
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
256272
#[allow(non_camel_case_types)]

src/style_propetries/style_property_type.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,14 @@ pub enum CSSPropertyType {
8787
AnimationFillMode = 82,
8888
BackgroundPositionX = 83,
8989
BackgroundPositionY = 84,
90-
transition = 85,
91-
transitionProperty = 86,
92-
transitionDuration = 87,
93-
transitionTimingFunction = 88,
94-
transitionDelay = 89,
90+
Transition = 85,
91+
TransitionProperty = 86,
92+
TransitionDuration = 87,
93+
TransitionTimingFunction = 88,
94+
TransitionDelay = 89,
9595
WhiteSpace = 90,
96+
TextDecorationLine = 91,
97+
TextDecorationThickness = 92,
98+
TextDecorationStyle = 93,
99+
TextDecorationColor = 94,
96100
}

src/style_propetries/text_decoration.rs

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,43 @@ pub struct TextDecorationColor(CssColor);
3535

3636
impl ToExpr for TextDecoration {
3737
fn to_expr(&self) -> PropertyTuple {
38-
let mut props = vec![];
38+
let mut props: Vec<(CSSPropertyType, Expr)> = vec![];
3939

4040
if let Some(line) = &self.line {
41-
props.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
42-
key: generate_prop_name!("type"),
43-
value: match line {
41+
props.push((
42+
CSSPropertyType::TextDecorationLine,
43+
match line {
4444
TextDecorationLine::Underline => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationType::ARKUI_TEXT_DECORATION_TYPE_UNDERLINE),
4545
TextDecorationLine::LineThrough => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationType::ARKUI_TEXT_DECORATION_TYPE_LINE_THROUGH),
4646
TextDecorationLine::Overline => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationType::ARKUI_TEXT_DECORATION_TYPE_OVERLINE),
4747
_ => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationType::ARKUI_TEXT_DECORATION_TYPE_NONE),
48-
}.into()
49-
}))));
48+
}
49+
));
5050
}
5151

5252
if let Some(color) = &self.color {
53-
props.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
54-
key: generate_prop_name!("color"),
55-
value: generate_expr_lit_color!(color.0.clone()).into()
56-
}))));
53+
props.push((
54+
CSSPropertyType::TextDecorationColor,
55+
generate_expr_lit_color!(color.0.clone())
56+
));
57+
58+
}
59+
60+
if let Some(style) = &self.style {
61+
props.push((
62+
CSSPropertyType::TextDecorationStyle,
63+
match style {
64+
TextDecorationStyle::Solid => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationStyle::ARKUI_TEXT_DECORATION_STYLE_SOLID),
65+
TextDecorationStyle::Double => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationStyle::ARKUI_TEXT_DECORATION_STYLE_DOUBLE),
66+
TextDecorationStyle::Dotted => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationStyle::ARKUI_TEXT_DECORATION_STYLE_DOTTED),
67+
TextDecorationStyle::Dashed => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationStyle::ARKUI_TEXT_DECORATION_STYLE_DASHED),
68+
TextDecorationStyle::Wavy => generate_expr_enum!(style_property_enum::ArkUI_TextDecorationStyle::ARKUI_TEXT_DECORATION_STYLE_WAVY),
69+
}
70+
));
71+
5772
}
5873

59-
PropertyTuple::One(
60-
CSSPropertyType::TextDecoration,
61-
Expr::Object(ObjectLit {
62-
span: DUMMY_SP,
63-
props: props
64-
})
65-
)
74+
PropertyTuple::Array(props)
6675
}
6776
}
6877

0 commit comments

Comments
 (0)