Nicolai
12/14/2022, 9:42 AMval state = rememberLazyListState()
val visibleIndex: Int by remember {
derivedStateOf {
state.firstVisibleItemIndex
}
}
LazyRow that takes the state
LazyRow(
state = state
)..... bla bla
And then a LaunchedEffect on the visibleIndex
LaunchedEffect(visibleIndex) {
delay(2000)
onMetricViewed(metrics[visibleIndex], visibleIndex)
}
My problem now is that this also runs on the second element in the LazyColumn which is far from visible (maybe around 5%).
I've tried with calculating the visibility of items but couldn't come up with something that worked as I wanted it to.
How can I make sure that
onMetricViewed(metrics[visibleIndex], visibleIndex)
is only called if I can actually see the full height of the element in the LazyRow? 🤔Pablo
12/14/2022, 12:46 PModay
12/14/2022, 2:05 PM@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
CLOVIS
12/14/2022, 2:24 PM@Composable
functions, but I can't find where it's documented. Does anyone know?Jhonatan Sabadi
12/14/2022, 2:36 PMCsaba Szugyiczki
12/14/2022, 2:51 PMStylianos Gakis
12/14/2022, 3:56 PMdelayMillis
which makes this convenient. From what I understand this isn’t the case for the spring one since you want to maintain momentum from potential earlier animations or something like that, is this the case?
Now I’m thinking of doing something like
val animatableProgress = remember { Animatable(0f) }
LaunchedEffect(Unit) {
delay(300)
animatableProgress.animateTo(1f, spring())
}
// use animatableProgress
to use this exact thing, but I feel like I may be missing some API which makes this simpler for me.luke_c
12/14/2022, 4:26 PMmattinger
12/14/2022, 6:12 PM@Composable
@Preview
fun TestParagraph() {
val density = LocalDensity.current
val fontFamilyResolver = LocalFontFamilyResolver.current
val placeholderText = "H".repeat(10)
val paragraph1 = Paragraph(
text = placeholderText,
style = MaterialTheme.typography.body1,
spanStyles = listOf(),
maxLines = 1,
ellipsis = false,
density = density,
fontFamilyResolver = fontFamilyResolver,
constraints = Constraints()
)
val paragraph2 = Paragraph(
text = (1.. 2).map { placeholderText }.joinToString("\n"),
style = MaterialTheme.typography.body1,
spanStyles = listOf(),
maxLines = 2,
ellipsis = false,
density = density,
fontFamilyResolver = fontFamilyResolver,
constraints = Constraints()
)
val height1 = paragraph1.height
val height2 = paragraph2.height
Column {
Text(text = "${height1}")
Text(text = "${height2}")
}
}
james
12/15/2022, 12:17 AMhide()
before doing the next thing.. the UX feels nicer than without the delay, but the delay itself feels flimsy — in fact we probably need a condition that says we don’t have a delay on older API levels which don’t animate the IME at all.
it’d be cool if there was some kind of isImeAnimating
state I could watch for this purpose, or something I could use to create a derived state to produce my own isImeAnimating
, but I can’t think of anything immediately and a quick search hasn’t turned anything uppablisco
12/15/2022, 12:29 AMursus
12/15/2022, 12:46 AM@Composable
private fun VerticalSpacer(size: Dp) {
Spacer(modifier = Modifier.height(size))
}
Does creating helpers like this add some overhead?Colton Idle
12/15/2022, 3:32 AMJaime
12/15/2022, 4:19 AMzt
12/15/2022, 5:07 AMyogaboy
12/15/2022, 11:24 AMScaffold() {paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(bottom = paddingValues.calculateBottomPadding())
and screen in bottom on old navigation looks like …yogaboy
12/15/2022, 11:25 AMyogaboy
12/15/2022, 11:26 AMjasu
12/15/2022, 12:18 PMDanish Ansari
12/15/2022, 2:48 PMPopup
and PopupPositionProvider
The background and arrow are the most challenging part as it’s position will be dynamic, for eg. arrow will be on top normally and it might be on bottom if the anchoring view (trailing icon of text view) is on bottom of screen and very less space is available below. And the arrow should point exactly to the “help” icon as shown in first imageluke_c
12/15/2022, 3:44 PMorangy
12/15/2022, 5:57 PMTable
) and now I want to draw lines between rows and columns using measures I’ve calculated inside Layout code. How do I do it? Do I have to add artificial components for each line, lay them out and then draw? Or can I somehow feed data after measurements to something like drawBehind
?v79
12/15/2022, 9:01 PMFullScreenDialog
, as listed here https://m3.material.io/components/dialogs/overview - but it's definitely not listed here https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary !Puneet Verma
12/16/2022, 5:45 AMlesincs
12/16/2022, 7:57 AMRaphael TEYSSANDIER
12/16/2022, 9:03 AMItemTouchHelper
in compose for Lazy* ?Sivan
12/16/2022, 12:30 PMModalBottomSheetLayout
but I am not sure if the assertions are working right. All I am trying to do is to call a button click which opens up the sheet and asserting the sheetState to see if it is visible.
Every assertion is failing for some reason.
Code and logs in the thread ⬇️Tower Guidev2
12/16/2022, 1:43 PMorangy
12/16/2022, 1:57 PMStroke
is not a data class? I miss copy
method…robercoding
12/16/2022, 2:32 PMImage(...)
outside of composition phase? 🤔robercoding
12/16/2022, 2:32 PMImage(...)
outside of composition phase? 🤔Image
and I kinda dislike that it recomposes a hundred of times, do you know if that's skippable or?drawBehind { }
and drawWithContent
, but sadly this didn't work.
I'm guessing there must be another way
Edit: I don't want to go through recomposition just because I'm animating somethingsize
determined on Composition
phase?
I'm thinking that there should be a way to do this in Layout
phase right? Since it determines the size & placement of the layoutZach Klippenstein (he/him) [MOD]
12/16/2022, 11:40 PMrobercoding
12/17/2022, 10:03 AM.layout { measurable, constraints ->
val size = sizeAnimation.toPx()
val placeable = measurable.measure(Constraints.fixed(size.toInt(), size.toInt()))
layout(placeable.width,placeable.height) {
placeable.placeRelative(0, 0)
}
}
Thank you Zach! :heart_hands:Text
and skip recomposition?
The above solution (in the thread) doesn't work which makes sense since it affects directly the width/height
Do you know if there's a way to do that affecting the position of other layouts around the text? That would mean that Drawing
phase won't work in this scenario