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