I have a row and a list and create my list of imag...
# compose
a
I have a row and a list and create my list of image with a foreach so i change alpha value of one image and image doesn’t change. I write cose in thread
Copy code
var toolState = viewModel.toolState.collectAsState().value
Copy code
data class ToolPageState(
  var mainFunctionList : MutableList<ToolFunction> = mutableListOf<ToolFunction>()
)
data class ToolFunction(var num :Int, var alpha: Float = 1f)
in screen:
Copy code
ToolsButtons(modifier = Modifier, pageState.mainFunctionList){ function ->
  
}
@Composable
fun BoxScope.ToolsButtons(
    modifier: Modifier = Modifier,
    functionList: MutableList<ToothFunction>,
    onSelectToolFeature: (function: ToolFunction) -> Unit
) {
    Row(
        modifier = modifier
            .fillMaxWidth()
            .background(GreyLight).
                padding(start = 30.dp, end = 30.dp)
            .height(100.dp)
            .align(
                Alignment.BottomCenter
            ),
        horizontalArrangement = Arrangement.SpaceBetween,
        verticalAlignment = Alignment.CenterVertically
    ) {
        functionList.forEach{
            ToolButton(it) { function ->
                onSelectToolFeature(function)
            }
        }
    }
}
fun  ToolButton(toolFunc: ToolFunction, onSelectButton: (toolFunc: ToolFunction) -> Unit) {
   
    Image(
        modifier = Modifier.alpha(toolFunc.alpha)
In viewModel
Copy code
fun onSelectToothFeature(function: ToolFunction) {
    mainFunctionList[2].alpha = 0.4f
    updateButtonFunctionList()

}
private fun updateButtonFunctionList(){
    uiState.value = uiState.value.copy(
        mainFunctionList = mainFunctionList
    )
}
when i change the alpha value for a single item.. composition is not called
it could be normal because list doesn’t change but only an item… so how can i change alpha image when an item has change the alpha value of data class
I used a lazyrow but the result does’t change
Copy code
@Composable
fun BoxScope.ToolsButtons(
    modifier: Modifier = Modifier,
    functionList: MutableList<ToolFunction>,
    onSelectToolFeature: (function: ToothFunction) -> Unit
) {

    LazyRow(modifier = modifier.fillMaxWidth().height(100.dp).background(GreyLight).
    padding(start = 30.dp, end = 30.dp) .align(
        Alignment.BottomCenter
    ),
        horizontalArrangement = Arrangement.SpaceBetween,
        verticalAlignment = Alignment.CenterVertically) {
        items(functionList) { item ->
            ToolButton(item) { function ->
               onSelectToolFeature(function)
            }
        }
    }
i resolved , i create
Copy code
var functionList by mutableStateOf(mainFunctionList)
e screen gets the list from viewModel directly