I am using dev17 and the format function isn’t an @Compose function hence this value does not update:
Copy code
val mDataModel = remember {dataModel}
ui.TextLabelStyled(
text = "%.1f".format(mDataModel.value),
color = mDataModel.targetColor,
fontSize = valueFontSize,
modifier = Modifier
)
Is there a workaround?
g
gildor
08/25/2020, 3:25 AM
how do you update
dataModel
?
g
Guy Bieber
08/25/2020, 4:56 PM
I change dataModel.value. Here is the dataModel definition:
Copy code
class BasicStatusDataModel<T> (
var state: ControlState = ControlState(), // already mutable
targetColor : Color = nikolaColors.color3, // wrapped mutable
val transitionTimeoutMs : Long = 2*1000,
name : String = "", // wrapped mutable
value : T, // wrapped mutable
unit : String = "", // wrapped mutable
showActive : Boolean = false // wrapped mutable
) {
var targetColor by mutableStateOf(targetColor)
var name by mutableStateOf(name)
var value by mutableStateOf(value)
var unit by mutableStateOf(unit)
var showActive by mutableStateOf(showActive)
Guy Bieber
08/25/2020, 4:57 PM
Does the whole dataModel need to be wrapped as a mutable.
Guy Bieber
08/25/2020, 4:57 PM
I really miss @Model. This latest change has been a bit of a nightmare.