eygraber
10/14/2021, 11:41 PMLazyColumn/LazyRow
to use mutable state for the items, so that updating a property of a single item doesn't cause all the visible items to recompose?Johnny
10/15/2021, 9:05 AMStrings
from LiveData
? When the items are sorted it should not cause recomposition. But seems like observeAsState
forces recomposition every time. Even though I’m using key
val value by viewModel.data.observeAsState()
LazyColumn {
value?.forEach {
item(key = it) {
Text( text = "$it!")
}
}
}
axehit
10/15/2021, 10:04 AMDisposableEffect
.
While using this effect I observed that if I move to another activity, then the onDispose
lambda in the DisposableEffect
of the composable in previous activity I navigated from didn’t get called.
Is this an expected behaviour? That since I didn’t use compose navigation instead activity navigation onDispose
isn’t called.
And on the same topic can you suggest some other alternative of disposing data when composable moves out of view in case of activity navigation, my usecase is I want to send a tracking event everytime user moves out of screen.Stefano Sansone
10/15/2021, 2:12 PMChris Fillmore
10/15/2021, 3:22 PMBasicTextField
to simply show text, in addition to allowing it to be editable?
That is, instead of doing this:
var isEditing by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("some editable text") }
if (isEditing) {
BasicTextField(...)
} else {
Text(...)
}
You do this:
var isEditing by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("some editable text") }
BasicTextField(
...
value = text,
enabled = isEditing,
decorationBox = { innerTextField ->
Surface(
...
// A visual cue to show that the field is being edited
border = if (isEditing) BorderStroke(...) else null
) {
innerTextField()
}
}
)
Shakil Karim
10/15/2021, 4:41 PMAlex
10/15/2021, 6:37 PMSubcomposeLayout
specialists here? Trying to get the height of an inner child, code in 🧵Stylianos Gakis
10/15/2021, 11:23 PMRecyclerView
that holds ViewHolders
that just hold a ComposeView
inside it, I am not getting the expected recomposition behaviour I am expecting. More details in thread 🧵Waqas Tahir
10/16/2021, 8:02 AMMohammad Sianaki
10/16/2021, 9:32 AMCheckbox
?
I have tried Modifier.clip(CircleShape)
but it’s not working.AmrJyniat
10/16/2021, 11:23 AMRyan Kay
10/16/2021, 2:42 PMJishin Dev [JD]
10/16/2021, 2:48 PMOriginally shared in #multiplatform.Seeing this compiler
BackendException
on AS when building a multi module KMM project which uses Jetpack compose
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
and this as render problems when preview tries to load in between
java.lang.NoSuchMethodError: 'void androidx.compose.material.TextKt.Text...'
Found a few other people who had the same issue here, on the issuetracker and even on SOF but none of the solutions that worked for them, worked for me unfortunately.
More details in the 🧵 .spierce7
10/16/2021, 7:15 PMComposable
that displays an image, and when you click on it, it prints out the x and y position of the click, and the RGB color of the image.
I’m noticing if the image is updated though, I end up getting RGB colors from the first image I clicked, not the latest. What is the correct way to handle this, as clearly I’m doing it wrong. Code in thread.Alexander Suraphel
10/17/2021, 2:00 PMyschimke
10/17/2021, 3:16 PMSean Proctor
10/17/2021, 4:00 PMLaunchedEffect
, but it seems that LaunchedEffect
gets canceled on recompose.
@Composable
fun TimeDisplay(viewModel: TimeDisplayViewModel) {
val properties: Map<String, Long> by viewModel.properties.collectAsState()
var timeRemaining by rememeber { mutableStateOf(0) }
Text(timeRemaining.toString)
val timeProperty = properties["time"]
LaunchedEffect(timeProperty) {
val currentTime = System.currentTimeMillis()
while (timeProperty > currentTime) {
timeRemaining = timeProperty - currentTime
delay(1000L)
}
timeRemaining = 0L
}
}
The LaunchedEffect
is always canceled during the delay. properties
is updated with an unrelated value.Chris Johnson
10/17/2021, 9:08 PMchangeToUp
from the Pointer input scope but that doesn't seem to do what I think.. currently I use PointerInput
and detectDragGestures
.Daniel
10/18/2021, 7:55 AMjames
10/18/2021, 7:56 AMsomeParentId
), and that screen is made up of some child Composables, and those Composables each have their own ViewModels. I would like to re-initialize those child ViewModels when someParentId
changes, so that they re-load their data (and in turn recompose whatever is required)
if I completely blow away the child ViewModels when someParentId
changes and construct new ones, the corresponding UI must be recomposed every time, right? and that would be a very inefficient way to do it?
so does this mean that the correct way would be to have ParentViewModel hold a reference to ChildA ViewModel and ChildB ViewModel, and when someParentId
changes I can just get my existing child ViewModel references, and tell them to fetch the relevant new data?
(hastily drawn pic for reference in case the relationships were unclear)Danish Ansari
10/18/2021, 7:56 AM4.2 MB
whereas starter app in Compose is 7.2 MB
having 5 .dex
files. Why there are so many dex files in a starter app?
Edit: I noticed that starter app in XML also has 3 dex files, why is this happening, does this have anything to do with recent versions of Android gradle plugin?Jason Roberts
10/18/2021, 11:22 AMInk
10/18/2021, 12:06 PMDivider(
color = MaterialTheme.colors.background,
modifier = Modifier
.height(150.dp)
.width(2.dp)
)
How Can I add rounded corners for that divider?bmo
10/18/2021, 12:08 PMArpit Shukla
10/18/2021, 2:39 PMrobnik
10/18/2021, 4:15 PMImage
? I'm using Accompanist's HorizontalPager
. A page shows an Image
from a URL. I'd like to load one page ahead so paging feels faster.Александр Репин
10/18/2021, 4:27 PMmingkangpan
10/18/2021, 4:54 PMrobnik
10/18/2021, 5:35 PMMutableState
type. Is there a way to signal Compose when this computed property has changed, without keeping a separate copy of the data in my view model as a MutableState
? (In SwiftUI I do this with objectWillChange.send()
)Fredrik Larsen
10/18/2021, 9:22 PMFredrik Larsen
10/18/2021, 9:22 PMCsaba Kozák
10/19/2021, 7:44 AMFredrik Larsen
10/19/2021, 7:53 AMCsaba Kozák
10/19/2021, 7:55 AMFredrik Larsen
10/19/2021, 7:56 AMdewildte
10/19/2021, 2:40 PMmaxgdn
10/25/2021, 4:02 PM