From 2fa433585af3515d095d0dbf51396c97a629a6f3 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:28:22 +1100 Subject: [PATCH] Fixed height for group name editing --- .../groups/compose/EditGroupScreen.kt | 22 ++++++++++++++----- .../securesms/ui/components/Text.kt | 4 ++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/compose/EditGroupScreen.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/compose/EditGroupScreen.kt index 94da3a396b..8e5f4c4be2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/compose/EditGroupScreen.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/compose/EditGroupScreen.kt @@ -7,9 +7,13 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material3.ExperimentalMaterial3Api @@ -150,9 +154,8 @@ fun EditGroup( // Group name title Row( modifier = Modifier - .animateContentSize() .fillMaxWidth() - .padding(LocalDimensions.current.smallSpacing), + .heightIn(min = 72.dp), horizontalArrangement = Arrangement.spacedBy( LocalDimensions.current.xxxsSpacing, Alignment.CenterHorizontally @@ -160,7 +163,9 @@ fun EditGroup( verticalAlignment = CenterVertically, ) { if (editingName != null) { - IconButton(onClick = onEditNameCancelClicked) { + IconButton( + modifier = Modifier.size(LocalDimensions.current.spacing), + onClick = onEditNameCancelClicked) { Icon( painter = painterResource(R.drawable.ic_x), contentDescription = stringResource(R.string.AccessibilityId_cancel), @@ -169,23 +174,30 @@ fun EditGroup( } SessionOutlinedTextField( - modifier = Modifier.width(180.dp), + modifier = Modifier.widthIn( + min = LocalDimensions.current.mediumSpacing, + max = 240.dp + ), text = editingName, onChange = onEditingNameValueChanged, textStyle = LocalType.current.h8, + singleLine = true, innerPadding = PaddingValues( horizontal = LocalDimensions.current.spacing, vertical = LocalDimensions.current.smallSpacing ) ) - IconButton(onClick = onEditNameConfirmed) { + IconButton( + modifier = Modifier.size(LocalDimensions.current.spacing), + onClick = onEditNameConfirmed) { Icon( painter = painterResource(R.drawable.check), contentDescription = stringResource(R.string.AccessibilityId_confirm), tint = LocalColors.current.text, ) } + } else { Text( text = groupName, diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt index 9ad43fea06..f18069f080 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt @@ -40,6 +40,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.max import androidx.compose.ui.unit.sp import network.loki.messenger.R import org.thoughtcrime.securesms.ui.theme.LocalDimensions @@ -51,6 +52,7 @@ import org.thoughtcrime.securesms.ui.theme.textSecondary import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.theme.LocalType import org.thoughtcrime.securesms.ui.theme.bold +import kotlin.math.sin @Preview @Composable @@ -98,6 +100,7 @@ fun SessionOutlinedTextField( error: String? = null, isTextErrorColor: Boolean = error != null, enabled: Boolean = true, + singleLine: Boolean = false, ) { BasicTextField( value = text, @@ -113,6 +116,7 @@ fun SessionOutlinedTextField( onSearch = { onContinue() }, onSend = { onContinue() }, ), + singleLine = singleLine, decorationBox = { innerTextField -> Column(modifier = Modifier.animateContentSize()) { Box(