colintheshots
03/21/2022, 9:55 PMRafs
03/21/2022, 9:56 PMderivedStateOf
https://developer.android.com/jetpack/compose/side-effects#derivedstateofmyanmarking
03/21/2022, 9:59 PMAlex Vanyo
03/21/2022, 11:20 PMMutableStates
into one, what do you mean exactly?
Do you want to compute some other state based on two input states?myanmarking
03/22/2022, 12:07 AMZach Klippenstein (he/him) [MOD]
03/22/2022, 3:57 PMZach Klippenstein (he/him) [MOD]
03/22/2022, 3:59 PMMutableState
to communicate about events, `Flow`s are much better suited to that.colintheshots
03/22/2022, 4:04 PMZach Klippenstein (he/him) [MOD]
03/22/2022, 4:38 PMvar mainText by remember { mutableStateOf(TextFieldValue("")) }
var editingLink by remember { mutableStateOf(false) }
var linkText by remember { mutableStateOf("") }
if (editingLink) {
TextField(
linkText,
…,
imeAction = {
editingLink = false
mainText = mainText.copy(/* insert linkText at selection position */)
}
)
} else {
TextField(
mainText,
…,
)
// Some event handler that sets editingLink to true
}
colintheshots
03/22/2022, 8:06 PMZach Klippenstein (he/him) [MOD]
03/23/2022, 5:45 PMcolintheshots
03/23/2022, 6:57 PM