Remove unnecessary Card for Dialog
This commit is contained in:
parent
0db1599cf7
commit
35ed8e12c6
|
@ -4,9 +4,9 @@ import androidx.compose.foundation.Image
|
|||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
|
@ -31,15 +31,12 @@ import java.time.format.DateTimeFormatter
|
|||
import java.time.format.FormatStyle
|
||||
|
||||
@Composable
|
||||
fun DialogCard(dialog: Dialog, onDialogSelected: () -> Unit) {
|
||||
Card(
|
||||
shape = MaterialTheme.shapes.large,
|
||||
fun Dialog(dialog: Dialog, onDialogSelected: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(0.dp, 2.dp)
|
||||
.padding(4.dp)
|
||||
.clickable(onClick = onDialogSelected)
|
||||
) {
|
||||
Row(modifier = Modifier.padding(4.dp)) {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.ic_launcher_foreground),
|
||||
contentDescription = stringResource(R.string.profile_photo),
|
||||
|
@ -98,16 +95,16 @@ fun DialogCard(dialog: Dialog, onDialogSelected: () -> Unit) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DialogList(dialogs: List<Dialog>, onDialogSelected: (String) -> Unit) {
|
||||
LazyColumn {
|
||||
items(dialogs.size) {
|
||||
DialogCard(dialogs[it], onDialogSelected = {
|
||||
Dialog(dialogs[it], onDialogSelected = {
|
||||
onDialogSelected(dialogs[it].id)
|
||||
})
|
||||
Divider(startIndent = 52.dp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +115,9 @@ fun DialogScreen(
|
|||
dialogViewModel: DialogViewModel = viewModel()
|
||||
) {
|
||||
val dialogUiState by dialogViewModel.uiState.collectAsState()
|
||||
Surface {
|
||||
DialogList(dialogUiState.dialogs, onDialogSelected = onDialogSelected)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
|
Loading…
Reference in New Issue