Skip to content

Commit

Permalink
ANDROAPP-5721-mobile-ui-Supporting-text-visual-improvements-animations (
Browse files Browse the repository at this point in the history
#166)

* animate `InputShell` content

This will animate the visibility of supporting text and other composable contents used inside `InputShell`

* update `InputRadioButtonScreen` to test animation

button added to show supporting text visibility with animation

* fix lint error

---------

Co-authored-by: Siddharth Agarwal <[email protected]>
  • Loading branch information
siddh1004 and Siddharth Agarwal authored Dec 22, 2023
1 parent 03fad51 commit 4bebbcd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fun App() {

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

Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import org.hisp.dhis.common.screens.previews.lorem
import org.hisp.dhis.mobile.ui.designsystem.component.Button
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputRadioButton
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.Orientation
import org.hisp.dhis.mobile.ui.designsystem.component.RadioButtonData
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextData
import org.hisp.dhis.mobile.ui.designsystem.component.SupportingTextState
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing

@Composable
Expand Down Expand Up @@ -67,7 +71,12 @@ fun InputRadioButtonScreen() {
var selectedItemHorizontal by remember {
mutableStateOf<RadioButtonData?>(radioButtonDataItemsHorizontal[0])
}
var showSupportingText by remember { mutableStateOf(false) }
ColumnComponentContainer("Radio Buttons") {
Button(text = "Click to show/Hide supporting text") {
showSupportingText = !showSupportingText
}

SubTitle("Vertical")
InputRadioButton(
title = "Label",
Expand All @@ -77,6 +86,14 @@ fun InputRadioButtonScreen() {
selectedItemVertical = it
},
state = InputShellState.UNFOCUSED,
supportingText = if (showSupportingText) {
listOf(
SupportingTextData("Required", state = SupportingTextState.ERROR),
SupportingTextData(lorem + lorem + lorem, state = SupportingTextState.WARNING),
)
} else {
emptyList()
},
)
Spacer(Modifier.size(Spacing.Spacing18))
InputRadioButton(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hisp.dhis.mobile.ui.designsystem.component

import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -62,7 +63,12 @@ fun InputShell(
isRequiredField: Boolean = false,
modifier: Modifier = Modifier,
) {
Column(modifier = modifier.fillMaxWidth().clip(shape = RoundedCornerShape(Radius.XS, Radius.XS))) {
Column(
modifier = modifier
.fillMaxWidth()
.clip(shape = RoundedCornerShape(Radius.XS, Radius.XS))
.animateContentSize(),
) {
var indicatorColor by remember(state) { mutableStateOf(state.color) }
var indicatorThickness by remember { mutableStateOf(Border.Thin) }
val backgroundColor = if (state != InputShellState.DISABLED) SurfaceColor.Surface else SurfaceColor.DisabledSurface
Expand Down

0 comments on commit 4bebbcd

Please sign in to comment.