Skip to content

Commit

Permalink
Fix how control labels fill horizontal space in forms
Browse files Browse the repository at this point in the history
  • Loading branch information
aabewhite committed Aug 18, 2024
1 parent 2ddaa3f commit e3ed41b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Sources/SkipUI/SkipUI/Controls/DatePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ public struct DatePicker : View {
} else {
ComposeContainer(modifier: context.modifier, fillWidth: true) { modifier in
Row(modifier: modifier, horizontalArrangement: horizontalArrangement, verticalAlignment: androidx.compose.ui.Alignment.CenterVertically) {
label.Compose(context: contentContext)
androidx.compose.foundation.layout.Spacer(modifier: Modifier.weight(Float(1.0)))
Box(modifier: Modifier.weight(Float(1.0))) {
label.Compose(context: contentContext)
}
ComposePickerContent(context: contentContext)
}
}
Expand Down
13 changes: 7 additions & 6 deletions Sources/SkipUI/SkipUI/Controls/Picker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.ContentAlpha
import androidx.compose.material3.DropdownMenu
Expand Down Expand Up @@ -62,9 +63,9 @@ public struct Picker<SelectionValue> : View, ListItemAdapting {
}, enabled: EnvironmentValues.shared.isEnabled)
ComposeContainer(modifier: modifier, fillWidth: true) { modifier in
Row(modifier: modifier, verticalAlignment: androidx.compose.ui.Alignment.CenterVertically) {
Button.ComposeTextButton(label: label, context: contentContext)
androidx.compose.foundation.layout.Spacer(modifier: Modifier.width(8.dp))
androidx.compose.foundation.layout.Spacer(modifier: Modifier.weight(Float(1.0)))
Box(modifier: Modifier.padding(end: 8.dp).weight(Float(1.0))) {
Button.ComposeTextButton(label: label, context: contentContext)
}
ComposeSelectedValue(views: views, context: contentContext, style: style, performsAction: false)
}
}
Expand Down Expand Up @@ -123,9 +124,9 @@ public struct Picker<SelectionValue> : View, ListItemAdapting {
let modifier = Modifier.clickable(onClick: onClick, enabled: EnvironmentValues.shared.isEnabled).then(contentModifier)
Row(modifier: modifier, verticalAlignment: androidx.compose.ui.Alignment.CenterVertically) {
if !EnvironmentValues.shared._labelsHidden {
label.Compose(context: context)
androidx.compose.foundation.layout.Spacer(modifier: Modifier.width(8.dp))
androidx.compose.foundation.layout.Spacer(modifier: Modifier.weight(Float(1.0)))
Box(modifier: Modifier.padding(end: 8.dp).weight(Float(1.0))) {
label.Compose(context: context)
}
}
Box {
ComposeSelectedValue(views: views, context: context, style: style, performsAction: false)
Expand Down
6 changes: 4 additions & 2 deletions Sources/SkipUI/SkipUI/Controls/Toggle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// as published by the Free Software Foundation https://fsf.org

#if SKIP
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.material.ContentAlpha
import androidx.compose.material3.Switch
Expand Down Expand Up @@ -63,8 +64,9 @@ public struct Toggle : View {
let contentContext = context.content()
ComposeContainer(modifier: context.modifier, fillWidth: true) { modifier in
Row(modifier: modifier, verticalAlignment: androidx.compose.ui.Alignment.CenterVertically) {
label.Compose(context: contentContext)
androidx.compose.foundation.layout.Spacer(modifier: Modifier.weight(Float(1.0)))
Box(modifier: Modifier.weight(Float(1.0))) {
label.Compose(context: contentContext)
}
PaddingLayout(padding: EdgeInsets(top: -6.0, leading: 0.0, bottom: -6.0, trailing: 0.0), context: context) { context in
Switch(checked: isOn.wrappedValue, onCheckedChange: { isOn.wrappedValue = $0 }, enabled: EnvironmentValues.shared.isEnabled, colors: colors)
}
Expand Down

0 comments on commit e3ed41b

Please sign in to comment.