Fix implementation of full_width and icon_position in button

Nate Butler created

Change summary

crates/ui2/src/components/button/button.rs      | 33 ++++++++++--------
crates/ui2/src/components/button/button_like.rs |  2 
2 files changed, 20 insertions(+), 15 deletions(-)

Detailed changes

crates/ui2/src/components/button/button.rs 🔗

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

crates/ui2/src/components/button/button_like.rs 🔗

@@ -355,7 +355,7 @@ impl RenderOnce for ButtonLike {
             .group("")
             .flex_none()
             .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()
             .gap_1()
             .map(|this| match self.size {