Lilly
05/11/2022, 1:12 AMSnapshotStateMap<String, Any>
and storing the value in a state object:
// viewmodel content
private val state: SnapshotStateMap<String, Any> = mutableStateMapOf()
var myState by mutableStateOf(StateObject(state.getValue("key")))
@Immutable
data class StateObject(val value: Any)
I'm changing the values by bubbling up a onValueChange
event that accesses state
like state["key"] = newValue. But when I use for example a Slider
composable and onValueChange
is triggered, the Slider does not reflect the change, although I can print the new values. I guess storing the value in a state object as intermediate step is the problem. Is this intended or do I miss something here?Icyrockton
05/11/2022, 2:21 AMComposable
component , which is helpful to visualize relationships between different UI elementsColton Idle
05/11/2022, 2:24 AMremember{}
is needed? Code in threadMarcin Wisniowski
05/11/2022, 11:05 AMTodor Grudev
05/11/2022, 12:55 PMTextField
- it feels like previously was the default behaviour, but I think with Compose it is not :?Patrick Kellison
05/11/2022, 1:36 PMLilly
05/11/2022, 1:37 PM@Preview
functions private to avoid polluting code completion might be useful?!Joseph Hawkes-Cates
05/11/2022, 2:59 PMSatyam G
05/11/2022, 3:08 PMmertceyhan
05/11/2022, 3:25 PMPHondogo
05/11/2022, 3:58 PMColton Idle
05/11/2022, 7:16 PMSam
05/11/2022, 8:40 PMaccompanist v0.24.8-beta
to drop 🙃Ben Trengrove [G]
05/11/2022, 9:23 PMFudge
05/11/2022, 9:27 PMhttps://youtu.be/qBkyU1TJKDg?t=2529▾
https://youtu.be/qBkyU1TJKDg?t=1249▾
Alex
05/12/2022, 7:59 AMColumn
inside of a Surface
as opposed to adding the .background(color = MaterialTheme.colors.surface)
modifier to the Column
? Which one would you consider better practice?iamthevoid
05/12/2022, 8:17 AMTin Tran
05/12/2022, 8:53 AMMarcin Wisniowski
05/12/2022, 11:11 AMdimsuz
05/12/2022, 11:24 AMButton
slot's content and printing "recomposing"?
MaterialTheme {
val handler = { _: TextLayoutResult -> }
MyButton(handler)
}
@Composable
fun MyButton(handler: (TextLayoutResult) -> Unit) {
val state by flowOf("two", "three").collectAsState("one")
Button(onClick = {}, enabled = state == "two") {
println("recomposing content")
Text(text = "Button", onTextLayout = handler)
}
}
If I remove "handler" parameter recomposition happens only once. Is there a way to somehow mark "handler" as stable?Lilly
05/12/2022, 12:43 PMScaffold
.The Scaffold has a BottomNavigation
and a TopAppBar
. Navigating between the child screens means switching the content of the Scaffold. How can I have different TopBar actions on each screen? Do I have to drop the TopAppBar of the main screen and let the child screens have its own Scaffold with TopAppBar ? Another possibility I'm aware of would be to pass down the related TopBar composable and switch it on screen change like I do it with the screen content?mattinger
05/12/2022, 12:47 PMTgo1014
05/12/2022, 12:58 PMLazyRow
where the items can have different sizes, as it’s the last composable on the bottom of the screen, if when scrolling the user scrolls to a smaller item than the ones displayed first the screen moves up, which makes it seems weird. My question: is there a way to set the height
of a LazyRow
to be of its tallest item?Slackbot
05/12/2022, 2:31 PMIan Warwick
05/12/2022, 4:17 PMcreateEmptyComposeRule()
however in practice using it with espresso tests with ActivityScenario
based tests has issues with idling resource timeout. I found this repo that demonstrates the issue https://github.com/Maksim-Novikov/ComposeUiTestsBug (check the only andoridTest
test there)
I am not sure the source of this repo but a github community member posted it I guess however it demonstrates a workaround for my exact issue.
My question is anyone using this approach and is there an official bug or something raised regarding this and the workaround? I can’t find anything 😞Rick Regan
05/12/2022, 4:57 PMperformTouchInput
and check the text with hasText
. The way I devised to move the slider doesn’t work for all ranges, so I’m looking for suggestions for the best (correct) way to move it. (See 🧵 for details.)Tolriq
05/12/2022, 7:26 PMSimon Stahl
05/12/2022, 8:04 PMFunkyMuse
05/12/2022, 10:41 PMfengdai
05/13/2022, 1:43 AMfengdai
05/13/2022, 1:43 AMStylianos Gakis
05/13/2022, 7:39 AMIan Lake
05/23/2022, 8:18 PMmovableContentOf
, it could be reparented onto another tree that has a different LifecycleOwner (i..e., a different screen if you are using Navigation Compose)