Skip to content

Commit b8ba583

Browse files
committed
Update Nav3 snippets to match alpha09 API
1 parent 26d3644 commit b8ba583

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ androidx-fragment-ktx = "1.8.6"
1818
androidx-glance-appwidget = "1.1.1"
1919
androidx-lifecycle-compose = "2.8.7"
2020
androidx-lifecycle-runtime-compose = "2.8.7"
21-
androidx-lifecycle-viewmodel-navigation3 = "1.0.0-SNAPSHOT"
21+
androidx-lifecycle-viewmodel-navigation3 = "1.0.0-alpha04"
2222
androidx-navigation = "2.8.9"
23-
androidx-navigation3 = "1.0.0-SNAPSHOT"
23+
androidx-navigation3 = "1.0.0-alpha09"
2424
androidx-paging = "3.3.6"
2525
androidx-startup-runtime = "1.2.0"
2626
androidx-test = "1.6.1"
@@ -31,7 +31,7 @@ androidx-window-core = "1.5.0-alpha01"
3131
androidx-window-java = "1.5.0-alpha01"
3232
# @keep
3333
androidx-xr = "1.0.0-alpha03"
34-
androidxHiltNavigationCompose = "1.2.0"
34+
androidxHiltNavigationCompose = "1.3.0"
3535
appcompat = "1.7.0"
3636
coil = "2.7.0"
3737
# @keep
@@ -56,7 +56,7 @@ maps-compose = "6.6.0"
5656
material = "1.13.0-alpha13"
5757
material3-adaptive = "1.1.0"
5858
material3-adaptive-navigation-suite = "1.3.2"
59-
material3-adaptive-navigation3 = "1.0.0-SNAPSHOT"
59+
material3-adaptive-navigation3 = "1.0.0-alpha02"
6060
media3 = "1.6.1"
6161
# @keep
6262
minSdk = "21"

0 commit comments

Comments
 (0)