SliderV2 Position in Handle now. (#214)
This commit is contained in:
@@ -11,7 +11,7 @@ import com.navi.uitron.model.data.ActionDetails
|
||||
import com.navi.uitron.model.data.UiTronAction
|
||||
|
||||
data class UpdateStateHandleAction(
|
||||
val statesMap: Map<String, String?>? = null
|
||||
val statesMap: Map<String, Any?>? = null
|
||||
) : UiTronAction() {
|
||||
override suspend fun manageAction(actionDetails: ActionDetails) {
|
||||
val action = actionDetails.uiTronAction as UpdateStateHandleAction
|
||||
|
||||
@@ -41,6 +41,8 @@ data class SliderProperty(
|
||||
sliderProperty?.tooltip?.let { tooltip = it }
|
||||
sliderProperty?.thumbView?.let { thumbView = it }
|
||||
}
|
||||
|
||||
fun getSliderPositionId() = layoutId + "_slider_position"
|
||||
}
|
||||
|
||||
data class SliderColors(
|
||||
|
||||
@@ -122,7 +122,8 @@ class SliderRendererV2(
|
||||
}
|
||||
}
|
||||
|
||||
val sliderPosition = remember { mutableStateOf(0f) }
|
||||
val sliderPosition = uiTronViewModel.handle.getStateFlow(property.getSliderPositionId(), 0f)
|
||||
.collectAsState()
|
||||
|
||||
LaunchedEffect(mvelUuid.value) {
|
||||
val stepMap = mutableMapOf<String, String>()
|
||||
@@ -136,7 +137,6 @@ class SliderRendererV2(
|
||||
)?.toFloat() ?: 0f
|
||||
val totalStep = sliderUiTronData.stepValue?.size.orVal(1) - 1
|
||||
stepToValue.value = stepMap
|
||||
sliderPosition.value = positionIndex
|
||||
steps.value = totalStep
|
||||
thumbX = sliderStart + (positionIndex / totalStep) * (sliderEnd - sliderStart)
|
||||
saveSelectionToHandle(positionIndex.toNearestInt())
|
||||
@@ -174,7 +174,7 @@ class SliderRendererV2(
|
||||
Slider(
|
||||
value = sliderPosition.value,
|
||||
onValueChange = {
|
||||
sliderPosition.value = it
|
||||
uiTronViewModel.handle[property.getSliderPositionId()] = it
|
||||
thumbX = sliderStart + (it / steps.value) * (sliderEnd - sliderStart)
|
||||
updateValuesInMvelActionOnSliderChange(
|
||||
uiTronViewModel,
|
||||
|
||||
Reference in New Issue
Block a user