Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jetpack Composeを本番導入してみた結果と課題

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for makun makun
April 20, 2023

Jetpack Composeを本番導入してみた結果と課題

Avatar for makun

makun

April 20, 2023
Tweet

More Decks by makun

Other Decks in Programming

Transcript

  1. 4

  2. data class Comic( val id: String, val title: String, val

    summary: String, val authors: List<Author>, val imageUrl: String, ..., ) 受け取っているデータの例 10 Composableの引数にしたとき、 必要のない再コンポーズが 起こるようになる List やその中身が Immutableではない
  3. @Immutable data class Comic( val id: String, val title: String,

    val summary: String, val authors: List<Author>, val imageUrl: String, ..., ) 11 @Immutable を宣言することで、Compose Compilerが安定したクラスと 判断できる 全てのデータで @Immutable を宣言すれ ば良さそう? 良くない
  4. @Immutable data class Comic( val id: String, val title: String,

    val summary: String, val authors: List<Author>, val imageUrl: String, ..., ) 12 MutableList の可能性があり 運用を間違えると壊れる Kotlin でいう「 !! 」と同じ
  5. data class Comic( val id: String, val title: String, val

    summary: String, val authors: ImmutableList<Author>, val imageUrl: String, ..., ) 13 Kotlin / kotlinx.collections.immutable を利用し ImmutableList を定義ができる 安定化の強制が可能
  6. data class Comic( val id: String, val title: String, val

    summary: String, val authors: ImmutableList<Author>, val imageUrl: String, ..., ) 14 クラスの利用先も ImmutableList に依存 Composeとは無関係のモジュールも Composeに依存してしまう
  7. @Composable fun ComicLineItem( comicId: String, comicTitle: String, comicImageUrl: String, comicSummary:

    String, onItemClick: (...) -> Unit = {}, ..., ) {...} ComicLineItemの例 18 必要なデータのみを Immutable な値として 受け取るようにする 引数が多く扱いにくくなる
  8. data class ComicLineModel( val comicId: String, val comicTitle: String, val

    comicImageUrl: String, val comicSummary: String, ..., ) { constructor(comic: Comic) : this(...) } ComicLineItem用のModelを定義 19
  9. 21 Model Tracker Compose Feature Compose Common Repository Compose 依存

    Viewに関心のあるモジュー ルだけがComposeに依存
  10. Compose導入後の開発の流れ 26 リ リ l ス 仕 様 決 定

    コ ン ポ l ズ 対 応 コ ン ポ l ズ 検 証 実 装 検 証 実装の前に、コンポーズ化する流れ
  11. あきらかにやること増えてる 29 リ リ l ス 仕 様 決 定

    コ ン ポ l ズ 対 応 コ ン ポ l ズ 検 証 実 装 検 証 実装と検証が大変
  12. val text = “Hello, <font color=\”blue\”>world</font>!!” // AndroidViewではHTMLが利用できた val textView

    = TextView(context) textView.text = text // ComposeではHTMLが利用できない Text(text = text) HTMLを利用したText 37
  13. 40