Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jamal.composeprefs3.ui

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
Expand All @@ -19,6 +20,7 @@ lateinit var LocalPrefsDataStore: ProvidableCompositionLocal<DataStore<Preferenc
*
* @param dataStore DataStore which will be used to save all the preferences
* @param modifier Modifier applied to the [LazyColumn] holding the list of Prefs
* @param contentPadding PaddingValues applied to the [LazyColumn] holding the list of Prefs
*
*/
@Composable
Expand All @@ -27,6 +29,7 @@ fun PrefsScreen(
modifier: Modifier = Modifier,
dividerThickness: Dp = 1.dp, // 0 for no divider
dividerIndent: Dp = 0.dp, // indents on both sides
contentPadding: PaddingValues = PaddingValues(0.dp),
content: PrefsScope.() -> Unit
) {
LocalPrefsDataStore = staticCompositionLocalOf { dataStore }
Expand All @@ -36,7 +39,7 @@ fun PrefsScreen(
CompositionLocalProvider(LocalPrefsDataStore provides dataStore) {
Column {
Spacer(modifier = Modifier.height(12.dp))
LazyColumn(modifier = modifier.fillMaxSize()) {
LazyColumn(modifier = modifier.fillMaxSize(), contentPadding = contentPadding) {

items(prefsScope.prefsItems.size) { index ->
prefsScope.getPrefsItem(index)()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jamal.composeprefs3sample

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
Expand All @@ -11,6 +12,7 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.jamal.composeprefs3.ui.GroupHeader
import com.jamal.composeprefs3.ui.PrefsScreen
Expand All @@ -22,7 +24,7 @@ import com.jamal.composeprefs3.ui.prefs.*
fun SettingsScreen() {
Scaffold(topBar = { SettingsTopBar() }) { padding ->

PrefsScreen(dataStore = LocalContext.current.dataStore, modifier = Modifier.padding(padding)) {
PrefsScreen(dataStore = LocalContext.current.dataStore, modifier = Modifier.padding(padding), contentPadding = PaddingValues(5.dp)) {

prefsGroup({
GroupHeader(
Expand Down