library/ui: add LazyListScaffold
- Commit
395c065616da62a57b8b3d7bbcd6569d1b466d6c- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-16 00:15 UTC (3 months ago)
- Parents
f6590c6
Diff
library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.ktnew file mode 100644index 0000000000..8f50220621--- /dev/null+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/LazyListScaffold.kt@@ -0,0 +1,57 @@+package com.vayunmathur.library.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.plus+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.LazyListScope+import androidx.compose.foundation.lazy.LazyListState+import androidx.compose.foundation.lazy.rememberLazyListState+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp++/**+ * A scaffold whose body is a single lazily-composed list.+ *+ * The scaffold's [PaddingValues] are forwarded as the [LazyColumn]'s+ * `contentPadding` on all four sides, so items scroll clear of the bars and+ * nothing double-insets or drops the bottom inset. Only a symmetric+ * [horizontalPadding] is folded onto the forwarded start/end (as+ * [DetailScaffold]'s list does with `Spacing.lg`); the top and bottom are always+ * exactly the scaffold's own insets.+ *+ * Use this for a list screen that supplies its own [topBar]/[floatingActionButton]+ * and custom [content] items - grouped cards, headers, selection rows - that the+ * flat-item [ListPage] cannot express.+ */+@Composable+fun LazyListScaffold(+ modifier: Modifier = Modifier,+ topBar: @Composable () -> Unit = {},+ floatingActionButton: @Composable () -> Unit = {},+ bottomBar: @Composable () -> Unit = {},+ snackbarHost: @Composable () -> Unit = {},+ state: LazyListState = rememberLazyListState(),+ horizontalPadding: Dp = 0.dp,+ verticalArrangement: Arrangement.Vertical = Arrangement.Top,+ content: LazyListScope.() -> Unit,+) {+ Scaffold(+ modifier = modifier,+ topBar = topBar,+ bottomBar = bottomBar,+ snackbarHost = snackbarHost,+ floatingActionButton = floatingActionButton,+ ) { innerPadding ->+ LazyColumn(+ state = state,+ modifier = Modifier.fillMaxSize(),+ contentPadding = innerPadding + PaddingValues(horizontal = horizontalPadding),+ verticalArrangement = verticalArrangement,+ content = content,+ )+ }+}