Odin
10/20/2022, 8:11 PMsmithc42
10/20/2022, 9:43 PMinitialState
value within AnimatedContent
. Using the AnimatedContent example from the Android docs which slides number up/down based on the previous initialState
, I've tried updateTransition along with animateColor
but I can't find a way to change the text color based on the previous value. Am I missing something obvious here? 🤔Piotr Krzemiński
10/21/2022, 6:19 AMJasmin Fajkic
10/21/2022, 9:37 AMFunkyMuse
10/21/2022, 11:06 AMKev Thompson
10/21/2022, 11:12 AModay
10/21/2022, 12:11 PM@Composable
fun Chip(
label: String,
enabled: MutableState<Boolean>,
onClick: () -> Unit,
) {
val (selected, setSelected) = enabled
val chipColor =
if (selected) MaterialTheme.colors.Action else MaterialTheme.colors.ForegroundMuted
Surface(
shape = RoundedCornerShape(15.dp),
color = chipColor.copy(alpha = 0.2f),
border = BorderStroke(
width = 1.dp, color = chipColor
),
modifier = Modifier
.toggleable(
value = selected,
enabled = true,
onValueChange = setSelected
)
.clickable {
onClick()
},
but this would
modifier = Modifier
.clickable {
onClick()
setSelected(!selected)
},
Thanksczuckie
10/21/2022, 4:35 PMval rotation by animateFloatAsState(
targetValue = if (state) 360.0f else 0f,
animationSpec = if (state) InfiniteRepeatableSpec(tween(durationMillis = 500, easing = LinearEasing)) else snap())
Which I use to rotate an image of a fan when the fan is on, and when it is off, it rotates to a final stationary position.
However if the composable first appears in an on state, the animation will not start. How should I handle this?Lisandro Di Meo
10/21/2022, 4:51 PMcomposable(A){
// other stuff
ScreenA( navHostController, ..., onNavigateToB = { navHostController.navigate(B) } )
// after onNavigateToB executes, it recomposes and re-renders ScreenA
}
composable(B){
ScreenB( ... )
}
Andrea
10/21/2022, 8:56 PMzt
10/21/2022, 10:19 PMzt
10/22/2022, 1:13 AMGiorgi
10/22/2022, 12:56 PMste
10/22/2022, 2:15 PMLazyLayoutPrefetchState
in a custom LazyLayout
to prefetch the previous page and the next one (e.g. in "A, B, C, D, E", I prefetch A and C). However, pages can be swapped (e.g. "A, B, E, C, D"). How can I handle such thing? How can I tell the Prefetcher
the item at index 2 has changed? Is LazyLayoutItemProvider
involved at all?Jasmin Fajkic
10/22/2022, 2:59 PMinclusive=true
. Code in 🧵Sudhir Singh Khanger
10/22/2022, 4:20 PMvisible
, which may be shown imminently (prefetched
), and items down the line which are far away in the list. Which state the last items are in?Sudhir Singh Khanger
10/22/2022, 4:25 PMLazyColumn
item becomes visible for only once. It shouldn't trigger if a user moves up and down the list.
The problem I am facing is that irrespective of which side effect I use any time a Composable from down the list becomes visible, it seems, starts a new composition which means the side effect gets triggered when a user moves up or down the list. Is there a way to avoid this situation? I had asked my question here on SO.
So far, the only way to handle this situation for me would be holding a variable in the data class (isSeen: Boolean
).Aaron Waller
10/22/2022, 6:03 PMCaused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.ViewGroup.getChildAt(int)' on a null object reference
at androidx.activity.compose.ComponentActivityKt.setContent (ComponentActivityKt.java:264)
at com.censored.censored.presentation.MainActivity.onCreate (MainActivity.java:264)
Full crash in thread ->
MainActivity line 264 points to a DrawerItem: (first line is 264)
DrawerItem(
imageDrawable = R.drawable.gold,
title = "Text"
) {
uriHandler.openUri("<https://google.com>")
}
Someone has an idea how I can fix it?zt
10/22/2022, 11:41 PMzt
10/23/2022, 3:42 AMBagadeshkumar R
10/23/2022, 4:39 AMIlan Sasportas
10/24/2022, 8:10 AMNavigationBar
in my Compose code, and I’m trying to have a navigation stack for each tab (so that when I change tabs, my stack for that tab is restored).
What I have seen in the docs is that this all feature is build around routes. And my problem is, some tabs of the bottom bar have the same route showing different data. Are you aware of any way to make this a bit more dynamic ?
Thanks for your help !Rihards
10/24/2022, 8:23 AMgetTheme
function in the fragment which is working in other places in the app where .xml is being used. How can I get rounded bottom sheet corners in this situation?Rafs
10/24/2022, 9:28 AMhorizontalArrangement
to the children of a Row
. I want to use a combination of Arrangement.spacedBy()
and Arrangement.Center
to center the children in the row with even spacing. I can only do one at the moment.Slackbot
10/24/2022, 9:29 AMsunnat629
10/24/2022, 2:28 PMelevation
in TopAppBar
of Material3? Thanks.langara
10/24/2022, 2:38 PM@Composable
fun <T> delayedStateOf(init: T, delayMs: Long = 200, calculation: () -> T): State<T> {
....
val derived = derivedStateOf { if(someCacheNotOutdated) useCache else calculation()... } // FIXME: correct conditional control of reads (subscriptions)
....
return derived
}
So this delayedStateOf
would be a bit lazy updating, so I can use it as input for some low priority part of UI.
Maybe better idea would be to use SnapshotStateObserver
directly - I experimented with it a bit, but I have other issues with that
Or maybe only reasonable solution is to go even lower level and play with snapshots directly? (like snapshotFlow
does)Vinay Gaba
10/24/2022, 5:32 PMste
10/24/2022, 7:19 PMLocalLifecycleOwner.current
and LocalSavedStateRegistryOwner.current
guaranteed to be Activity
?Jorge Domínguez
10/24/2022, 8:34 PMLazyHorizontalStaggeredGrid
in androidx.compose.foundation
? I'm getting the following exception which seems to indicate that I need to pass in a fixed height (and indeed that fixes it) but it doesn't sound right since its height should depend on the children.
java.lang.IllegalArgumentException: LazyHorizontalStaggeredGrid's height should be bound by parent.
my implementation looks like this:
LazyHorizontalStaggeredGrid(
modifier = Modifier.fillMaxWidth(),
rows = StaggeredGridCells.Fixed(3)
) {
items(showcaseFeatures) {
FeatureChip(name = it)
}
}
Jorge Domínguez
10/24/2022, 8:34 PMLazyHorizontalStaggeredGrid
in androidx.compose.foundation
? I'm getting the following exception which seems to indicate that I need to pass in a fixed height (and indeed that fixes it) but it doesn't sound right since its height should depend on the children.
java.lang.IllegalArgumentException: LazyHorizontalStaggeredGrid's height should be bound by parent.
my implementation looks like this:
LazyHorizontalStaggeredGrid(
modifier = Modifier.fillMaxWidth(),
rows = StaggeredGridCells.Fixed(3)
) {
items(showcaseFeatures) {
FeatureChip(name = it)
}
}
Andrey Kulikov
10/24/2022, 10:58 PMshikasd
10/25/2022, 2:30 PMLazyGrid
does, taking up the whole height (in horizontal orientation)
We are looking into adding a way to define fixed child height and size the grid and staggered grid dynamicallyJorge Domínguez
10/25/2022, 3:44 PMLazyHorizontalStaggeredGrid
inside a parent with a fixed height?shikasd
10/25/2022, 4:01 PMKarthick
11/07/2022, 6:10 AM