Skip to content

Commit 3c47d8c

Browse files
author
mayintao3
committed
Merge branch 'feat/capi'
2 parents 986859d + fa4d75a commit 3c47d8c

File tree

4 files changed

+46
-35
lines changed

4 files changed

+46
-35
lines changed

src/style_propetries/background_position.rs

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,37 +124,41 @@ pub struct BackgroundPosition {
124124

125125
impl ToExpr for BackgroundPosition {
126126
fn to_expr(&self) -> PropertyTuple {
127-
let expr = match self.value.get(0).unwrap() {
128-
ImagePosition::ImagePositionXY(x, y) => Expr::Object(ObjectLit {
129-
span: DUMMY_SP,
130-
props: vec![
131-
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
132-
key: PropName::Ident(Ident::new("x".into(), DUMMY_SP)),
133-
value: generate_expr_with_css_input(x.to_string(), Platform::Harmony).into(),
134-
}))),
135-
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
136-
key: PropName::Ident(Ident::new("y".into(), DUMMY_SP)),
137-
value: generate_expr_with_css_input(y.to_string(), Platform::Harmony).into(),
138-
}))),
139-
]
140-
.into(),
141-
})
142-
.into(),
143-
ImagePosition::TopStart => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_TOP_START),
144-
ImagePosition::Top => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_TOP),
145-
ImagePosition::TopEnd => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_TOP_END),
146-
ImagePosition::Start => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_START),
147-
ImagePosition::Center => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_CENTER),
148-
ImagePosition::End => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_END),
149-
ImagePosition::BottomStart => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_BOTTOM_START),
150-
ImagePosition::Bottom => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_BOTTOM),
151-
ImagePosition::BottomEnd => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_BOTTOM_END),
127+
let property_tuple = match self.value.get(0).unwrap() {
128+
ImagePosition::ImagePositionXY(x, y) => {
129+
PropertyTuple::Array(vec![
130+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input(x.to_string(), Platform::Harmony).into()),
131+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input(y.to_string(), Platform::Harmony).into())
132+
])
133+
},
134+
position => {
135+
let expr = match position {
136+
ImagePosition::TopStart => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_TOP_START),
137+
ImagePosition::Top => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_TOP),
138+
ImagePosition::TopEnd => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_TOP_END),
139+
ImagePosition::Start => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_START),
140+
ImagePosition::Center => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_CENTER),
141+
ImagePosition::End => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_END),
142+
ImagePosition::BottomStart => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_BOTTOM_START),
143+
ImagePosition::Bottom => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_BOTTOM),
144+
ImagePosition::BottomEnd => generate_expr_enum!(style_property_enum::ArkUI_Alignment::ARKUI_ALIGNMENT_BOTTOM_END),
145+
_ => unreachable!(),
146+
};
147+
148+
PropertyTuple::One(
149+
CSSPropertyType::BackgroundPosition,
150+
expr
151+
)
152+
},
153+
152154
};
153155

154-
PropertyTuple::One(
155-
CSSPropertyType::BackgroundPosition,
156-
expr
157-
)
156+
property_tuple
157+
158+
// PropertyTuple::One(
159+
// CSSPropertyType::BackgroundPosition,
160+
// expr
161+
// )
158162
}
159163

160164
}

src/style_propetries/style_property_type.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ pub enum CSSPropertyType {
8383
AnimationIterationCount = 78,
8484
Content = 79,
8585
WordBreak = 80,
86-
WebkitLineClamp = 81,
87-
AnimationFillMode = 82
86+
WebkitLineLamp = 81,
87+
AnimationFillMode = 82,
88+
BackgroundPositionX = 83,
89+
BackgroundPositionY = 84,
90+
transition = 85,
91+
transitionProperty = 86,
92+
transitionDuration = 87,
93+
transitionTimingFunction = 88,
94+
transitionDelay = 89
8895
}

src/style_propetries/transform_origin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl ToExpr for TransformOrigin {
3737
span: DUMMY_SP,
3838
props: vec![
3939
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
40-
key: PropName::Ident(Ident::new(stringify!("x").into(), DUMMY_SP)),
40+
key: PropName::Ident(Ident::new(stringify!(x).into(), DUMMY_SP)),
4141
value: Box::new(
4242
match &self.x {
4343
EnumValue::String(value) => generate_expr_lit_str!(value.to_string()),
@@ -46,7 +46,7 @@ impl ToExpr for TransformOrigin {
4646
),
4747
}))),
4848
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
49-
key: PropName::Ident(Ident::new(stringify!("y").into(), DUMMY_SP)),
49+
key: PropName::Ident(Ident::new(stringify!(y).into(), DUMMY_SP)),
5050
value: Box::new(
5151
match &self.y {
5252
EnumValue::String(value) => generate_expr_lit_str!(value.to_string()),

src/style_propetries/transform_properties/translate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Translate {
4747
if let Some(z) = &self.z {
4848
match z {
4949
Length::Value(val) => props.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
50-
key: PropName::Ident(Ident::new(stringify!("z").into(), DUMMY_SP)),
50+
key: PropName::Ident(Ident::new(stringify!(z).into(), DUMMY_SP)),
5151
value: Box::new(generate_expr_by_length_value(&val, Platform::Harmony))
5252
})))),
5353
_ => {}
@@ -84,7 +84,7 @@ impl Translate {
8484
if let Some(z) = &self.z {
8585
match z {
8686
Length::Value(val) => props.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
87-
key: PropName::Ident(Ident::new(stringify!("z").into(), DUMMY_SP)),
87+
key: PropName::Ident(Ident::new(stringify!(z).into(), DUMMY_SP)),
8888
value: Box::new(generate_expr_by_length_value(&val, Platform::Harmony))
8989
})))),
9090
_ => {}

0 commit comments

Comments
 (0)