Simplifying Cell and leaving responsibility to modifier and content

This commit is contained in:
ThomasSession 2024-08-22 22:33:26 +10:00
parent 356b105b98
commit b2c73ff7a2
3 changed files with 15 additions and 19 deletions

View File

@ -193,11 +193,11 @@ fun CellMetadata(
) {
state.apply {
if (listOfNotNull(sent, received, error, senderInfo).isEmpty()) return
Cell(
margin = PaddingValues(horizontal = LocalDimensions.current.spacing),
padding = PaddingValues(all = LocalDimensions.current.spacing)
Cell(modifier = Modifier.padding(horizontal = LocalDimensions.current.spacing)) {
Column(
modifier = Modifier.padding(LocalDimensions.current.spacing),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)
) {
Column(verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)) {
TitledText(sent)
TitledText(received)
TitledErrorText(error)
@ -220,7 +220,7 @@ fun CellButtons(
onResend: (() -> Unit)? = null,
onDelete: () -> Unit = {},
) {
Cell(margin = PaddingValues(horizontal = LocalDimensions.current.spacing)) {
Cell(modifier = Modifier.padding(horizontal = LocalDimensions.current.spacing)) {
Column {
onReply?.let {
LargeItemButton(
@ -375,7 +375,7 @@ fun PreviewMessageDetails(
fun FileDetails(fileDetails: List<TitledText>) {
if (fileDetails.isEmpty()) return
Cell(margin = PaddingValues(horizontal = LocalDimensions.current.spacing)) {
Cell(modifier = Modifier.padding(horizontal = LocalDimensions.current.spacing)) {
FlowRow(
modifier = Modifier.padding(horizontal = LocalDimensions.current.xsSpacing, vertical = LocalDimensions.current.spacing),
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)

View File

@ -71,10 +71,10 @@ private fun RecoveryPasswordCell(
mutableStateOf(false)
}
Cell(
padding = PaddingValues(all = LocalDimensions.current.smallSpacing)
Cell {
Column(
modifier = Modifier.padding(LocalDimensions.current.smallSpacing)
) {
Column {
Row {
Text(
stringResource(R.string.sessionRecoveryPassword),
@ -152,10 +152,10 @@ private fun RecoveryPassword(mnemonic: String) {
@Composable
private fun HideRecoveryPasswordCell(onHide: () -> Unit = {}) {
Cell(
padding = PaddingValues(all = LocalDimensions.current.smallSpacing)
Cell {
Row(
modifier = Modifier.padding(LocalDimensions.current.smallSpacing)
) {
Row {
Column(
Modifier.weight(1f)
) {

View File

@ -259,19 +259,15 @@ fun PrewviewItemButton() {
@Composable
fun Cell(
modifier: Modifier = Modifier,
padding: PaddingValues = PaddingValues(all = 0.dp),
margin: PaddingValues = PaddingValues(all = 0.dp),
content: @Composable () -> Unit
) {
Box(
modifier = modifier
.padding(margin)
.background(
color = LocalColors.current.backgroundSecondary,
shape = MaterialTheme.shapes.small
)
.wrapContentHeight()
.padding(padding)
.fillMaxWidth(),
) {
content()