Some feelings/pits of using Jetpack Compose in a formal environment

Original link: http://i.lckiss.com/?p=8041

Background : UI development using Jetpack Compose on an online package.

Impact : In some cases, AutoSize does not support ComposeView, and the Fragment of the old View system is nested in Compose’s Activity.

Solution : Rewrite the relevant requirements using native writing methods such as xml.

Details :

A few months ago, when I was picking up a functional module, I used Compose to write the top-level Activity. The page UI was similar to the Tab switch of Viewpager + Fragment, and the header used the Coordinator layout and pull-down refresh, that is, Coordinatorlayout + RefreshLayout. , the overall page is more complicated, but using Jetpack Compose is relatively simple in terms of tab switching, etc., and because it is a new module, there is a plan to use Compose directly. This is because.

As for the result, the last iterative requirement was to extend this module. To put it bluntly, it was to add two original old fragments. The logic of the two fragments is very complicated and there are some diagrams, because they cannot be nested into compose, and there is no such thing as If you spend too much time rewriting those modules with compose, you can only consider a compromise, that is to rewrite the top layer with Android’s native XML set, and then use compose two interfaces and two native interfaces under the tab. The changes seem to be insignificant. Great, I started it, and after I changed it, I realized that I forgot the logic of Coordinatorlayout.

But!!! Compose 1.2.0 did not support coordination with the native Coordinatorlayout before. The developer conference said two days ago that the official version has not yet come out, so I expressed despair and pain to rewrite the previous logic with native Think about it! ! ! Blood and Tears Lessons! ! !

About some new features at the developer conference: New features in Jetpack Compose – Google I/O 2022

Other pits :

Aside from some incompleteness of writing or framework, the performance problem of long lists should be the biggest pit at present. In addition, there is the problem of reorganization. Special attention should be paid to the problem of infinite reorganization . In addition, it is really inconvenient to preview on the UI, and previewing is really tasteless. . This declarative writing method is really comfortable, but if you want to use it online, I suggest you be cautious, if you don’t know much about the principles of compose, gestures, drawing, etc.

In addition, when the ComposeView of this product is nested with the native one, there will be some inexplicable problems in the adaptation of the Autosize set of screens, and the UI will be big and small.

So it is only recommended to use Compose on pure Compose pages .

above.

This article is reprinted from: http://i.lckiss.com/?p=8041
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment