使用 Compose 构建速度更快、质量更高的 Cuvva
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Cuvva 正在通过提供真正灵活的保险管理方式(全部通过手机完成)来大幅改进保险服务。
Cuvva 的 Android 工程师花了一些时间重新设计应用的架构,并决定采用单向数据流和 Jetpack Compose。这样,他们就可以摆脱基于自定义 View 的设计系统,该系统速度较慢、难以使用,并且在旧版 Android 上不太可靠。
策略
Cuvva 团队从头开始创建了新的设计组件,然后使用互操作性 API 将可组合项放置在现有布局中,并随着时间的推移,使用 Compose 替换基于 View 的界面并构建新界面。“我们发现,借助 Compose,我们可以更快地从头开始创建新的设计组件,并减少在尝试解决状态管理或碎片化问题上花费的时间。当我们积累了足够多的此类组件后,发布新界面变得非常快速,这无疑有助于我们提高工作效率。”
结果
借助 Compose,他们能够更快地构建更优质的应用:“借助 Compose,我们能够快速整合新功能,这意味着我们可以更快地进行迭代,从而比以往更快地为客户提供更优质的体验。”
使用 Compose,您需要编写的代码行数(以及需要阅读、理解和维护的代码行数)会减少:“只需要很少几行代码就可以在应用中创建列表或动画,这一点令我们非常满意。Compose 确实大幅减少了构建界面所需的代码行数。”
自定义组件更易于实现:“我们创建了一个圆形表盘组件,用于向客户显示其驾驶得分。使用 Compose 为其进度和颜色添加动画效果比以前容易得多,也有趣得多。在 Compose 中,无论是创建新组件还是更改现有组件的行为,自定义操作都更加轻松。”
开始使用
详细了解 Compose。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2021-07-28。
[null,null,["最后更新时间 (UTC):2021-07-28。"],[],[],null,["# Cuvva builds faster and with higher quality with Compose\n\n[Cuvva](https://www.cuvva.com/) is making insurance radically better\nby giving you a truly flexible way to manage your cover, all from your phone.\nThe Android engineers at Cuvva got to spend some time re-architecting their app\nand decided to adopt a unidirectional data flow and Jetpack Compose. That way\nthey could **move away from their custom View based design system**, which was\nslower and harder to work with, and less predictable on older versions of\nAndroid.\n\nWhat they did\n-------------\n\nThe Cuvva team created new design components from scratch, then used the\ninteroperability APIs to place Composables inside existing layouts and, with\ntime, replace View-based screens and build new screens with Compose. *\"We found\nthat Compose lets us create new design components from scratch **much more\nrapidly** and spend less time trying to work around state management or\nfragmentation. Once we had built up a large enough library of these components,\nshipping a new screen became very fast, and it has definitely helped us to be\nmore productive.\"*\n\nResults\n-------\n\nCompose allowed them to build a higher quality app faster: *\"The speed at which\nCompose allows us to put together a new feature means **we can iterate more\nrapidly, providing a higher-quality experience** for our customers faster than\nbefore.\"*\n\nWith Compose the number of lines you need to write, and therefore read,\nunderstand, and maintain, decreases: *\"we were very pleased to see how few lines\nwere required to create lists or animations in our app. Compose has definitely\n**dramatically reduced the number of lines of code** required to build our UI.\"*\n\nCustom components are easier to implement: *\"We created a circular dial\ncomponent which is used to show customers their driving score. **Animating** its\nprogress and colours with Compose was **far easier and a lot more fun** than it\nwould have been previously. Doing anything custom, whether that's new\ncomponents or changing the behaviour of existing ones, is far easier in\nCompose.\"*\n\nGet started\n-----------\n\nLearn more about [Compose](/jetpack/compose)."]]