How fast can you write an app with Compose?

This article was written in early March 2023, because the review and launch process has gone for nearly two months, hehe~

After resting for more than half a year, I am thinking and trying how to go about my career after this year. In fact, in the year-end summary of last year, I have mentioned several of my directions.

My initial direction was to step into the health care industry. Although I have technology and medical skills, I have no customers, so I probably need a long time to accumulate customers, and now customers are obsessed with massage that relaxes muscles, as well as rent expenses such as equipment. It's better to find a small company to work comfortably. But I couldn't bear to toss my heart.

So I started PlanBto go to the field of Chinese medicine knowledge learning. Although there are some of this kind on the market app, they are not led by people who really have knowledge of Chinese medicine. It can only be said to be a simple aggregation of a bunch of resources, or to sell courses. and exist. But I don't know what the pain points of learning Chinese medicine are, and how to really improve medical skills. This is my market. So I made one from scratch app, and the first version is now complete. It's really about doing appone 's own thing. Although there are few functions and data at present, I think it is valuable, although there may be no money.

aa1.png

AppIt has been put on the official website villa.qhplus.cn , Huawei, Xiaomi, Yongyongbao, and Oppo's application market, but for development, I don't understand the content and structure Appof . After all, it is not designed for you, but you can Experience how silky smooth it is Composealready . Because this appis all Composedeveloped with . From the beginning of the project to the present, it only took about one and a half months to complete the development. It is time for you to experience the speed of Composedevelopment . Appreciate the number of design drafts first (Thanks to my beautiful wife).

aa2.png

And what I do is full-stack development, which includes:

  1. Think about product form
  2. rustWrite backend services with
  3. Data crawling, cleaning and storage
  4. Use to vue3write H5 interfaces such as official website and privacy agreement
  5. In order to put on the shelves, log in, push, etc., you need to open a shell company and run various processes (the most tedious and time-consuming work)

Even on appthe server side , there are various data logic, reporting, storage and other logics. It is conceivable UIhow much time can be allocated for writing?

Of course, this is also due to the emocomponent , which greatly accelerated the development of the business layer.

Q: Why not consider small program development, Flutterdevelopment, RNdevelopment?

Answer: The small program is good, but it is very closed. I want to realize functions such as desktop widgets, and the small program can do it completely. But for the provisions of traditional Chinese medicine, using small components to let us recall an article every day is a problem. A feature that I personally like.

And the performance RNof is too poor, and using it, it is necessary to sacrifice various scenes such as animation and complex layout. And often these scenes that need to interact with the native, it takes ten times more effort to solve.

No Flutter, first of all, because I don’t know how to do it, and secondly, it and RNare both UIlayers. If you consider it together with the data layer, it’s not that simple. And I use it Compose, which is connected to the entire Androidecology , so the performance is high and the development speed is fast. Why not do it? Cross-platform? Just write them separately, and don't go into the overall cross-platform pit anymore. The pitfalls of cross-platform are not only the pitfalls of technical abstraction to cope with the instability of their respective ecology, but also the pitfalls of human resource coordination. It will always be tiring.

Let's take a look Composeat emosome cool points brought by collaborative development with and :

interface management

It is very simple to Composeuse schemethe method of adding routing to handle interface jumps and exposures. Each new interface is one Composable, and @ComposeSchemeit is adding

@ComposeScheme(
    action = SchemeConst.ACTION_THINK_DETAIL,
    alternativeHosts = [HolderActivity::class]
)
@SchemeLongArg(name = SchemeConst.ARG_ID)
@SchemeLongArg(name = SchemeConst.ARG_COMMENT_ID)
@Composable
fun ThinkDetailPage(navBackStackEntry: NavBackStackEntry) {
    LogicPage(navBackStackEntry = navBackStackEntry) {
       // content
    }
}

@Composable
fun LogicPage(
    navBackStackEntry: NavBackStackEntry,
    saveToLatest: Boolean = false, 
    content: @Composable () -> Unit
) {
    content()
    LaunchedEffect(navBackStackEntry) {
        val scheme = navBackStackEntry.arguments?.getString(SchemeKeys.KEY_ORIGIN)?.let { Uri.decode(it) }
        if (scheme != null) {
            // 上报 scheme,作为曝光
            // 保存 scheme,如果用户退出了,直接重入这个界面。 
            // 这个在调试中很好用。例如某个界面,需要点5层才能进去,每次编译重启就要点5次才能看到这个界面,那就蛋疼了,所以如果每次把它记录起来,启动就进去,那开发就顺很多了
        }
    }
}
复制代码

interface state

很多界面基本上就是列表,然后就有空界面、错误提示情况,列表,列表可能还有加载更多。在原来 View 体系,就要做各种 View 的显示隐藏操作,写起来贼麻烦。 用 Compose 封装起来就简单了。 看我的封装结果

val logic by vm.thinkFlow.collectAsStateWithLifecycle()
LogicBox(
    modifier = Modifier
        .fillMaxWidth()
        .weight(1f),
    logic = { logic },
    reload = {
        vm.reload()
    },
    emptyText = "空"
) { list ->
    // 列表数据
}
复制代码

把它往 LogicPage 里面套就完事了,当然这也是数据逻辑层我抽象了强大的 logic 逻辑。借助这个逻辑,可以分分钟完成数据的从网络数据拉取,再到读存 DB,再到界面的渲染,可以快速补充完成空界面、加载出错、加载更多、下拉刷新等功能。

多级评论

aa3.jpg

看我这个思辨详情页面,假设以旧的 RecyclerView 体系来做这个,想想都痛苦。而我是数据逻辑层加UI一起两三个小时搞定, 毫无 bug

另外这里还有一个“从通知点击进来滚动到当前评论”的场景,如果是原生或者 RN 来做,最痛苦的事情就是滚动时机了,一般最终会使用 post 万能大法大法,然而总有没滚动的情况发生,然后产品就找过来了。

Compose 也就是一小段代码的事了:

if (vm.targetCommentId > 0) {
    val targetCommentIndex = remember(vo) {
        indexOfTargetCommentId(vo, vm.targetCommentId)
    }
    if (targetCommentIndex > 0) {
        LaunchedEffect(Unit) {
            vm.listState.scrollToItem(targetCommentIndex, 0)
        }
    }
}
复制代码

嵌套滚动

看看这个一般的嵌套滚动界面

aa4.gif

即使有 NestedScroll 或者 CoordinatorLayout,但新手用不懂,高手也容易遗忘某些配置而踩坑。

那么 Compose 需要多少代码呢?

val nestedScrollConnection = remember {
    object : NestedScrollConnection {
        override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
            if (available.y < 0 && vm.scrollState.canScrollForward) {
                scope.launch {
                    vm.scrollState.scrollBy(-available.y)
                }
                return available
            }
            return super.onPreScroll(available, source)
        }
    }
}
Column(
    modifier = Modifier
        .fillMaxSize()
        .verticalScroll(vm.scrollState)
        .nestedScroll(nestedScrollConnection)
) {
    BookInfoBasic(info)
    BookInfoPageTabSegment(vm = vm)
    HorizontalPager(...)
}
复制代码

这样就完成整个界面了,其实也是对 nestedScroll 的封装,道理和 View 体系一样,只是用起来更方便了。

ChatGPT

ChatGPT 对于 Compose 而言,很不好,毕竟其训练依赖的是旧版本,所以会有很多错误,所以不能用的,但是它在逻辑层面就很好用了,例如文件上传、下载等,我都是让它写,写完自己校验下,就完工了。为了赶时髦,我当然也在 app 里接入了 ChatGPT,当然,我做了配置,目前对外不开放。

aa5.jpg

漫长的审核

正如文章开始所说,开发我用了一个多月,但是后面的审核上线则是用了两个月左右,其实说到底还是对规则的不熟悉。在电子版权、安全评估报告等环节都是在处理一份之后才知道必须要另一个,所以化并行为串行了。并且做安全评估,给我的感觉就是我的 app 分分钟有上百万的日活,实际上整个圈子可能不过数万人,但我也得完成相应的功能,例如接入飞书机器人,在飞书群里完成内容审核功能。

所以这两个月,最多的就是认识到了整个市场,在公司注册、记账、上架等各个环节衍生的无数商业行为,很多都是收智商税和信息差赚差价的。所以中国有商业头脑的人还是很多,在各个小环节拉拢豪绅、巧立名目,只要有信息差,我就可以无限拉高价格。因为也铸就了现在创业那高不可攀的围墙。

当然,我已经进到墙内了,如果能够成功,那这个墙就是对我的保护了,毕竟干的又不是 ChatGpt 那种无法轻易复制的产品,所以这堵高墙就可以为我争取更多的成长时间了。

在这两个月,我打造了另一款产品:emo-ai。最主要的功能就是 ChatGpt 的代理,目前维护了一个小用户群体,收到了第一桶小金。

此外,我也了解了下 StableDiffusion,本地搭建了 StableDiffusionWebUi 的环境,了解它的 prompt 玩法、 controlnetlora 之类的知识。绘图入魔怔~

aa6.jpg

最后

ChatGPTThe explosion of , let people see the power AIof , and the development, design, copywriting and other fields are about to be replaced. Although the field of traditional Chinese medicine has not been affected at all, I have mentioned it before:

**Treatment = recommend [corresponding drugs] based on [current symptoms/indicators]

Therefore, the essence of medicine is a recommendation system. Western medicine emphasizes targeted treatment, while Chinese medicine uses Yin-Yang and Five Elements to build a huge model. From this perspective, Chinese medicine is obviously better.

But in the era of deep neural networks, it is obvious that we can train models with larger parameters to complete the process of dialectical treatment.

But the training of the model requires the support of data and the establishment of the model.

In terms of data, Chinese medicine has thousands of years of data accumulation, which is the largest and most complete resource in the world, but it needs to be integrated and structured.

The most important thing about the model is what is the structure of the model? How to define loss function and optimizer? After a long period of study, I already have some ideas, which are also my unique insights into cross-field integration.

But the current data is not yet structured, GPUnor can I afford it, so there is still a long way to go, and it is also the dream that Qihuang Xiaozhu wants to carry.

If you have a dream, you must also be down-to-earth, because what I am doing now is more difficult. I want to split the books one by one, save them as structured data, and link the content. Using technology can only get vague results, and finally I have to proofread it myself. The management background of the input system is still under construction.

So, blowing it off at the end Composesaved me a lot of time. In Viewthe era of , since there are really few people whoUI like to write and can write , I can probably replace 6 business developers at one time, so with the blessing of , perhaps it is not a big problem to replace 60 business developers.UICompose

Guess you like

Origin juejin.im/post/7229539262911381563