Skip to content

Instantly share code, notes, and snippets.

@tolgaprm
Last active January 16, 2024 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolgaprm/9819e32766776df165b078c282cc3c75 to your computer and use it in GitHub Desktop.
Save tolgaprm/9819e32766776df165b078c282cc3c75 to your computer and use it in GitHub Desktop.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Stability_ImmutabilityTheme {
val (isChecked, onChecked) = remember { mutableStateOf(false) }
Column(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background),
) {
Checkbox(
checked = isChecked,
onCheckedChange = onChecked
)
ContactList(
contactListState = ContactListState(
names = listOf("name1", "name2", "name3", "name4"),
)
)
}
}
}
}
}
@Composable
fun ContactList(
contactListState: ContactListState
) {
if (contactListState.isLoading) {
CircularProgressIndicator()
} else {
Text(text = contactListState.names.toString())
}
}
data class ContactListState(
val names: List<String>,
val isLoading: Boolean = false,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment