Stylianos Gakis
07/10/2023, 3:20 PMpointerInput(Unit) { … }
somewhere, and inside there I call this.size.width
to calculate something regarding its width.
Due to the fact that in my activity I am saying that I am handling the configuration change of rotating the phone, this does not get updated in that case.
Is my best bet to do something like pointerInput(LocalConfiguration.current)
so I key properly to restart that lambda and on the new instance I will get the right width again? Or is there something better I can do instead?Stylianos Gakis
07/10/2023, 3:24 PMprivate fun Modifier.customModifier()
where I am not in a composable context, and I gotta go with a composed
in order to achieve this it seems like.Stylianos Gakis
07/10/2023, 3:36 PMAlex Vanyo
07/10/2023, 4:02 PMthis
referring to in this.size.width
and how is it being called?
Keying off of LocalConfiguration.current
for the size is pretty suspicious to me: That’s a “global” window-level signal, and maybe the composable you’re using pointerInput
for changes size completely separately from the window resizingStylianos Gakis
07/10/2023, 4:07 PMthis
there is just PointerInputScope
which is what this
is inside the pointerInput
already.
I didn’t like this solution either, but how else can I make sure that the val size: IntSize
inside this PointerInputScope
is up to date?Stylianos Gakis
07/10/2023, 4:09 PMStylianos Gakis
07/10/2023, 4:10 PMoffsetX.updateBounds(
lowerBound = -size.width.toFloat(),
upperBound = size.width.toFloat()
)
Alex Vanyo
07/10/2023, 6:24 PMendPoint
“lazier”, and repeatedly calculate the sizes as needed later. So instead of val endPoint = // ...
, you could do
fun getEndPoint() = // …
so that you fetch the most up-to-date width
each timeStylianos Gakis
07/10/2023, 6:41 PMoffsetX.updateBounds(
would also need to be updated in this case too then, since it’s also initiated once and then the slider doesn’t go all the way due to that, it looks so silly with this bug 😅
I turned endPoint
to:
val getEndPoint = {
val endPoint = this.size.width - circleDiameter.toPx()
offsetX.updateBounds(
lowerBound = 0f,
upperBound = endPoint,
)
endPoint
}
And this does in fact work without the configuration local as a keyStylianos Gakis
07/10/2023, 6:43 PMStylianos Gakis
07/10/2023, 9:26 PMStylianos Gakis
07/11/2023, 7:15 PM