This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun SingleChoiceQuestion(answers: List<Answer>) { | |
Column { | |
answers.forEach { answer -> | |
SurveyAnswer(answer = answer) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun SurveyAnswer(answer: Answer) { | |
Row { | |
Image(answer.image) | |
Text(answer.text) | |
RadioButton(false, onClick = { /* … */ }) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun ItemRow(index: Int, state: LazyListState) { | |
Column(Modifier.fillMaxWidth()) { | |
Text("Row #${index + 1}", Modifier.padding(horizontal = 8.dp)) | |
LazyRow(state = state) { | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun ItemRow(index: Int) { | |
Column(Modifier.fillMaxWidth()) { | |
Text("Row #${index + 1}", Modifier.padding(horizontal = 8.dp)) | |
key(index) { | |
LazyRow { | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun ItemRow(index: Int, state: LazyListState) { | |
DisposableEffect(Unit) { | |
println("ItemRow $index composed") | |
onDispose { println("ItemRow $index DISPOSED") } | |
} | |
Column(Modifier.fillMaxWidth()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
class ComposeItemRow @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyle: Int = 0 | |
) : AbstractComposeView(context, attrs, defStyle) { | |
// … |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
import androidx.compose.ui.platform.ViewCompositionStrategy | |
class MyComposeViewHolder( | |
val composeView: ComposeView | |
) : RecyclerView.ViewHolder(composeView) { | |
init { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
import androidx.compose.ui.platform.ComposeView | |
class MyComposeAdapter : RecyclerView.Adapter<MyComposeViewHolder>() { | |
override fun onCreateViewHolder( | |
parent: ViewGroup, | |
viewType: Int, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
class MyComposeAdapter : RecyclerView.Adapter<MyComposeViewHolder>() { | |
override fun onCreateViewHolder( | |
parent: ViewGroup, | |
viewType: Int, | |
): MyComposeViewHolder { | |
return MyComposeViewHolder(ComposeView(parent.context)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
MyAppTheme { | |
GoogleMap( | |
//… | |
) { | |
Circle( | |
center = singapore, | |
fillColor = MaterialTheme.colors.primary |