Ensure the invisible buttons have the correct size.
This commit is contained in:
parent
700d4c62af
commit
8b21efa32a
3 changed files with 27 additions and 26 deletions
|
|
@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.PaddingValues
|
|||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
|
|
@ -118,6 +119,14 @@ fun TextButton(
|
|||
leadingIcon = leadingIcon
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun InvisibleButton(
|
||||
modifier: Modifier = Modifier,
|
||||
size: ButtonSize = ButtonSize.Large,
|
||||
) {
|
||||
Spacer(modifier = modifier.height(size.toMinHeight()))
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ButtonInternal(
|
||||
text: String,
|
||||
|
|
@ -131,14 +140,7 @@ private fun ButtonInternal(
|
|||
showProgress: Boolean = false,
|
||||
leadingIcon: IconSource? = null,
|
||||
) {
|
||||
val minHeight = when (size) {
|
||||
ButtonSize.Small -> 32.dp
|
||||
ButtonSize.Medium,
|
||||
ButtonSize.MediumLowPadding -> 40.dp
|
||||
ButtonSize.Large,
|
||||
ButtonSize.LargeLowPadding -> 48.dp
|
||||
}
|
||||
|
||||
val minHeight = size.toMinHeight()
|
||||
val hasStartDrawable = showProgress || leadingIcon != null
|
||||
|
||||
val contentPadding = when (size) {
|
||||
|
|
@ -253,6 +255,14 @@ private fun ButtonInternal(
|
|||
}
|
||||
}
|
||||
|
||||
private fun ButtonSize.toMinHeight() = when (this) {
|
||||
ButtonSize.Small -> 32.dp
|
||||
ButtonSize.Medium,
|
||||
ButtonSize.MediumLowPadding -> 40.dp
|
||||
ButtonSize.Large,
|
||||
ButtonSize.LargeLowPadding -> 48.dp
|
||||
}
|
||||
|
||||
@Immutable
|
||||
sealed interface IconSource {
|
||||
val contentDescription: String?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue