Skip to content

Instantly share code, notes, and snippets.

@arriolac
Created September 21, 2022 12:30
Show Gist options
  • Save arriolac/e5f562d35c11d824a79fafa424f6bac1 to your computer and use it in GitHub Desktop.
Save arriolac/e5f562d35c11d824a79fafa424f6bac1 to your computer and use it in GitHub Desktop.
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
// Initialize selectedAnswer to null since no answer will be selected at first
var selectedAnswer: MutableState<Answer?> =
mutableStateOf(null)
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer.value == answer),
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment