Skip to content

Commit 2e6179d

Browse files
committed
Add List placeholder
1 parent 4a335d3 commit 2e6179d

File tree

1 file changed

+6
-9
lines changed
  • compose/snippets/src/main/java/com/example/compose/snippets/navigation3/scenes

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
package com.example.compose.snippets.navigation3.scenes
1818

19+
import androidx.compose.foundation.clickable
1920
import androidx.compose.foundation.layout.Column
2021
import androidx.compose.foundation.layout.Row
2122
import androidx.compose.foundation.layout.fillMaxSize
23+
import androidx.compose.material.Text
2224
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
2325
import androidx.compose.runtime.Composable
2426
import androidx.compose.runtime.remember
@@ -167,7 +169,6 @@ data class ConversationDetail(
167169
val colorId: Int
168170
) : NavKey
169171

170-
@Serializable data object Profile : NavKey
171172

172173
@Composable
173174
fun MyAppContent() {
@@ -183,15 +184,15 @@ fun MyAppContent() {
183184
metadata = ListDetailScene.listPane()
184185
) {
185186
// Add new Detail with backStack.addDetail(detailRoute)
187+
Text(text = "I'm a Conversation List", Modifier.clickable(onClick = {
188+
backStack.addDetail(ConversationDetail(1, 2))
189+
}))
186190
}
187191
entry<ConversationDetail>(
188192
metadata = ListDetailScene.detailPane()
189193
) {
190194
// Show Detail Composable
191195
}
192-
entry<Profile> {
193-
// Profile Composable
194-
}
195196
}
196197
)
197198
}
@@ -201,10 +202,6 @@ private fun NavBackStack<NavKey>.addDetail(detailRoute: ConversationDetail) {
201202

202203
// Remove any existing detail routes, then add the new detail route
203204
removeIf { it is ConversationDetail }
204-
add(detailRoute)
205-
// Avoid adding the same detail route to the back stack twice.
206-
if (!contains(detailRoute)) {
207-
add(detailRoute)
208-
}
205+
add(detailRoute)
209206
}
210207
// [END android_compose_navigation3_scenes_4]

0 commit comments

Comments
 (0)