Button theme: fix small integration mistake on button padding from Figma.

This commit is contained in:
Benoit Marty 2023-08-22 10:38:24 +02:00
parent a88b3699a3
commit 448e526ffa

View file

@ -133,23 +133,39 @@ internal fun ButtonInternal(
ButtonSize.Large -> 48.dp ButtonSize.Large -> 48.dp
} }
val contentPadding = when (size) { val hasNoStartDrawable = !showProgress && leadingIcon == null
ButtonSize.Medium -> {
when (style) { val (paddingStart, paddingCenter, paddingEnd) = when (size) {
ButtonStyle.Filled, ButtonSize.Medium -> when (style) {
ButtonStyle.Outlined -> PaddingValues(horizontal = 16.dp, vertical = 10.dp) ButtonStyle.Filled,
ButtonStyle.Text -> PaddingValues(horizontal = 12.dp, vertical = 10.dp) ButtonStyle.Outlined -> if (hasNoStartDrawable)
} Triple(24.dp, 0.dp, 24.dp)
else
Triple(16.dp, 8.dp, 24.dp)
ButtonStyle.Text -> if (hasNoStartDrawable)
Triple(12.dp, 0.dp, 12.dp)
else
Triple(12.dp, 8.dp, 16.dp)
} }
ButtonSize.Large -> { ButtonSize.Large -> when (style) {
when (style) { ButtonStyle.Filled,
ButtonStyle.Filled, ButtonStyle.Outlined -> if (hasNoStartDrawable)
ButtonStyle.Outlined -> PaddingValues(horizontal = 24.dp, vertical = 13.dp) Triple(32.dp, 0.dp, 32.dp)
ButtonStyle.Text -> PaddingValues(horizontal = 16.dp, vertical = 13.dp) else
} Triple(24.dp, 8.dp, 32.dp)
ButtonStyle.Text -> if (hasNoStartDrawable)
Triple(16.dp, 0.dp, 16.dp)
else
Triple(12.dp, 8.dp, 16.dp)
} }
} }
val contentPadding = when (size) {
ButtonSize.Medium -> PaddingValues(start = paddingStart, end = paddingEnd, top = 10.dp, bottom = 10.dp)
ButtonSize.Large -> PaddingValues(start = paddingStart, end = paddingEnd, top = 13.dp, bottom = 13.dp)
}
val internalPadding = PaddingValues(start = paddingCenter)
val shape = when (style) { val shape = when (style) {
ButtonStyle.Filled, ButtonStyle.Filled,
ButtonStyle.Outlined -> RoundedCornerShape(percent = 50) ButtonStyle.Outlined -> RoundedCornerShape(percent = 50)
@ -170,12 +186,6 @@ internal fun ButtonInternal(
ButtonSize.Large -> ElementTheme.typography.fontBodyLgMedium ButtonSize.Large -> ElementTheme.typography.fontBodyLgMedium
} }
val internalPadding = when (style) {
ButtonStyle.Filled,
ButtonStyle.Outlined -> PaddingValues(horizontal = 8.dp)
ButtonStyle.Text -> if (leadingIcon != null) PaddingValues(start = 8.dp) else PaddingValues(0.dp)
}
androidx.compose.material3.Button( androidx.compose.material3.Button(
onClick = { onClick = {
if (!showProgress) { if (!showProgress) {