Skip to content

Commit 4735731

Browse files
committed
fix: secondary button weight layout regression
1 parent 3c7f7af commit 4735731

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

  • app/src/main/java/to/bitkit/ui/components

app/src/main/java/to/bitkit/ui/components/Button.kt

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Box
99
import androidx.compose.foundation.layout.Column
1010
import androidx.compose.foundation.layout.PaddingValues
1111
import androidx.compose.foundation.layout.Row
12-
import androidx.compose.foundation.layout.fillMaxSize
1312
import androidx.compose.foundation.layout.fillMaxWidth
1413
import androidx.compose.foundation.layout.padding
1514
import androidx.compose.foundation.layout.requiredHeight
@@ -83,6 +82,7 @@ enum class ButtonSize {
8382
Small -> 8.dp
8483
Large -> 6.dp
8584
}
85+
8686
fun secondaryBorder(enabled: Boolean): BorderStroke = when (this) {
8787
Large -> BorderStroke(2.dp, if (enabled) Colors.Gray4 else Color.Transparent)
8888
Small -> BorderStroke(1.dp, if (enabled) Colors.White16 else Color.Transparent)
@@ -183,6 +183,7 @@ fun SecondaryButton(
183183
// and AFTER size modifiers (Haze needs to know dimensions)
184184
val buttonShape = MaterialTheme.shapes.extraLarge
185185
Box(
186+
propagateMinConstraints = true,
186187
modifier = modifier
187188
.then(if (fullWidth) Modifier.fillMaxWidth() else Modifier)
188189
.requiredHeight(size.height)
@@ -200,15 +201,14 @@ fun SecondaryButton(
200201
} else {
201202
Modifier
202203
}
203-
)
204+
),
204205
) {
205206
OutlinedButton(
206207
onClick = rememberDebouncedClick(onClick = onClick),
207208
enabled = enabled && !isLoading,
208209
colors = AppButtonDefaults.secondaryColors.copy(contentColor = contentColor),
209210
contentPadding = contentPadding,
210211
border = border,
211-
modifier = if (fullWidth) Modifier.fillMaxSize() else Modifier,
212212
) {
213213
if (isLoading) {
214214
GradientCircularProgressIndicator(
@@ -488,6 +488,25 @@ private fun SecondaryButtonPreview() {
488488
)
489489
},
490490
)
491+
Row(
492+
modifier = Modifier.fillMaxWidth(),
493+
horizontalArrangement = Arrangement.spacedBy(8.dp)
494+
) {
495+
SecondaryButton(
496+
text = "Secondary",
497+
fullWidth = false,
498+
hazeState = hazeState,
499+
onClick = {},
500+
modifier = Modifier.weight(1f)
501+
)
502+
SecondaryButton(
503+
text = "Secondary",
504+
fullWidth = false,
505+
hazeState = hazeState,
506+
onClick = {},
507+
modifier = Modifier.weight(1f)
508+
)
509+
}
491510
SecondaryButton(
492511
text = "Secondary Small",
493512
size = ButtonSize.Small,
@@ -588,6 +607,23 @@ private fun TertiaryButtonPreview() {
588607
},
589608
onClick = {}
590609
)
610+
Row(
611+
modifier = Modifier.fillMaxWidth(),
612+
horizontalArrangement = Arrangement.spacedBy(8.dp)
613+
) {
614+
TertiaryButton(
615+
text = "Tertiary",
616+
fullWidth = false,
617+
onClick = {},
618+
modifier = Modifier.weight(1f)
619+
)
620+
TertiaryButton(
621+
text = "Tertiary",
622+
fullWidth = false,
623+
onClick = {},
624+
modifier = Modifier.weight(1f)
625+
)
626+
}
591627
TertiaryButton(
592628
text = "Tertiary Small",
593629
size = ButtonSize.Small,

0 commit comments

Comments
 (0)