Skip to content

Upgrade Navigation Compose to 2.8.9 and adopt type-safe navigation - #206

Open
dipenpradhan wants to merge 6 commits into
Gurupreet:masterfrom
dipenpradhan:issue-193-nav-2.8
Open

Upgrade Navigation Compose to 2.8.9 and adopt type-safe navigation#206
dipenpradhan wants to merge 6 commits into
Gurupreet:masterfrom
dipenpradhan:issue-193-nav-2.8

Conversation

@dipenpradhan

Copy link
Copy Markdown

Summary

Upgrades Navigation Compose from 2.7.7 to 2.8.9 and adopts type-safe navigation, as proposed in #193.

Build changes

  • Versions.kt: navCompose 2.7.7 → 2.8.9; new kotlinxSerializationJson = "1.8.0"
  • kotlinx-serialization-json added to the shared kotlinDependencies group
  • org.jetbrains.kotlin.plugin.serialization (2.1.20, matching Kotlin) available from buildSrc and applied in the two demo modules that define routes

Type-safe route migrations

  • Gmail demo: "home" / "detail" / "create" string routes → @Serializable route objects (GmailHomeRoute, GmailDetailRoute, GmailCreateRoute)
  • TikTok demo: TikTokScreen is now a serializable sealed interface; the profile route carries a typed argumentdata class Profile(val userId: String) read via backStackEntry.toRoute<…>() instead of arguments?.getString("userId")!! — and the bottom bar selection uses NavDestination.hasRoute(...) instead of comparing route strings

The Wear OS nav graph in the cryptoapp demo intentionally stays string-based: it uses androidx.wear.compose:compose-navigation, which has its own API surface.

Closes #193

Verification

  • ./gradlew ktfmtCheck assembleDebug testDebugUnitTest passes locally (JDK 17, SDK 35)
  • CI ./gradlew build on this PR

Merge order

PR 6 of the stacked series. Depends on #195#196#197#204#205 — its diff includes their commits until they merge.

🤖 Generated with Claude Code

cc @Gurupreet for review

- Bump kotlin-gradle-plugin 1.9.22 -> 2.1.20 (root + buildSrc)
- Adopt the new Compose Compiler Gradle plugin
  (org.jetbrains.kotlin.plugin.compose) in app and convention plugins
- Drop composeCompiler version constant and composeOptions blocks
- Replace removed -Xopt-in flag with -opt-in
- Bump KSP to 2.1.20-1.0.31 to match Kotlin

Fixes Gurupreet#182
ktfmt-gradle 0.12.0 fails with 'Generic error during file processing'
once Kotlin 2.x is on the buildscript classpath. 0.22.0 supports
Kotlin 2.x and also formats *.kts build scripts, hence the repo-wide
reformat (no functional changes).
- AGP 8.2.2 -> 8.7.3 (compileSdk 35 supported from AGP 8.6)
- Gradle wrapper 8.5 -> 8.9 (required by AGP 8.7.x)
- PinLockView: removeLast() -> removeAt(lastIndex); at compileSdk 35 the
  call binds to java.util.List#removeLast (API 35) instead of the Kotlin
  stdlib extension, failing lint NewApi against minSdk 25

Fixes Gurupreet#185
- Replace compose/material3 version constants with composeBom
- Strip explicit versions from BOM-managed artifacts
- Import the BOM platform on every configuration that receives
  Compose artifacts (implementation, debugImplementation,
  androidTestImplementation, :data)
- Migrate API removals that come with Compose 1.7 / Material3 1.3:
  SmallTopAppBar -> TopAppBar, rememberRipple -> material3 ripple
- Update the outdated README Compose badge to the BOM version

Fixes Gurupreet#186
All lifecycle artifacts (viewmodel-compose, viewmodel-ktx,
livedata-ktx, runtime-ktx, viewmodel-savedstate) move together
via the shared androidLifecycleGrouped version.

Fixes Gurupreet#192
- navCompose 2.7.7 -> 2.8.9; add kotlinx-serialization-json 1.8.0
- Apply the Kotlin serialization plugin in gmail and tiktok demos
- Gmail: string routes -> @serializable route objects
- TikTok: TikTokScreen becomes a serializable sealed interface;
  the profile route carries a typed userId argument read via
  toRoute(), bottom bar selection uses NavDestination.hasRoute

Fixes Gurupreet#193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Upgrade Navigation Compose to 2.8.x and adopt type-safe navigation

1 participant