Skip to content

Commit bb34cb3

Browse files
author
mayintao3
committed
feat: background枚举变成百分比
1 parent 90ead0d commit bb34cb3

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

src/style_propetries/background_position.rs

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,42 @@ impl ToExpr for BackgroundPosition {
131131
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input(y.to_string(), Platform::Harmony).into())
132132
])
133133
},
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-
},
134+
ImagePosition::TopStart => PropertyTuple::Array(vec![
135+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("0%".to_string(), Platform::Harmony).into()),
136+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("0%".to_string(), Platform::Harmony).into())
137+
]),
138+
ImagePosition::Top => PropertyTuple::Array(vec![
139+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("50%".to_string(), Platform::Harmony).into()),
140+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("0%".to_string(), Platform::Harmony).into())
141+
]),
142+
ImagePosition::TopEnd => PropertyTuple::Array(vec![
143+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("100%".to_string(), Platform::Harmony).into()),
144+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("0%".to_string(), Platform::Harmony).into())
145+
]),
146+
ImagePosition::Start => PropertyTuple::Array(vec![
147+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("0%".to_string(), Platform::Harmony).into()),
148+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("50%".to_string(), Platform::Harmony).into())
149+
]),
150+
ImagePosition::Center => PropertyTuple::Array(vec![
151+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("50%".to_string(), Platform::Harmony).into()),
152+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("50%".to_string(), Platform::Harmony).into())
153+
]),
154+
ImagePosition::End => PropertyTuple::Array(vec![
155+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("100%".to_string(), Platform::Harmony).into()),
156+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("50%".to_string(), Platform::Harmony).into())
157+
]),
158+
ImagePosition::BottomStart => PropertyTuple::Array(vec![
159+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("0%".to_string(), Platform::Harmony).into()),
160+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("100%".to_string(), Platform::Harmony).into())
161+
]),
162+
ImagePosition::Bottom => PropertyTuple::Array(vec![
163+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("50%".to_string(), Platform::Harmony).into()),
164+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("100%".to_string(), Platform::Harmony).into())
165+
]),
166+
ImagePosition::BottomEnd => PropertyTuple::Array(vec![
167+
(CSSPropertyType::BackgroundPositionX, generate_expr_with_css_input("100%".to_string(), Platform::Harmony).into()),
168+
(CSSPropertyType::BackgroundPositionY, generate_expr_with_css_input("100%".to_string(), Platform::Harmony).into())
169+
]),
153170

154171
};
155172

0 commit comments

Comments
 (0)