Skip to content

Commit ef45ff2

Browse files
authored
Merge pull request #37 from android/dt/fix-list-detail
Remove horizontal space in the Material list-detail scene
2 parents 955a300 + 72234b4 commit ef45ff2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/src/main/java/com/example/nav3recipes/scenes/materiallistdetail/MaterialListDetailActivity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ import androidx.compose.foundation.layout.Column
2323
import androidx.compose.material3.Button
2424
import androidx.compose.material3.Text
2525
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
26+
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
27+
import androidx.compose.material3.adaptive.layout.calculatePaneScaffoldDirective
2628
import androidx.compose.material3.adaptive.navigation3.ListDetailSceneStrategy
2729
import androidx.compose.material3.adaptive.navigation3.rememberListDetailSceneStrategy
30+
import androidx.compose.runtime.remember
2831
import androidx.compose.ui.Alignment
32+
import androidx.compose.ui.unit.dp
2933
import androidx.navigation3.runtime.NavKey
3034
import androidx.navigation3.runtime.entry
3135
import androidx.navigation3.runtime.entryProvider
@@ -62,7 +66,14 @@ class MaterialListDetailActivity : ComponentActivity() {
6266
setContent {
6367

6468
val backStack = rememberNavBackStack(ConversationList)
65-
val listDetailStrategy = rememberListDetailSceneStrategy<NavKey>()
69+
70+
// Override the defaults so that there isn't a horizontal space between the panes.
71+
val windowAdaptiveInfo = currentWindowAdaptiveInfo()
72+
val directive = remember(windowAdaptiveInfo) {
73+
calculatePaneScaffoldDirective(windowAdaptiveInfo)
74+
.copy(horizontalPartitionSpacerSize = 0.dp)
75+
}
76+
val listDetailStrategy = rememberListDetailSceneStrategy<NavKey>(directive = directive)
6677

6778
NavDisplay(
6879
backStack = backStack,

0 commit comments

Comments
 (0)