File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
app/src/main/java/com/hoc081098/datastoresample Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 11package com.hoc081098.datastoresample.data
22
3+ import android.util.Log
34import androidx.datastore.core.DataStore
45import androidx.datastore.preferences.core.Preferences
56import androidx.datastore.preferences.core.booleanPreferencesKey
@@ -98,5 +99,6 @@ class UserPreferencesRepositoryImpl(
9899
99100 override suspend fun updateShowCompleted (showCompleted : Boolean ) {
100101 dataStore.edit { it[Keys .showCompleted] = showCompleted }
102+ Log .d(" UserPreferencesRepo" , " updateShowCompleted $showCompleted " )
101103 }
102104}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class MainActivity : AppCompatActivity() {
1616 super .onCreate(savedInstanceState)
1717
1818 setContent {
19- DataStoreSampleTheme (darkTheme = true ) {
19+ DataStoreSampleTheme {
2020 // A surface container using the 'background' color from the theme
2121 Surface (color = MaterialTheme .colors.background) {
2222 val viewModel = viewModel<MainViewModel >(factory = Locator .mainViewModelFactory)
Original file line number Diff line number Diff line change @@ -56,8 +56,12 @@ fun MainScreen(
5656 CircularProgressIndicator ()
5757 }
5858 } else {
59- Column {
60- MainTasksList (state.tasks)
59+ Column (
60+ modifier = Modifier
61+ .fillMaxHeight()
62+ .fillMaxWidth(),
63+ ) {
64+ MainTasksList (state.tasks, Modifier .weight(1f ))
6165
6266 Row (modifier = Modifier .padding(all = 32 .dp)) {
6367 Image (
@@ -70,7 +74,7 @@ fun MainScreen(
7074
7175 Checkbox (
7276 checked = state.showCompleted,
73- onCheckedChange = { changeShowCompleted(it) }
77+ onCheckedChange = changeShowCompleted
7478 )
7579 }
7680 }
@@ -79,9 +83,9 @@ fun MainScreen(
7983}
8084
8185@Composable
82- fun MainTasksList (tasks : List <Task >) {
86+ fun MainTasksList (tasks : List <Task >, modifier : Modifier = Modifier ) {
8387 LazyColumn (
84- // modifier = Modifier.fillMaxHeight() ,
88+ modifier = modifier ,
8589 contentPadding = PaddingValues (all = 8 .dp)
8690 ) {
8791 items(tasks) { task ->
You can’t perform that action at this time.
0 commit comments