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

View File

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

View File

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