File tree Expand file tree Collapse file tree 3 files changed +10
-14
lines changed
AdaptiveUiCodelab/app/src/main/java/com/example/reply Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import com.example.reply.data.MailboxType
2727
2828object LocalEmailsDataProvider {
2929
30- private val threads = listOf (
30+ private val replies = listOf (
3131 Email (
3232 4L ,
3333 LocalAccountsDataProvider .getContactAccountByUid(11L ),
@@ -116,7 +116,7 @@ object LocalEmailsDataProvider {
116116 """ .trimIndent(),
117117 createAt = " 20 mins ago" ,
118118 isStarred = true ,
119- replies = threads ,
119+ replies = replies ,
120120 ),
121121 Email (
122122 1L ,
@@ -133,7 +133,7 @@ object LocalEmailsDataProvider {
133133 Ali
134134 """ .trimIndent(),
135135 createAt = " 40 mins ago" ,
136- replies = threads ,
136+ replies = replies ,
137137 ),
138138 Email (
139139 2L ,
@@ -149,7 +149,7 @@ object LocalEmailsDataProvider {
149149 ),
150150 true ,
151151 createAt = " 1 hour ago" ,
152- replies = threads ,
152+ replies = replies ,
153153 ),
154154 Email (
155155 3L ,
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import com.example.reply.data.EmailsRepositoryImpl
2424import kotlinx.coroutines.flow.MutableStateFlow
2525import kotlinx.coroutines.flow.StateFlow
2626import kotlinx.coroutines.flow.catch
27+ import kotlinx.coroutines.flow.update
2728import kotlinx.coroutines.launch
2829
2930class ReplyHomeViewModel (private val emailsRepository : EmailsRepository = EmailsRepositoryImpl ()): ViewModel() {
@@ -54,10 +55,9 @@ class ReplyHomeViewModel(private val emailsRepository: EmailsRepository = Emails
5455 }
5556
5657 fun setSelectedEmail (email : Email ) {
57- val currentState = _uiState .value
58- _uiState .value = currentState.copy(
59- selectedEmail = email
60- )
58+ _uiState .update {
59+ it.copy(selectedEmail = email)
60+ }
6161 }
6262}
6363
Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ package com.example.reply.ui
1818
1919import androidx.compose.foundation.Image
2020import androidx.compose.foundation.background
21- import androidx.compose.foundation.clickable
2221import androidx.compose.foundation.layout.Arrangement
2322import androidx.compose.foundation.layout.Column
2423import androidx.compose.foundation.layout.Row
@@ -93,11 +92,8 @@ fun ReplyEmailListItem(
9392 modifier : Modifier = Modifier
9493) {
9594 Card (
96- modifier = modifier
97- .padding(horizontal = 16 .dp, vertical = 4 .dp)
98- .clickable {
99- onEmailClick(email)
100- }
95+ onClick = { onEmailClick(email) },
96+ modifier = modifier.padding(horizontal = 16 .dp, vertical = 4 .dp)
10197 ) {
10298 Column (
10399 modifier = Modifier
You can’t perform that action at this time.
0 commit comments