Skip to content

Commit e799446

Browse files
committed
Update Nav3 snippets to match alpha09 API
1 parent 9105e56 commit e799446

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/navigation3/scenes/ScenesSnippets.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ interface SceneExample<T : Any> {
5050

5151
// [START android_compose_navigation3_scenes_2]
5252
data class SinglePaneScene<T : Any>(
53-
override val key: T,
53+
override val key: Any,
5454
val entry: NavEntry<T>,
5555
override val previousEntries: List<NavEntry<T>>,
5656
) : Scene<T> {
5757
override val entries: List<NavEntry<T>> = listOf(entry)
58-
override val content: @Composable () -> Unit = { entry.content.invoke(entry.key) }
58+
override val content: @Composable () -> Unit = { entry.Content() }
5959
}
6060

6161
/**
@@ -66,7 +66,7 @@ public class SinglePaneSceneStrategy<T : Any> : SceneStrategy<T> {
6666
@Composable
6767
override fun calculateScene(entries: List<NavEntry<T>>, onBack: (Int) -> Unit): Scene<T> =
6868
SinglePaneScene(
69-
key = entries.last().key,
69+
key = entries.last().contentKey,
7070
entry = entries.last(),
7171
previousEntries = entries.dropLast(1)
7272
)
@@ -88,10 +88,10 @@ class TwoPaneScene<T : Any>(
8888
override val content: @Composable (() -> Unit) = {
8989
Row(modifier = Modifier.fillMaxSize()) {
9090
Column(modifier = Modifier.weight(0.5f)) {
91-
firstEntry.content.invoke(firstEntry.key)
91+
firstEntry.Content()
9292
}
9393
Column(modifier = Modifier.weight(0.5f)) {
94-
secondEntry.content.invoke(secondEntry.key)
94+
secondEntry.Content()
9595
}
9696
}
9797
}
@@ -138,7 +138,7 @@ class TwoPaneSceneStrategy<T : Any> : SceneStrategy<T> {
138138
val secondEntry = lastTwoEntries.last()
139139

140140
// The scene key must uniquely represent the state of the scene.
141-
val sceneKey = Pair(firstEntry.key, secondEntry.key)
141+
val sceneKey = Pair(firstEntry.contentKey, secondEntry.contentKey)
142142

143143
TwoPaneScene(
144144
key = sceneKey,

gradle/libs.versions.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ androidx-credentials-play-services-auth = "1.5.0"
1717
androidx-emoji2-views = "1.5.0"
1818
androidx-fragment-ktx = "1.8.9"
1919
androidx-glance-appwidget = "1.1.1"
20-
androidx-lifecycle-viewmodel-navigation3 = "1.0.0-SNAPSHOT"
21-
androidx-navigation = "2.8.9"
22-
androidx-navigation3 = "1.0.0-SNAPSHOT"
20+
androidx-lifecycle-viewmodel-navigation3 = "1.0.0-alpha04"
21+
androidx-navigation3 = "1.0.0-alpha09"
2322
androidx-lifecycle-compose = "2.9.2"
2423
androidx-lifecycle-runtime-compose = "2.9.2"
2524
androidx-navigation = "2.9.3"
@@ -34,7 +33,7 @@ androidx-window-java = "1.5.0-beta02"
3433
androidx-xr-arcore = "1.0.0-alpha05"
3534
androidx-xr-compose = "1.0.0-alpha06"
3635
androidx-xr-scenecore = "1.0.0-alpha06"
37-
androidxHiltNavigationCompose = "1.2.0"
36+
androidxHiltNavigationCompose = "1.3.0"
3837
appcompat = "1.7.1"
3938
coil = "2.7.0"
4039
# @keep
@@ -61,7 +60,7 @@ maps-compose = "6.7.2"
6160
material = "1.14.0-alpha03"
6261
material3-adaptive = "1.1.0"
6362
material3-adaptive-navigation-suite = "1.3.2"
64-
material3-adaptive-navigation3 = "1.0.0-SNAPSHOT"
63+
material3-adaptive-navigation3 = "1.0.0-alpha02"
6564
media3 = "1.8.0"
6665
# @keep
6766
minSdk = "35"

0 commit comments

Comments
 (0)