From b2c73ff7a223315fc90be02723f982fb13a28665 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Thu, 22 Aug 2024 22:33:26 +1000 Subject: [PATCH] Simplifying Cell and leaving responsibility to modifier and content --- .../conversation/v2/MessageDetailActivity.kt | 14 +++++++------- .../recoverypassword/RecoveryPassword.kt | 16 ++++++++-------- .../org/thoughtcrime/securesms/ui/Components.kt | 4 ---- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt index b02fefc5e7..065ae8e11d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt @@ -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) - ) { - Column(verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.smallSpacing)) { + Cell(modifier = Modifier.padding(horizontal = LocalDimensions.current.spacing)) { + Column( + modifier = Modifier.padding(LocalDimensions.current.spacing), + 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) { 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) diff --git a/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt b/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt index 4b69622bef..0b47708b5d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt @@ -71,10 +71,10 @@ private fun RecoveryPasswordCell( mutableStateOf(false) } - Cell( - padding = PaddingValues(all = LocalDimensions.current.smallSpacing) - ){ - Column { + Cell { + Column( + modifier = Modifier.padding(LocalDimensions.current.smallSpacing) + ) { 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) - ) { - Row { + Cell { + Row( + modifier = Modifier.padding(LocalDimensions.current.smallSpacing) + ) { Column( Modifier.weight(1f) ) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt index 81d8855ac8..df64f093ec 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt @@ -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()