Code clarity (no change effect): always use when with ButtonStyle.Filled, ButtonStyle.Outlined and ButtonStyle.Text cases.
This commit is contained in:
parent
3a476f5130
commit
a88b3699a3
1 changed files with 12 additions and 7 deletions
|
|
@ -136,29 +136,33 @@ internal fun ButtonInternal(
|
||||||
val contentPadding = when (size) {
|
val contentPadding = when (size) {
|
||||||
ButtonSize.Medium -> {
|
ButtonSize.Medium -> {
|
||||||
when (style) {
|
when (style) {
|
||||||
|
ButtonStyle.Filled,
|
||||||
|
ButtonStyle.Outlined -> PaddingValues(horizontal = 16.dp, vertical = 10.dp)
|
||||||
ButtonStyle.Text -> PaddingValues(horizontal = 12.dp, vertical = 10.dp)
|
ButtonStyle.Text -> PaddingValues(horizontal = 12.dp, vertical = 10.dp)
|
||||||
else -> PaddingValues(horizontal = 16.dp, vertical = 10.dp)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ButtonSize.Large -> {
|
ButtonSize.Large -> {
|
||||||
when (style) {
|
when (style) {
|
||||||
|
ButtonStyle.Filled,
|
||||||
|
ButtonStyle.Outlined -> PaddingValues(horizontal = 24.dp, vertical = 13.dp)
|
||||||
ButtonStyle.Text -> PaddingValues(horizontal = 16.dp, vertical = 13.dp)
|
ButtonStyle.Text -> PaddingValues(horizontal = 16.dp, vertical = 13.dp)
|
||||||
else -> PaddingValues(horizontal = 24.dp, vertical = 13.dp)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val shape = when (style) {
|
val shape = when (style) {
|
||||||
ButtonStyle.Filled, ButtonStyle.Outlined -> RoundedCornerShape(percent = 50)
|
ButtonStyle.Filled,
|
||||||
|
ButtonStyle.Outlined -> RoundedCornerShape(percent = 50)
|
||||||
ButtonStyle.Text -> RectangleShape
|
ButtonStyle.Text -> RectangleShape
|
||||||
}
|
}
|
||||||
|
|
||||||
val border = when (style) {
|
val border = when (style) {
|
||||||
ButtonStyle.Filled, ButtonStyle.Text -> null
|
ButtonStyle.Filled -> null
|
||||||
ButtonStyle.Outlined -> BorderStroke(
|
ButtonStyle.Outlined -> BorderStroke(
|
||||||
width = 1.dp,
|
width = 1.dp,
|
||||||
color = ElementTheme.colors.borderInteractiveSecondary
|
color = ElementTheme.colors.borderInteractiveSecondary
|
||||||
)
|
)
|
||||||
|
ButtonStyle.Text -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
val textStyle = when (size) {
|
val textStyle = when (size) {
|
||||||
|
|
@ -166,9 +170,10 @@ internal fun ButtonInternal(
|
||||||
ButtonSize.Large -> ElementTheme.typography.fontBodyLgMedium
|
ButtonSize.Large -> ElementTheme.typography.fontBodyLgMedium
|
||||||
}
|
}
|
||||||
|
|
||||||
val internalPadding = when {
|
val internalPadding = when (style) {
|
||||||
style == ButtonStyle.Text -> if (leadingIcon != null) PaddingValues(start = 8.dp) else PaddingValues(0.dp)
|
ButtonStyle.Filled,
|
||||||
else -> PaddingValues(horizontal = 8.dp)
|
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(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue