Fix implementation of full_width and icon_position in button

This commit is contained in:
Nate Butler 2023-12-18 12:56:50 -05:00
parent 196df1c378
commit d72cd3795a
2 changed files with 20 additions and 15 deletions

View file

@ -151,26 +151,31 @@ impl RenderOnce for Button {
self.base.child( self.base.child(
h_stack() h_stack()
.gap_1() .gap_1()
.map(|this| { .when(self.icon_position.is_some(), |this| {
if self.icon_position == Some(IconPosition::End) { this.children(self.icon.map(|icon| {
this.flex_row_reverse() ButtonIcon::new(icon)
} else { .disabled(is_disabled)
this .selected(is_selected)
} .selected_icon(self.selected_icon)
.size(self.icon_size)
.color(self.icon_color)
}))
}) })
.child( .child(
Label::new(label) Label::new(label)
.color(label_color) .color(label_color)
.line_height_style(LineHeightStyle::UILabel), .line_height_style(LineHeightStyle::UILabel),
) )
.children(self.icon.map(|icon| { .when(!self.icon_position.is_some(), |this| {
ButtonIcon::new(icon) this.children(self.icon.map(|icon| {
.disabled(is_disabled) ButtonIcon::new(icon)
.selected(is_selected) .disabled(is_disabled)
.selected_icon(self.selected_icon) .selected(is_selected)
.size(self.icon_size) .selected_icon(self.selected_icon)
.color(self.icon_color) .size(self.icon_size)
})), .color(self.icon_color)
}))
}),
) )
} }
} }

View file

@ -355,7 +355,7 @@ impl RenderOnce for ButtonLike {
.group("") .group("")
.flex_none() .flex_none()
.h(self.size.height()) .h(self.size.height())
.when_some(self.width, |this, width| this.w(width)) .when_some(self.width, |this, width| this.w(width).justify_center())
.rounded_md() .rounded_md()
.gap_1() .gap_1()
.map(|this| match self.size { .map(|this| match self.size {