@@ -36,6 +36,7 @@ import androidx.compose.foundation.layout.padding
3636import androidx.compose.foundation.layout.width
3737import androidx.compose.foundation.lazy.LazyColumn
3838import androidx.compose.foundation.lazy.items
39+ import androidx.compose.foundation.lazy.itemsIndexed
3940import androidx.compose.material.icons.Icons
4041import androidx.compose.material.icons.filled.Delete
4142import androidx.compose.material.icons.filled.Mic
@@ -98,7 +99,7 @@ fun TodoScreen(viewModel: TodoScreenViewModel = hiltViewModel()) {
9899 TopAppBar (
99100 colors = TopAppBarDefaults .topAppBarColors(
100101 containerColor = MaterialTheme .colorScheme.primaryContainer,
101- titleContentColor = MaterialTheme .colorScheme.primary ,
102+ titleContentColor = MaterialTheme .colorScheme.onPrimaryContainer ,
102103 ),
103104 title = { Text (stringResource(R .string.gemini_live_title)) },
104105 )
@@ -141,28 +142,32 @@ fun TodoScreen(viewModel: TodoScreenViewModel = hiltViewModel()) {
141142 is TodoScreenUiState .Success -> {
142143 val todos = (uiState as TodoScreenUiState .Success ).todos
143144 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 ->
145146 TodoItem (
146147 modifier = Modifier ,
147148 task = todo,
148149 onToggle = { viewModel.toggleTodoStatus(todo.id) },
149150 onDelete = { viewModel.removeTodo(todo.id) },
150151 )
151- HorizontalDivider ()
152+ if (index!= todos.size- 1 ) {
153+ HorizontalDivider ()
154+ }
152155 }
153156 }
154157 }
155158 is TodoScreenUiState .Error -> {
156159 val todos = (uiState as TodoScreenUiState .Error ).todos
157160 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 ->
159162 TodoItem (
160163 modifier = Modifier ,
161164 task = todo,
162165 onToggle = { viewModel.toggleTodoStatus(todo.id) },
163166 onDelete = { viewModel.removeTodo(todo.id) },
164167 )
165- HorizontalDivider ()
168+ if (index!= todos.size- 1 ) {
169+ HorizontalDivider ()
170+ }
166171 }
167172 }
168173 }
0 commit comments