Skip to content

Commit

Permalink
[ANDROAPP-5800] provide icons based on valueType
Browse files Browse the repository at this point in the history
  • Loading branch information
andresmr committed Feb 14, 2024
1 parent 7c9a9b5 commit bec2f4a
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package org.dhis2.usescases.searchTrackEntity.searchparameters.provider

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.AddCircleOutline
import androidx.compose.material.icons.outlined.QrCode
import androidx.compose.material.icons.outlined.QrCode2
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.graphics.vector.ImageVector
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.form.model.FieldUiModel
import org.dhis2.form.model.UiRenderType
import org.dhis2.form.ui.provider.inputfield.FieldProvider
import org.hisp.dhis.android.core.common.ValueType
import org.hisp.dhis.mobile.ui.designsystem.component.InputStyle
import org.hisp.dhis.mobile.ui.designsystem.component.parameter.model.ParameterSelectorItemModel

Expand All @@ -33,6 +40,7 @@ fun provideParameterSelectorItem(
}

return ParameterSelectorItemModel(
icon = provideIcon(fieldUiModel.valueType, fieldUiModel.renderingType),
label = fieldUiModel.label,
helper = "Optional",
inputField = {
Expand All @@ -53,3 +61,21 @@ fun provideParameterSelectorItem(
},
)
}

private fun provideIcon(valueType: ValueType?, renderingType: UiRenderType?): ImageVector =
when (valueType) {
ValueType.TEXT -> {
when (renderingType) {
UiRenderType.QR_CODE, UiRenderType.GS1_DATAMATRIX -> {
Icons.Outlined.QrCode2
}
UiRenderType.BAR_CODE -> {
Icons.Outlined.QrCode
}
else -> {
Icons.Outlined.AddCircleOutline
}
}
}
else -> Icons.Outlined.AddCircleOutline
}

0 comments on commit bec2f4a

Please sign in to comment.