https://kotlinlang.org logo
#compose
Title
# compose
k

Kyant

03/16/2024, 1:59 PM
I am using Compose for many years, it's more convenient than View but I complain it everyday. It's still not mature anyway, there are lots of bugs in the libraries, I have to write my own version, from color system to navigation to m3 components... I really don't understand why the code in library is so complex and there are so many severe bugs which prohibit daily use. My rewrite version will only need less code and performs well (fewer bugs and better performance), for example the
LazyHorizontalPager
is only 200 lines (including
PagerState
). There is a bug in the official `HorizontalPager`: when you scroll to fling, then touch screen, it will transform touch event into small scroll event... so the users can't click and have to wait for the animation finished. In terms of performance, to optmize it will take complex measures, such as using custom
Layout
,
Modifier.Node
to cahce something, and make the recomposition less. If you animate the
TextStyle
in
Text
, it will recompose on every frame and very laggy, I have to create a custom
Modifier.Node
to make it not to recompose. So the work amount is indeed increasing. I am tired of writing compose now, it makes me headache.
👍 1
💆‍♂️ 4
s

Stylianos Gakis

03/16/2024, 3:49 PM
Have you tried reporting bugs for things you find like that problem with the pager fling behavior? What issues do you have with the navigation integration in particular? Writing your own color system other than m3, you absolutely need to do that if your app is not following the material design system obviously. For the animated text scenario, have you tried using TextMotion.Animated https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]n/kotlin/androidx/compose/ui/text/style/TextMotion.kt;l=35-41 which should help with performance?
s

Sergey Y.

03/16/2024, 9:30 PM
Hey there! I'm genuinely intrigued to see your 200-line LazyHorizontalPager and any benchmarks you might have. It sounds like quite the marvel! Sharing it could be hugely beneficial for everyone here, helping to understand your approach and potentially inspiring improvements. 😊
💯 3
e

eygraber

03/17/2024, 12:57 AM
To play devil's advocate, I've been using Compose for 2+ years, and I rarely complain or experience bugs (especially the kind that prohibit any use). I'm very grateful for the amazing material components, and if I ever need to tweak them or make my own version (because a more targeted implementation made for a specific use case could potentially be more optimized) it's much easier and straightforward than it was with View. I enjoy reading the source, as it's relatively easy to understand and copy, especially compared to View. I love writing Compose, and it's gotten rid of a lot of my headaches 😈
👍🏾 2
K 8
5
👍🏻 1
slow parrot 3
👍 15
b

brandonmcansh

03/17/2024, 8:04 PM
Agree 100% here as well
k

Kyant

04/02/2024, 2:08 PM
@Sergey Y. Hi, I may publish the entire library in the future. But it has some project use cases which may be unsuitable to publish. They are highly optmized that minimized the recomposition count, the lazy pager is 0 recomposition even if you change the page or integrate with an animated tab bar.
K 1
@Stylianos Gakis Isn't
TextMotion.Animated
only enable subpixels, but don't prevent recompose?
s

Stylianos Gakis

04/02/2024, 2:29 PM
Yeah, I didn't say it'd stop recompositions, but it's there to make animating text look smoother.
k

Kyant

04/02/2024, 2:30 PM
Yes, I have already use it.
👍 1
4 Views