Skip to content

Commit

Permalink
add colorStyle to button component
Browse files Browse the repository at this point in the history
`ColorStyle` parameter added to button component with two values DEFAULT, ERROR
  • Loading branch information
Siddharth Agarwal committed Jan 17, 2024
1 parent cecfbce commit f55ddc6
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 265 deletions.
4 changes: 1 addition & 3 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import org.hisp.dhis.common.screens.SectionScreen
import org.hisp.dhis.common.screens.SupportingTextScreen
import org.hisp.dhis.common.screens.SwitchScreen
import org.hisp.dhis.common.screens.TagsScreen
import org.hisp.dhis.common.screens.WarningButtonScreen
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing

Expand All @@ -93,7 +92,7 @@ fun App() {

@Composable
fun Main() {
val currentScreen = remember { mutableStateOf(Components.WARNING_BUTTON) }
val currentScreen = remember { mutableStateOf(Components.BUTTON) }
var expanded by remember { mutableStateOf(false) }

Column(
Expand Down Expand Up @@ -141,7 +140,6 @@ fun Main() {

when (currentScreen.value) {
Components.BUTTON -> ButtonScreen()
Components.WARNING_BUTTON -> WarningButtonScreen()
Components.ICON_BUTTON -> IconButtonScreen()
Components.FORMS_COMPONENTS -> FormsComponentsScreen()
Components.RADIO -> RadioButtonScreen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.ui.Modifier
import org.hisp.dhis.common.screens.previews.ButtonPreview
import org.hisp.dhis.common.screens.previews.ButtonPreviewWithIcon
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle
import org.hisp.dhis.mobile.ui.designsystem.component.ColorStyle
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.RowComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle
Expand Down Expand Up @@ -81,5 +82,71 @@ fun ButtonScreen() {
ButtonPreviewWithIcon("Label", ButtonStyle.KEYBOARDKEY)
ButtonPreviewWithIcon("Label", ButtonStyle.KEYBOARDKEY, false)
}

Title("Error Buttons")
SubTitle("Filled")
RowComponentContainer() {
ButtonPreview("Label", ButtonStyle.FILLED, true, ColorStyle.ERROR)
ButtonPreview("Label", ButtonStyle.FILLED, false, ColorStyle.ERROR)
}
RowComponentContainer {
ButtonPreviewWithIcon("Label", ButtonStyle.FILLED, true, ColorStyle.ERROR)
ButtonPreviewWithIcon("Label", ButtonStyle.FILLED, false, ColorStyle.ERROR)
}

Spacer(Modifier.size(Spacing.Spacing18))
SubTitle("Outlined")
RowComponentContainer() {
ButtonPreview("Label", ButtonStyle.OUTLINED, true, ColorStyle.ERROR)
ButtonPreview("Label", ButtonStyle.OUTLINED, false, ColorStyle.ERROR)
}
RowComponentContainer() {
ButtonPreviewWithIcon("Label", ButtonStyle.OUTLINED, true, ColorStyle.ERROR)
ButtonPreviewWithIcon("Label", ButtonStyle.OUTLINED, false, ColorStyle.ERROR)
}
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Text")
RowComponentContainer() {
ButtonPreview("Label", ButtonStyle.TEXT, true, ColorStyle.ERROR)
ButtonPreview("Label", ButtonStyle.TEXT, false, ColorStyle.ERROR)
}
RowComponentContainer() {
ButtonPreviewWithIcon("Label", ButtonStyle.TEXT, true, ColorStyle.ERROR)
ButtonPreviewWithIcon("Label", ButtonStyle.TEXT, false, ColorStyle.ERROR)
}
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Elevated")
RowComponentContainer() {
ButtonPreview("Label", ButtonStyle.ELEVATED, true, ColorStyle.ERROR)
ButtonPreview("Label", ButtonStyle.ELEVATED, false, ColorStyle.ERROR)
}
RowComponentContainer() {
ButtonPreviewWithIcon("Label", ButtonStyle.ELEVATED, true, ColorStyle.ERROR)
ButtonPreviewWithIcon("Label", ButtonStyle.ELEVATED, false, ColorStyle.ERROR)
}
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Tonal")
RowComponentContainer() {
ButtonPreview("Label", ButtonStyle.TONAL, true, ColorStyle.ERROR)
ButtonPreview("Label", ButtonStyle.TONAL, false, ColorStyle.ERROR)
}
RowComponentContainer() {
ButtonPreviewWithIcon("Label", ButtonStyle.TONAL, true, ColorStyle.ERROR)
ButtonPreviewWithIcon("Label", ButtonStyle.TONAL, false, ColorStyle.ERROR)
}
Spacer(Modifier.size(Spacing.Spacing18))

SubTitle("Keyboard")
RowComponentContainer() {
ButtonPreview("Label", ButtonStyle.KEYBOARDKEY, true, ColorStyle.ERROR)
ButtonPreview("Label", ButtonStyle.KEYBOARDKEY, false, ColorStyle.ERROR)
}
RowComponentContainer() {
ButtonPreviewWithIcon("Label", ButtonStyle.KEYBOARDKEY, true, ColorStyle.ERROR)
ButtonPreviewWithIcon("Label", ButtonStyle.KEYBOARDKEY, false, ColorStyle.ERROR)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.hisp.dhis.common.screens
enum class Components(val label: String) {
ICON_BUTTON("Icon Button"),
BUTTON("Button"),
WARNING_BUTTON("Warning Button"),
FORM_SHELLS("Form Shells"),
INPUT_TEXT("Input Text"),
INPUT_LONG_TEXT("Input Long Text"),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,35 @@ import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import org.hisp.dhis.mobile.ui.designsystem.component.Button
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonStyle
import org.hisp.dhis.mobile.ui.designsystem.component.ColorStyle

@Composable
internal fun ButtonPreview(text: String, style: ButtonStyle = ButtonStyle.OUTLINED, enabled: Boolean = true) {
internal fun ButtonPreview(
text: String,
style: ButtonStyle = ButtonStyle.OUTLINED,
enabled: Boolean = true,
colorStyle: ColorStyle = ColorStyle.DEFAULT,
) {
Button(
enabled = enabled,
style,
text,
style = style,
colorStyle = colorStyle,
text = text,
) { }
}

@Composable
internal fun ButtonPreviewWithIcon(text: String, style: ButtonStyle = ButtonStyle.OUTLINED, enabled: Boolean = true) {
internal fun ButtonPreviewWithIcon(
text: String,
style: ButtonStyle = ButtonStyle.OUTLINED,
enabled: Boolean = true,
colorStyle: ColorStyle = ColorStyle.DEFAULT,
) {
Button(
enabled = enabled,
style,
text,
style = style,
colorStyle = colorStyle,
text = text,
icon = {
Icon(
imageVector = Icons.Filled.Add,
Expand Down
Loading

0 comments on commit f55ddc6

Please sign in to comment.