Mercari 運用 Jetpack Compose 將 UI 開發效率提高 56%
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Mercari 讓數百萬人可以選購幾乎任何商品。這間公司創立於 2013 年,現在是日本最大的智慧型手機專用 C2C 市集。Mercari 的客戶架構師團隊於 2020 年開始使用 Jetpack Compose,目標是使用可以長期擴充的新解決方案和技術,為新應用程式建構自家技術堆疊。
具體措施
Mercari 團隊需要在 Android View 中實作複雜的狀態管理和樣式設計系統,這是相當複雜的工作。使用 Jetpack Compose 後,他們不只能夠實作這個複雜的系統,進而減少開發各個畫面的時間。
Jetpack Compose 也協助團隊運用設計系統,為新的應用程式編寫 UI 程式碼,讓 UI 程式碼簡單明瞭。因此,該團隊能投入更多時間編寫畫面和商業邏輯,例如支援深色主題的實務支援。
此外,Mercari 團隊也編寫了一項概念驗證工具,用來整合 Figma 與設計系統,這個工具會自動根據元件設計產生 UI 程式碼。團隊表示,由於 Compose 的宣告性質,在開發這項工具時比較容易。
「一旦 Android 開發人員習慣編寫 Jetpack Compose 程式碼,他們就不會想回來。」- Mercari 的 Android 技術主管 Anthony Allan Conda
成果
在 Jetpack Compose 及其新設計系統之間,Mercari 得以用更少的程式碼編寫畫面。針對可無限捲動內容的螢幕 (常見用途),實際程式碼其實減少了 56% 左右。因此,這些畫面可以在同一時間內編寫更多畫面,進而有更多時間編寫商業邏輯和程式碼的其他部分。
此外,這些 API 也能利用 UI 本身完成更多工作,例如加入動畫,以及使用符合直覺的 API,例如 AnimatedVisibility、Crossfade 和 Animatable。
Mercari 打算繼續在新應用程式中使用 Jetpack Compose,直到發布為止。他們的設計系統 (採用以 Jetpack Compose 編寫的 Android SDK) 也是專為 Mercari 中的多個應用程式所設計。
開始使用
進一步瞭解 Jetpack Compose。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2021-05-19 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2021-05-19 (世界標準時間)。"],[],[],null,["# Mercari improves UI development productivity by 56% with Jetpack Compose\n\n[Mercari](https://play.google.com/store/apps/details?id=com.kouzoh.mercari) allows millions of people to shop and sell almost anything. The company was founded in 2013 in Japan, and it now is the largest smartphone-focused C2C marketplace in Japan. Mercari's Client Architect Team started using [Jetpack Compose](https://developer.android.com/jetpack/compose) in 2020 with the goal of using modern solutions and technologies that can scale for the long term to build their tech stack for new applications.\n\nWhat they did\n-------------\n\nThe Mercari team needed to implement a design system with complex state management and styling on Android Views --- a very complex task. Using Jetpack Compose, they were not only able to implement this complex system, it helped them spend less time developing each screen.\n\nJetpack Compose also helped the team write UI code for their new app utilizing the design system, making their UI code concise and easy to understand. As a result, the team can spend more time writing screens and business logic, such as practical support for the dark theme.\n\nIn addition, the Mercari team wrote a proof-of-concept tool for integrating Figma with the design system, which automatically generates UI code from the component designs. The team said that developing this tool was easier with Compose due to its declarative nature.\n\n*\"Once Android developers get used to writing Jetpack Compose code, they wouldn't wish to go back.\" - Anthony Allan Conda, Android Tech Lead at Mercari*\n\nResults\n-------\n\nBetween Jetpack Compose and their new design system, Mercari was able to use far less code to write screens. On screens with infinitely-scrollable content --- a common use case --- they actually reduced their code by about 56%. As a result, they were able to write more screens in the same amount of time, giving them more time to write business logic and other parts of the code.\n\nAlso, they were able to do more with the UI itself, such as incorporating animations and using intuitive APIs such as *AnimatedVisibility* , *Crossfade* , and *Animatable*.\n\nMercari is planning to continue using Jetpack Compose in their new application until its release. Their design system, with the Android SDK written in Jetpack Compose, is also designed to work with multiple applications within Mercari.\n\nGet started\n-----------\n\nLearn more about [Jetpack Compose](https://developer.android.com/jetpack/compose)."]]