Merge pull request #3832 from element-hq/feature/bma/waitingtoMatch

Disable button during the "verifying" step.
This commit is contained in:
Benoit Marty 2024-11-08 14:07:38 +01:00 committed by GitHub
commit cf9dbc60f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 62 additions and 54 deletions

View file

@ -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?