Skip to content

Commit

Permalink
Improve modeling of button
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolegeorgieva committed Nov 28, 2024
1 parent 3bcb0b1 commit e176ee4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions composeApp/src/commonMain/kotlin/component/button/IvyButton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

sealed interface ButtonStyle {
data class FilledButton(val state: ButtonState) : ButtonStyle
data class OutlinedButton(val state: ButtonState) : ButtonStyle
sealed interface ButtonAppearance {
val style: ButtonStyle

data class Filled(override val style: ButtonStyle): ButtonAppearance
data class Outlined(override val style: ButtonStyle): ButtonAppearance
data class Text(override val style: ButtonStyle): ButtonAppearance
}

enum class ButtonState {
PrimaryVariant,
SecondaryVariant,
Success,
Error
enum class ButtonStyle {
Primary,
Secondary,
Neutral
}

@Composable
fun IvyButton(
style: ButtonStyle,
appearance: ButtonAppearance,
modifier: Modifier = Modifier,
enabled: Boolean = true,
text: String? = null,
text: @Composable (() -> Unit)? = null,
icon: @Composable (() -> Unit)? = null,
iconRight: @Composable (() -> Unit)? = null,
onClick: () -> Unit,
Expand Down
4 changes: 2 additions & 2 deletions composeApp/src/commonMain/kotlin/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ val MaterialTheme.colorsExt: ExtendedColors
ExtendedColors(
success = Green,
onSuccess = Color.White,
backgroundVariant = Dark,
backgroundVariant = LightGray,
onBackgroundVariant = Color.White,
)
} else {
ExtendedColors(
success = Green,
onSuccess = Color.White,
backgroundVariant = Light,
backgroundVariant = DarkGray,
onBackgroundVariant = Color.Black,
)
}
Expand Down

0 comments on commit e176ee4

Please sign in to comment.