@@ -36,6 +36,7 @@ import androidx.compose.foundation.layout.padding
36
36
import androidx.compose.foundation.layout.width
37
37
import androidx.compose.foundation.lazy.LazyColumn
38
38
import androidx.compose.foundation.lazy.items
39
+ import androidx.compose.foundation.lazy.itemsIndexed
39
40
import androidx.compose.material.icons.Icons
40
41
import androidx.compose.material.icons.filled.Delete
41
42
import androidx.compose.material.icons.filled.Mic
@@ -98,7 +99,7 @@ fun TodoScreen(viewModel: TodoScreenViewModel = hiltViewModel()) {
98
99
TopAppBar (
99
100
colors = TopAppBarDefaults .topAppBarColors(
100
101
containerColor = MaterialTheme .colorScheme.primaryContainer,
101
- titleContentColor = MaterialTheme .colorScheme.primary ,
102
+ titleContentColor = MaterialTheme .colorScheme.onPrimaryContainer ,
102
103
),
103
104
title = { Text (stringResource(R .string.gemini_live_title)) },
104
105
)
@@ -141,28 +142,32 @@ fun TodoScreen(viewModel: TodoScreenViewModel = hiltViewModel()) {
141
142
is TodoScreenUiState .Success -> {
142
143
val todos = (uiState as TodoScreenUiState .Success ).todos
143
144
LazyColumn (modifier = Modifier .fillMaxSize()) {
144
- items (todos.reversed(), key = { it .id }) { todo ->
145
+ itemsIndexed (todos.reversed(), key = { index : Int , item : Todo -> item .id }) { index, todo ->
145
146
TodoItem (
146
147
modifier = Modifier ,
147
148
task = todo,
148
149
onToggle = { viewModel.toggleTodoStatus(todo.id) },
149
150
onDelete = { viewModel.removeTodo(todo.id) },
150
151
)
151
- HorizontalDivider ()
152
+ if (index!= todos.size- 1 ) {
153
+ HorizontalDivider ()
154
+ }
152
155
}
153
156
}
154
157
}
155
158
is TodoScreenUiState .Error -> {
156
159
val todos = (uiState as TodoScreenUiState .Error ).todos
157
160
LazyColumn (modifier = Modifier .fillMaxSize()) {
158
- items (todos.reversed(), key = { it .id }) { todo ->
161
+ itemsIndexed (todos.reversed(), key = { index : Int , item : Todo -> item .id }) { index, todo ->
159
162
TodoItem (
160
163
modifier = Modifier ,
161
164
task = todo,
162
165
onToggle = { viewModel.toggleTodoStatus(todo.id) },
163
166
onDelete = { viewModel.removeTodo(todo.id) },
164
167
)
165
- HorizontalDivider ()
168
+ if (index!= todos.size- 1 ) {
169
+ HorizontalDivider ()
170
+ }
166
171
}
167
172
}
168
173
}
0 commit comments