Add ButtonIcon atom

This commit is contained in:
Wolf-Martell Montwé 2023-05-23 16:42:26 +02:00
parent d6f49b4919
commit 96b1fc2eb5
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
2 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,41 @@
package app.k9mail.core.ui.compose.designsystem.atom.button
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.theme.Icons
import app.k9mail.core.ui.compose.theme.MainTheme
import androidx.compose.material.IconButton as MaterialIconButton
@Composable
fun ButtonIcon(
onClick: () -> Unit,
imageVector: ImageVector,
modifier: Modifier = Modifier,
enabled: Boolean = true,
contentDescription: String? = null,
) {
MaterialIconButton(
onClick = onClick,
modifier = modifier,
enabled = enabled,
) {
Icon(
modifier = Modifier.size(MainTheme.sizes.icon),
imageVector = imageVector,
contentDescription = contentDescription,
)
}
}
@Preview
@Composable
internal fun ButtonIconPreview() {
ButtonIcon(
onClick = { },
imageVector = Icons.Filled.user,
)
}

View file

@ -14,6 +14,8 @@ data class Sizes(
val larger: Dp = 128.dp,
val huge: Dp = 256.dp,
val huger: Dp = 384.dp,
val icon: Dp = 24.dp,
)
internal val LocalSizes = staticCompositionLocalOf { Sizes() }