@@ -4,33 +4,33 @@ package org.michaelbel.template.ui.settings
44
55import androidx.compose.foundation.clickable
66import androidx.compose.foundation.layout.PaddingValues
7- import androidx.compose.foundation.layout.calculateEndPadding
8- import androidx.compose.foundation.layout.calculateStartPadding
7+ import androidx.compose.foundation.layout.WindowInsetsSides
98import androidx.compose.foundation.layout.fillMaxSize
109import androidx.compose.foundation.layout.fillMaxWidth
10+ import androidx.compose.foundation.layout.only
1111import androidx.compose.foundation.layout.padding
12- import androidx.compose.foundation.layout.size
1312import androidx.compose.foundation.lazy.LazyColumn
1413import androidx.compose.material3.ExperimentalMaterial3Api
1514import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
1615import androidx.compose.material3.Icon
17- import androidx.compose.material3.IconButtonDefaults
1816import androidx.compose.material3.ListItem
1917import androidx.compose.material3.ListItemDefaults
2018import androidx.compose.material3.MaterialTheme
2119import androidx.compose.material3.Scaffold
20+ import androidx.compose.material3.ScaffoldDefaults
2221import androidx.compose.material3.Switch
2322import androidx.compose.material3.Text
2423import androidx.compose.material3.TopAppBar
24+ import androidx.compose.material3.TopAppBarDefaults
2525import androidx.compose.runtime.Composable
2626import androidx.compose.runtime.getValue
2727import androidx.compose.ui.Modifier
2828import androidx.compose.ui.draw.clip
29- import androidx.compose.ui.platform.LocalLayoutDirection
29+ import androidx.compose.ui.input.nestedscroll.nestedScroll
3030import androidx.compose.ui.unit.dp
3131import androidx.lifecycle.compose.collectAsStateWithLifecycle
3232import org.koin.androidx.compose.koinViewModel
33- import org.michaelbel.shared.icons.Github
33+ import org.michaelbel.shared.icons.FormatPaint
3434import org.michaelbel.shared.middleLargeIncreasedListItemShape
3535import org.michaelbel.template.ui.settings.intent.SettingsIntent
3636
@@ -39,55 +39,43 @@ fun SettingsScreen(
3939 viewModel : SettingsViewModel = koinViewModel()
4040) {
4141 val state by viewModel.stateFlow.collectAsStateWithLifecycle()
42+ val scrollBehavior = TopAppBarDefaults .pinnedScrollBehavior()
4243
4344 Scaffold (
44- modifier = Modifier .fillMaxSize(),
45+ modifier = Modifier
46+ .fillMaxSize()
47+ .nestedScroll(scrollBehavior.nestedScrollConnection),
4548 topBar = {
4649 TopAppBar (
47- title = {
48- Text (
49- text = " Settings "
50- )
51- }
50+ title = { Text (text = " Settings " ) },
51+ colors = TopAppBarDefaults .topAppBarColors (
52+ scrolledContainerColor = MaterialTheme .colorScheme.surfaceContainer
53+ ),
54+ scrollBehavior = scrollBehavior
5255 )
53- }
56+ },
57+ contentWindowInsets = ScaffoldDefaults .contentWindowInsets.only(WindowInsetsSides .Horizontal )
5458 ) { innerPadding ->
55- val layoutDirection = LocalLayoutDirection .current
56-
5759 LazyColumn (
58- modifier = Modifier .fillMaxSize(),
59- contentPadding = PaddingValues (
60- start = innerPadding.calculateStartPadding(layoutDirection),
61- top = innerPadding.calculateTopPadding().plus(16 .dp),
62- end = innerPadding.calculateEndPadding(layoutDirection),
63- bottom = innerPadding.calculateBottomPadding().plus(16 .dp)
64- )
60+ modifier = Modifier
61+ .padding(innerPadding)
62+ .fillMaxSize(),
63+ contentPadding = PaddingValues (16 .dp)
6564 ) {
6665 item {
6766 ListItem (
6867 modifier = Modifier
6968 .fillMaxWidth()
70- .padding(horizontal = 16 .dp)
7169 .clip(middleLargeIncreasedListItemShape)
7270 .clickable { viewModel.dispatch(SettingsIntent .ToggleDynamicColors ) },
73- colors = ListItemDefaults .colors(containerColor = MaterialTheme .colorScheme.inversePrimary),
74- headlineContent = {
75- Text (
76- text = " Dynamic Colors" ,
77- style = MaterialTheme .typography.titleLarge
78- )
79- },
80- supportingContent = {
81- Text (
82- text = " Apply colors from Wallpaper" ,
83- style = MaterialTheme .typography.bodyMedium
84- )
85- },
71+ colors = ListItemDefaults .colors(
72+ containerColor = MaterialTheme .colorScheme.surfaceContainerHighest
73+ ),
74+ headlineContent = { Text (text = " Dynamic Colors" ) },
8675 leadingContent = {
8776 Icon (
88- imageVector = Github ,
89- contentDescription = null ,
90- modifier = Modifier .size(IconButtonDefaults .smallIconSize)
77+ imageVector = FormatPaint ,
78+ contentDescription = null
9179 )
9280 },
9381 trailingContent = {
0 commit comments