Skip to content

Instantly share code, notes, and snippets.

@saurabharora90
Last active November 5, 2023 13:55
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 saurabharora90/f1fc38b795020f0f8768fb9eb923f3e8 to your computer and use it in GitHub Desktop.
Save saurabharora90/f1fc38b795020f0f8768fb9eb923f3e8 to your computer and use it in GitHub Desktop.
Derived State of Blog Example
@Composable
private fun PostHashtags(
hashtags: ImmutableList<String>,
onAddHashTag: (String) -> Unit,
modifier: Modifier
) {
var inputHashTag by remember(hashtags) { mutableStateOf("") }
Column(modifier = modifier) {
OutlinedTextField(
value = inputHashTag,
onValueChange = { inputHashTag = it },
leadingIcon = { Text(text = "#", fontWeight = FontWeight.Bold) },
placeholder = { Text(text = "Type a hashtag here") },
trailingIcon = {
IconButton(onClick = { onAddHashTag(inputHashTag) }) {
Icon(imageVector = Icons.Default.AddCircle,
contentDescription = "Add hashtag")
}
},
)
ReusableVerticalLazyList(content = hashtags)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment