androidxCommonMain.com.huanshankeji.compose.material.ext.Button.androidxCommon.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compose-multiplatform-material-jvm Show documentation
Show all versions of compose-multiplatform-material-jvm Show documentation
Material Design component wrappers for Compose Multiplatform (desktop/Android and web)
The newest version!
package com.huanshankeji.compose.material.ext
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.OutlinedButton
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import com.huanshankeji.compose.material.ext.ButtonType.*
import com.huanshankeji.compose.ui.Modifier
@Suppress("NAME_SHADOWING")
@Composable
actual fun Button(
onClick: () -> Unit,
buttonType: ButtonType,
modifier: Modifier,
content: @Composable ButtonScope.() -> Unit
) {
val modifier = modifier.platformModifier
val content: @Composable RowScope.() -> Unit = { ButtonScope(this).content() }
when (buttonType) {
Contained -> androidx.compose.material.Button(onClick, modifier, content = content)
Outlined -> OutlinedButton(onClick, modifier, content = content)
Text -> TextButton(onClick, modifier, content = content)
}
}
actual class ButtonScope(val rowScope: RowScope) {
@Composable
actual fun Label(text: String) =
androidx.compose.material.Text(text)
}