TP-24954 | Resolved passing data as additional information with slider (#29)

* TP-24954 | Resolved passing data as additional information when slider moves to all uitron ids

* TP-24954 | Resolved passing data as additional information when slider moves to all uitron ids

* TP-24954 | Resolved passing data as additional information when slider moves to all uitron ids

* TP-24954 | Resolved PR comments

* TP-24954 | Resolved PR comments

* TP-24954 | Resolved PR comments

* TP-24954 | Resolved PR comments

* TP-24954 | Resolved mock issues
This commit is contained in:
rishabh patni
2023-04-20 15:15:42 +05:30
committed by GitHub Enterprise
parent d0d864a89b
commit acaab68bdf
4 changed files with 838 additions and 1 deletions

View File

@@ -409,6 +409,801 @@
}
}
},
"sliderMock": {
"data": {
"interest_text": {
"viewType": "Text",
"text": "@2.25% p.m."
},
"top_image": {
"viewType": "Image",
"iconUrl": "https://public-assets.prod.navi-tech.in/icons/navi.com/cash-loan/png/triangle-white-up.png"
},
"tenure_text": {
"viewType": "Text",
"text": "Tenure"
},
"topup_text": {
"viewType": "Text",
"text": "Topup amount"
},
"max_amount_value": {
"viewType": "Text",
"text": "INR 1,30,000.00"
},
"min_header": {
"viewType": "Text",
"text": "min"
},
"min_amount_value": {
"viewType": "Text",
"text": "INR 10,000.00"
},
"max_header": {
"viewType": "Text",
"text": "max"
},
"loanAmountSlider": {
"stepValues": [
{
"sliderDependentValue": [
{
"uitronIds": ["interest_text"],
"additionalData": "@33.50% p.m"
}
],
"rawValue": 10000,
"formattedValue": "10,000.00"
},
{
"sliderDependentValue": [
{
"uitronIds": ["interest_text"],
"additionalData": "@31.50% p.m"
}
],
"showROINudge": false,
"rawValue": 15000,
"formattedValue": "15,000.00"
},
{
"sliderDependentValue": [
{
"uitronIds": ["interest_text"],
"additionalData": "@29.50% p.m"
}
],
"showROINudge": false,
"rawValue": 20000,
"formattedValue": "20,000.00"
},
{
"sliderDependentValue": [
{
"uitronIds": ["interest_text"],
"additionalData": "@22.50% p.m"
}
],
"showROINudge": false,
"rawValue": 25000,
"formattedValue": "25,000.00"
},
{
"sliderDependentValue": [
{
"uitronIds": ["interest_text"],
"additionalData": "@20.50% p.m"
}
],
"showROINudge": false,
"rawValue": 30000,
"formattedValue": "30,000.00"
},
{
"sliderDependentValue": [
{
"uitronIds": ["interest_text"],
"additionalData": "@17.50% p.m"
}
],
"showROINudge": false,
"rawValue": 35000,
"formattedValue": "35,000.00"
}
],
"viewType": "Slider",
"selectedRawValue": "130000"
},
"tenureSlider": {
"stepValues": [
{
"rawValue": 3,
"formattedValue": "45,255"
},
{
"rawValue": 6,
"formattedValue": "23,339"
},
{
"rawValue": 9,
"formattedValue": "16,054"
},
{
"rawValue": 12,
"formattedValue": "12,419"
},
{
"rawValue": 15,
"formattedValue": "10,244"
},
{
"rawValue": 18,
"formattedValue": "8,799"
},
{
"rawValue": 21,
"formattedValue": "7,771"
},
{
"rawValue": 24,
"formattedValue": "7,004"
}
],
"viewType": "Slider",
"selectedRawValue": "21"
},
"slider_start_text": {
"viewType": "Text",
"text": "3"
},
"text_emi_tenure": {
"textFormatter": {
"placeholder": "{month_count}",
"textFormat": "{month_count} months"
},
"viewType": "Text",
"text": "24"
},
"slider_start_label": {
"viewType": "Text",
"text": "min"
},
"slider_end_label": {
"viewType": "Text",
"text": "max"
},
"slider_end_text": {
"viewType": "Text",
"text": "24"
},
"text_emi_amount": {
"viewType": "Text",
"text": "7,004"
}
},
"parentComposeView": [
{
"childrenViews": [
{
"childrenViews": [
{
"childrenViews": [
{
"childrenViews": [
{
"childrenViews": [
{
"childrenViews": [
{
"property": {
"padding": {
"start": 16,
"end": 16
},
"constraintLinks": {
"top": {
"margin": 8,
"viewId": "parent",
"constraint": "TOP"
},
"start": {
"margin": 0,
"viewId": "parent",
"constraint": "START"
},
"end": {
"margin": 0,
"viewId": "parent",
"constraint": "END"
}
},
"uiTronIds": [
"currencyAmount"
],
"sliderValueRange": {
"start": 0,
"end": 100
},
"sliderColors": {
"inactiveTrackColor": "#EBEBEB",
"thumbColor": "#22CD80",
"activeTickColor": "#22CD80",
"activeTrackColor": "#22CD80",
"inactiveTickColor": "#EBEBEB"
},
"viewType": "Slider",
"layoutId": "loanAmountSlider",
"steps": "6"
}
},
{
"childrenViews": [
{
"property": {
"constraintLinks": {
"top": {
"margin": 4,
"viewId": "parent",
"constraint": "TOP"
},
"start": {
"margin": 16,
"viewId": "parent",
"constraint": "START"
}
},
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 10,
"layoutId": "min_header",
"textColor": "#8F6B6B6B",
"fontWeight": "TT_REGULAR"
}
},
{
"property": {
"constraintLinks": {
"top": {
"margin": 2,
"viewId": "min_header",
"constraint": "BOTTOM"
},
"bottom": {
"margin": 2,
"viewId": "parent",
"constraint": "BOTTOM"
},
"start": {
"margin": 16,
"viewId": "parent",
"constraint": "START"
}
},
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 12,
"layoutId": "min_amount_value",
"textColor": "#6B6B6B",
"fontWeight": "TT_REGULAR"
}
},
{
"property": {
"constraintLinks": {
"top": {
"margin": 0,
"viewId": "parent",
"constraint": "TOP"
},
"end": {
"margin": 16,
"viewId": "parent",
"constraint": "END"
}
},
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 10,
"layoutId": "max_header",
"textColor": "#8F6B6B6B",
"fontWeight": "TT_REGULAR"
}
},
{
"property": {
"constraintLinks": {
"top": {
"margin": 2,
"viewId": "max_header",
"constraint": "BOTTOM"
},
"bottom": {
"margin": 2,
"viewId": "parent",
"constraint": "BOTTOM"
},
"end": {
"margin": 16,
"viewId": "parent",
"constraint": "END"
}
},
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 12,
"layoutId": "max_amount_value",
"textColor": "#6B6B6B",
"fontWeight": "TT_REGULAR"
}
}
],
"property": {
"constraintLinks": {
"top": {
"margin": 0,
"viewId": "loanAmountSlider",
"constraint": "BOTTOM"
},
"bottom": {
"margin": 16,
"viewId": "parent",
"constraint": "BOTTOM"
},
"start": {
"margin": 0,
"viewId": "parent",
"constraint": "START"
}
},
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "min_max_holder",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "rowOne",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"elevation": 0,
"backgroundColor": "#FFFFFF",
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "cardOne",
"height": "WRAP_CONTENT",
"constraintLinks": {
"top": {
"margin": 16,
"viewId": "parent",
"constraint": "TOP"
},
"start": {
"viewId": "parent",
"constraint": "START"
},
"end": {
"viewId": "parent",
"constraint": "END"
}
}
}
},
{
"childrenViews": [
{
"childrenViews": [
{
"childrenViews": [
{
"childrenViews": [
{
"childrenViews": [
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 14,
"layoutId": "text_emi_amount",
"textColor": "#191919",
"fontWeight": "BOLD",
"isStateFul": true
}
},
{
"childrenViews": [
{
"property": {
"padding": {
"top": 4,
"bottom": 4,
"start": 8,
"end": 8
},
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 10,
"layoutId": "text_emi_tenure",
"textColor": "#F0F5FC",
"fontWeight": "BOLD",
"isStateFul": true
}
}
],
"property": {
"backgroundColor": "#011A48",
"shape": {
"shapeType": "RoundedCornerShape",
"size": 8
},
"viewType": "Row",
"width": "WRAP_CONTENT",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"padding": {
"top": 16,
"start": 16,
"end": 16
},
"viewType": "Row",
"width": "MATCH_PARENT",
"arrangementData": {
"arrangementType": "SpaceBetween"
},
"height": "WRAP_CONTENT"
}
},
{
"property": {
"padding": {
"top": 8,
"start": 16,
"end": 16
},
"uiTronRawValueIds": [
"text_emi_tenure"
],
"uiTronIds": [
"text_emi_amount"
],
"sliderValueRange": {
"start": 3,
"end": 24
},
"sliderColors": {
"inactiveTrackColor": "#EBEBEB",
"thumbColor": "#22CD80",
"activeTickColor": "#22CD80",
"activeTrackColor": "#22CD80",
"inactiveTickColor": "#EBEBEB"
},
"viewType": "Slider",
"width": "MATCH_PARENT",
"layoutId": "tenureSlider",
"steps": 7,
"height": "WRAP_CONTENT"
}
},
{
"childrenViews": [
{
"childrenViews": [
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 10,
"layoutId": "slider_start_lable",
"textColor": "#6B6B6B",
"fontWeight": "REGULAR"
}
},
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 12,
"layoutId": "slider_start_text",
"textColor": "#6B6B6B"
}
}
],
"property": {
"horizontalAlignment": "Start",
"viewType": "Column",
"width": "WRAP_CONTENT",
"layoutId": "column_slider_start",
"height": "WRAP_CONTENT"
}
},
{
"childrenViews": [
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 10,
"layoutId": "slider_end_lable",
"textColor": "#6B6B6B"
}
},
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"fontSize": 12,
"layoutId": "slider_end_text",
"textColor": "#6B6B6B"
}
}
],
"property": {
"horizontalAlignment": "End",
"viewType": "Column",
"width": "WRAP_CONTENT",
"layoutId": "column_slider_end",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"padding": {
"bottom": 16,
"start": 16,
"end": 16
},
"viewType": "Row",
"width": "MATCH_PARENT",
"arrangementData": {
"arrangementType": "SpaceBetween"
},
"layoutId": "row_emi_slider_1",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"horizontalAlignment": "Start",
"viewType": "Column",
"width": "MATCH_PARENT",
"layoutId": "column_emi_slider",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"elevation": 0,
"padding": {
"top": 2,
"bottom": 2,
"start": 2,
"end": 2
},
"backgroundColor": "#FFFFFF",
"visible": true,
"statesMap": {
"select": {
"visible": true,
"viewType": "Card"
},
"unselect": {
"visible": false,
"viewType": "Card"
}
},
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "card_customise_emi",
"height": "WRAP_CONTENT",
"isStateFul": true
}
}
],
"property": {
"constraintLinks": {
"top": {
"margin": 16,
"viewId": "parent",
"constraint": "TOP"
},
"start": {
"viewId": "parent",
"constraint": "START"
},
"end": {
"viewId": "parent",
"constraint": "END"
}
},
"horizontalAlignment": "Start",
"viewType": "Column",
"width": "MATCH_PARENT",
"layoutId": "column_emi_slider",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "constraint_emi_slider",
"height": "WRAP_CONTENT",
"constraintLinks": {
"top": {
"margin": 16,
"viewId": "cardOne",
"constraint": "BOTTOM"
},
"start": {
"viewId": "parent",
"constraint": "START"
},
"end": {
"viewId": "parent",
"constraint": "END"
}
}
}
},
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"width": "WRAP_CONTENT",
"fontSize": 12,
"layoutId": "tenure_text",
"textColor": "#6B6B6B",
"fontWeight": "TT_REGULAR",
"height": "WRAP_CONTENT",
"constraintLinks": {
"top": {
"margin": 16,
"viewId": "cardOne",
"constraint": "BOTTOM"
},
"start": {
"margin": 16,
"viewId": "parent",
"constraint": "START"
}
}
}
},
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"width": "WRAP_CONTENT",
"fontSize": 12,
"layoutId": "topup_text",
"textColor": "#6B6B6B",
"fontWeight": "TT_REGULAR",
"height": "WRAP_CONTENT",
"constraintLinks": {
"start": {
"margin": 16,
"viewId": "parent",
"constraint": "START"
},
"top": {
"margin": 16,
"viewId": "parent",
"constraint": "TOP"
}
}
}
},
{
"property": {
"fontFamily": "ttComposeFontFamily",
"viewType": "Text",
"width": "WRAP_CONTENT",
"fontSize": 12,
"layoutId": "interest_text",
"isStateFul": true,
"textColor": "#6B6B6B",
"fontWeight": "TT_REGULAR",
"height": "WRAP_CONTENT",
"constraintLinks": {
"end": {
"margin": 16,
"viewId": "parent",
"constraint": "END"
},
"top": {
"margin": 16,
"viewId": "parent",
"constraint": "TOP"
}
}
}
}
],
"property": {
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "rowOne",
"height": "WRAP_CONTENT"
}
}
],
"property": {
"elevation": 0,
"backgroundColor": "#FFFFFF",
"borderStrokeData": {
"color": "#EBEBEB",
"width": 1
},
"shape": {
"shapeType": "RoundedCornerShape",
"size": 8
},
"viewType": "Card",
"width": "MATCH_PARENT",
"layoutId": "cardOne",
"height": "WRAP_CONTENT",
"constraintLinks": {
"top": {
"margin": 16,
"viewId": "parent",
"constraint": "TOP"
}
}
}
},
{
"property": {
"viewType": "Image",
"width": "WRAP_CONTENT",
"layoutId": "top_image",
"height": "WRAP_CONTENT",
"constraintLinks": {
"top": {
"margin": 5,
"viewId": "parent",
"constraint": "TOP"
},
"start": {
"viewId": "parent",
"constraint": "START"
},
"end": {
"viewId": "parent",
"constraint": "END"
}
}
}
}
],
"property": {
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "root_cl",
"height": "WRAP_CONTENT",
"padding": {
"start": 16,
"end": 16
}
}
}
],
"property": {
"viewType": "ConstraintLayout",
"width": "MATCH_PARENT",
"layoutId": "main_view",
"height": "WRAP_CONTENT"
}
}
]
},
"dobMock": {
"parentComposeView": [
{

View File

@@ -23,10 +23,18 @@ data class UiTronSliderData(
) : UiTronData()
data class StepValue(
@Deprecated("use sliderDependentValue for passing values")
val formattedValue: String? = null,
val sliderDependentValue: List<SliderDependentValue>? = null,
@Deprecated("use sliderDependentValue for passing values")
val rawValue: String? = null
)
data class SliderDependentValue(
val uitronIds: List<String>? = null,
val additionalData: String? = null
)
@Parcelize
data class UiTronSliderWrapper(
val sliderValue: Float? = null

View File

@@ -24,6 +24,7 @@ import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.unit.dp
import com.navi.uitron.model.data.SliderDependentValue
import com.navi.uitron.model.data.StepValue
import com.navi.uitron.model.data.UiTronData
import com.navi.uitron.model.data.UiTronSliderData
@@ -150,10 +151,17 @@ class SliderRenderer :
if (sliderUiTronData?.stepValues.isNullOrEmpty()
.not()
) stepValue?.formattedValue else sliderPosition.value.toString()
val sliderDependentValue: List<SliderDependentValue>? =
if (sliderUiTronData?.stepValues.isNullOrEmpty()
.not()
) stepValue?.sliderDependentValue else null
uiTronViewModel.onSliderValueChangeFinished(
property.layoutId.orEmpty(),
sliderRawValue,
sliderFormattedValue,// can be replaced by value to be emitted if mapping is coming
sliderFormattedValue, // can be replaced by value to be emitted if mapping is coming
sliderDependentValue,
property.uiTronIds.orEmpty()
)
},
@@ -228,10 +236,17 @@ class SliderRenderer :
if (sliderUiTronData?.stepValues.isNullOrEmpty()
.not()
) stepValue?.formattedValue else sliderPosition.value.toString()
val sliderDependentValue: List<SliderDependentValue>? =
if (sliderUiTronData?.stepValues.isNullOrEmpty()
.not()
) stepValue?.sliderDependentValue else null
uiTronViewModel.onSliderValueProgressChanged(
property.layoutId.orEmpty(),
sliderRawValue,
sliderFormattedValue,// can be replaced by value to be emitted if mapping is coming
sliderDependentValue,
property.uiTronIds.orEmpty(),
property.uiTronRawValueIds.orEmpty()
)

View File

@@ -10,6 +10,7 @@ package com.navi.uitron.viewmodel
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.navi.uitron.model.data.SliderDependentValue
import com.navi.uitron.model.data.TextFieldInputWrapper
import com.navi.uitron.model.data.UiTronAction
import com.navi.uitron.model.data.UiTronActionData
@@ -68,6 +69,7 @@ open class UiTronViewModel constructor(
layoutId: String,
sliderRawValue: String?,
sliderFormattedValue: String?,
sliderDependentValue: List<SliderDependentValue>?,
uiTronFormattedValueIds: List<String>,
uiTronRawValueIds: List<String>
) {
@@ -88,6 +90,13 @@ open class UiTronViewModel constructor(
)
}
}
sliderDependentValue?.forEach {
it.uitronIds?.forEach { uitronId -> handle[uitronId] = handle.getStateFlow(uitronId, TextFieldInputWrapper()).value.copy(
inputText = it.additionalData,
hasError = false
)
}
}
sliderRawValue?.let {
_sliderProgressFlow.emit(Triple(layoutId, sliderRawValue, sliderFormattedValue))
}
@@ -99,6 +108,7 @@ open class UiTronViewModel constructor(
layoutId: String,
sliderRawValue: String?,
sliderFormattedValue: String?,
sliderDependentValue: List<SliderDependentValue>?,
uiTronIds: List<String>
) {
viewModelScope.launch {
@@ -110,6 +120,15 @@ open class UiTronViewModel constructor(
)
}
}
sliderDependentValue?.forEach {
it.uitronIds?.forEach { uitronId ->
handle[uitronId] =
handle.getStateFlow(uitronId, TextFieldInputWrapper()).value.copy(
inputText = it.additionalData,
hasError = false
)
}
}
sliderRawValue?.let {
_sliderFinishedFlow.emit(Triple(layoutId, sliderRawValue, sliderFormattedValue))
}