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

DroidKaigi 2022のカンファレンスアプリを眺める

DroidKaigi 2022のカンファレンスアプリを眺める

Mikami Hiroki

March 31, 2023
Tweet

More Decks by Mikami Hiroki

Other Decks in Programming

Transcript

  1. カンファレンスアプリの技術特徴 • モダンな技術要素 ◦ Jetpack ComposeやFlow、Compose Material 3 • 挑戦的な要素

    ◦ Kotlin Multiplatform[1] ▪ iOSまでもリリース [1] Kotlin Multiplatform, https://kotlinlang.org/docs/multiplatform.html
  2. build-logic の登場 • Version Catalog[4]とComposite Build[5]の組み合わせ build-logicを作る • Now in

    Android[6] でも採用 [4] Sharing dependency versions between projects, https://docs.gradle.org/current/userguide/platforms.html [5] Composing builds, https://docs.gradle.org/current/userguide/composite_builds.html [6] Now in Android, https://github.com/android/nowinandroid
  3. @Suppress("unused") class AndroidPlugin : Plugin<Project> { override fun apply(target: Project)

    { with(target) { with(pluginManager) { apply("com.android.library") } androidLibrary { setupAndroid() } } } } primitive @Suppress("unused") class AndroidKotlinPlugin : Plugin<Project> { override fun apply(target: Project) { with(target) { with(pluginManager) { apply("org.jetbrains.kotlin.android") } android { /* ... */} } } } }
  4. @Suppress("unused") class AndroidPlugin : Plugin<Project> { override fun apply(target: Project)

    { with(target) { with(pluginManager) { apply("com.android.library") } androidLibrary { setupAndroid() } } } } primitive @Suppress("unused") class AndroidKotlinPlugin : Plugin<Project> { override fun apply(target: Project) { with(target) { with(pluginManager) { apply("org.jetbrains.kotlin.android") } android { /* ... */} } } } }
  5. build-logicのbuild.gradle.kts gradlePlugin { plugins { // Primitives register("android") { id

    = "droidkaigi.primitive.android" implementationClass = "io.github.droidkaigi.confsched2022.primitive.AndroidPlugin" } register("androidKotlin") { id = "droidkaigi.primitive.android.kotlin" implementationClass = "io.github.droidkaigi.confsched2022.primitive.AndroidKotlinPlugin" } } }
  6. convention class AndroidFeaturePlugin : Plugin<Project> { override fun apply(target: Project)

    { with(target) { with(pluginManager) { apply("droidkaigi.primitive.android") apply("droidkaigi.primitive.android.kotlin") apply("droidkaigi.primitive.android.compose") /* ... */ } } } }
  7. convention class AndroidFeaturePlugin : Plugin<Project> { override fun apply(target: Project)

    { with(target) { with(pluginManager) { apply("droidkaigi.primitive.android") apply("droidkaigi.primitive.android.kotlin") apply("droidkaigi.primitive.android.compose") /* ... */ } } } }
  8. build-logicのbuild.gradle.kts gradlePlugin { plugins { // Primitives /* ... */

    // Conventions register("androidFeature") { id = "droidkaigi.convention.androidfeature" implementationClass = "io.github.droidkaigi.confsched2022.convention.AndroidFeaturePlugin" } register("kmp") { id = "droidkaigi.convention.kmp" implementationClass = "io.github.droidkaigi.confsched2022.convention.KmpPlugin" } } }
  9. Single source of truth for your build scripts [7] Single

    source of truth for your build scripts, https://proandroiddev.com/single-source-of-truth-for-your-build-scripts-72d584534949
  10. ビルド周りについての所感 • Version Catalogはクセはあるが... ◦ Renovateに続きDependabotの依存関係自動更新対応[8] • build logic は色々な難しい

    • Gradle 8.0.xのアップデート[9] ◦ buildSrcのincludeBuild対応をはじめとして パフォーマンス周りで改善 • 今後まだまだ変更があるかも🤔 [8] Dependabot version updates keeps Gradle version catalogs up-to-date [9] Gradle Release Notes, https://docs.gradle.org/current/release-notes.html
  11. @AndroidEntryPoint class MainActivity : AppCompatActivity() { /* ... */ override

    fun onCreate(savedInstanceState: Bundle?) { /* ... */ setContent { KaigiApp( windowSizeClass = calculateWindowSizeClass(this), sessionIdFromNotification = sessionIdString ) } } /* ... */ } :app-android
  12. @Composable fun KaigiApp(/* ... */) { KaigiTheme(/* ... */) {

    KaigiAppDrawer(/* ... */) { NavHost( modifier = Modifier, navController = kaigiAppScaffoldState.navController, startDestination = SessionsNavGraph.sessionRoute, ) { sessionsNavGraph(/* ... */) contributorsNavGraph(/* ... */) aboutNavGraph(/* ... */) /* ... */ } } } } :app-android
  13. @Composable fun KaigiApp(/* ... */) { KaigiTheme(/* ... */) {

    KaigiAppDrawer(/* ... */) { NavHost( modifier = Modifier, navController = kaigiAppScaffoldState.navController, startDestination = SessionsNavGraph.sessionRoute, ) { sessionsNavGraph(/* ... */) contributorsNavGraph(/* ... */) aboutNavGraph(/* ... */) /* ... */ } } } } :app-android
  14. @Composable fun KaigiApp(/* ... */) { KaigiTheme(/* ... */) {

    KaigiAppDrawer(/* ... */) { NavHost( modifier = Modifier, navController = kaigiAppScaffoldState.navController, startDestination = SessionsNavGraph.sessionRoute, ) { sessionsNavGraph(/* ... */) contributorsNavGraph(/* ... */) aboutNavGraph(/* ... */) /* ... */ } } } } :app-android
  15. fun NavGraphBuilder.aboutNavGraph( onStaffListClick: () -> Unit, /* ... */ )

    { composable(route = AboutNavGraph.aboutRoute) { AboutScreenRoot( onStaffListClick = onStaffListClick, /* ... */ ) } } :feature:about
  16. fun NavGraphBuilder.aboutNavGraph( onStaffListClick: () -> Unit, /* ... */ )

    { composable(route = AboutNavGraph.aboutRoute) { AboutScreenRoot( onStaffListClick = onStaffListClick, /* ... */ ) } } :feature:about fun onStaffListClick() { navController .navigate( StaffNavGraph.staffRoute, ) } :app-android
  17. fun NavGraphBuilder.aboutNavGraph( onStaffListClick: () -> Unit, /* ... */ )

    { composable(route = AboutNavGraph.aboutRoute) { AboutScreenRoot( onStaffListClick = onStaffListClick, /* ... */ ) } } :feature:about fun onStaffListClick() { navController .navigate( StaffNavGraph.staffRoute, ) } :app-android
  18. @Composable fun KaigiApp(/* ... */) { KaigiTheme(/* ... */) {

    KaigiAppDrawer(/* ... */) { NavHost( modifier = Modifier, navController = kaigiAppScaffoldState.navController, startDestination = SessionsNavGraph.sessionRoute, ) { sessionsNavGraph(/* ... */) contributorsNavGraph(/* ... */) aboutNavGraph(/* ... */) /* ... */ } } } } :app-android
  19. @Composable fun KaigiApp(/* ... */) { KaigiTheme(/* ... */) {

    KaigiAppDrawer(/* ... */) { NavHost( modifier = Modifier, navController = kaigiAppScaffoldState.navController, startDestination = SessionsNavGraph.sessionRoute, ) { sessionsNavGraph(/* ... */) contributorsNavGraph(/* ... */) aboutNavGraph(/* ... */) /* ... */ } } } } :app-android
  20. 2021年のカンファレンスアプリと比較して • Jetpack Composeは継続 ◦ Accompanist[11]も含めて開発が進んでいる • Compose Material 3[12]が登場

    & 実装にも • 全体的に実装の方針が定まりつつある印象 ◦ Google公式のドキュメントの充実 ◦ Now in AndroidなどのOSSプロジェクト [11] Accompanist, https://google.github.io/accompanist/ [12] Compose Material 3, https://developer.android.com/jetpack/androidx/releases/compose-material3
  21. CREDITS: This presentation template was created by Slidesgo, including icons

    by Flaticon, infographics & images by Freepik. Thanks!
  22. References 1 • [1] Kotlin Multiplatform, https://kotlinlang.org/docs/multiplatform.html • [2] Tech

    Stacks, https://github.com/DroidKaigi/conference-app-2022 • [3] Herding Elephants, https://developer.squareup.com/blog/herding-elephants/ • [4] Sharing dependency versions between projects, https://docs.gradle.org/current/userguide/platforms.html • [5] Composing builds, https://docs.gradle.org/current/userguide/composite_builds.html • [6] Single source of truth for your build scripts, https://proandroiddev.com/single-source-of-truth-for-your-build-scripts-72d584534949 • [7] Single source of truth for your build scripts, https://proandroiddev.com/single-source-of-truth-for-your-build-scripts-72d584534949
  23. References 2 • [8] Dependabot version updates keeps Gradle version

    catalogs up-to-date, https://github.blog/changelog/2023-03-13-dependabot-version-updates-keeps-gradle-version-cata logs-up-to-date/ • [9] Gradle Release Notes, https://docs.gradle.org/current/release-notes.html • [10] Common modularization patterns, https://developer.android.com/topic/modularization/patterns#communication • [11] Accompanist, https://google.github.io/accompanist/ • [12] Compose Material 3, https://developer.android.com/jetpack/androidx/releases/compose-material3