I'd like to create single select or multi select buttons.
c
I'd like to create single select or multi select buttons.
I am using this composable function in the screen.
Copy code
@Composable
fun QuestionField(
    title: String,
    answerType: Question.SurveyType,
    choiceList: List<BChoice>,
    onAnswer: (HashMap<String, String>) -> Unit,
    modifier: Modifier = Modifier
) {
    Log.d("aos", "choiceList: $choiceList")
    var choices by remember { mutableStateOf(choiceList) }
    Log.d("aos", "choices: $choices")
    ...
}
If I don't use
Copy code
var choices by remember { mutableStateOf(choiceList) }
this part, then, it prints. but if I use this, even the first debug log isn't printed. Why is that? And here's the button part in the function to reassign the choices data to make it recomposable.
Copy code
onNotifyButtonState = { index, isChecked ->
                        choices = choices.mapIndexed { idx, bChoice ->
                            if (idx != index) {
                                choice.copy(isChecked = false)
                            }
                            choice
                        }
                        Log.d("aos", "list: $choiceList")
                    },
                    modifier = Modifier
                        .width(166.dp)
                        .height(80.dp)
                        .clickable {
                            onAnswer.invoke(hashMapOf(ANSWER_REF to "${choice.aRef}"))
                        }
1. single select type -> when an item is clicked then, other items' isCheck state must turn into false, 2. multi select type -> it doesn't care other items. But need to get the selected items' data.