From 3dfbd0892d463d8657a2df2253ca1c2c14bac937 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Fri, 20 Sep 2024 10:29:11 +1000 Subject: [PATCH] Cleaned up ItemButton to work in both its variations --- .../start/home/StartConversation.kt | 6 ++--- .../thoughtcrime/securesms/ui/Components.kt | 22 ++++++++++++++----- .../securesms/ui/theme/Dimensions.kt | 1 - 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt index f00fbf44a9..f65dce4974 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt @@ -66,21 +66,21 @@ internal fun StartConversationScreen( icon = R.drawable.ic_message, modifier = Modifier.contentDescription(R.string.AccessibilityId_messageNew), onClick = delegate::onNewMessageSelected) - Divider(startIndent = LocalDimensions.current.dividerIndent) + Divider(startIndent = LocalDimensions.current.minItemButtonHeight) ItemButton( textId = R.string.groupCreate, icon = R.drawable.ic_group, modifier = Modifier.contentDescription(R.string.AccessibilityId_groupCreate), onClick = delegate::onCreateGroupSelected ) - Divider(startIndent = LocalDimensions.current.dividerIndent) + Divider(startIndent = LocalDimensions.current.minItemButtonHeight) ItemButton( textId = R.string.communityJoin, icon = R.drawable.ic_globe, modifier = Modifier.contentDescription(R.string.AccessibilityId_communityJoin), onClick = delegate::onJoinCommunitySelected ) - Divider(startIndent = LocalDimensions.current.dividerIndent) + Divider(startIndent = LocalDimensions.current.minItemButtonHeight) ItemButton( textId = R.string.sessionInviteAFriend, icon = R.drawable.ic_invite_friend, 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 6f6992474f..1a8a917f40 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt @@ -275,19 +275,17 @@ fun ItemButton( onClick: () -> Unit ) { TextButton( - modifier = modifier.fillMaxWidth() - .height(IntrinsicSize.Min) - .heightIn(min = minHeight), + modifier = modifier.fillMaxWidth(), colors = colors, onClick = onClick, contentPadding = PaddingValues(), shape = RectangleShape, ) { Box( - modifier = Modifier.fillMaxHeight() - .align(Alignment.CenterVertically) + modifier = Modifier .padding(horizontal = LocalDimensions.current.xxsSpacing) - .aspectRatio(1f), + .size(minHeight) + .align(Alignment.CenterVertically), content = icon ) @@ -313,6 +311,18 @@ fun PreviewItemButton() { } } +@Preview +@Composable +fun PreviewLargeItemButton() { + PreviewTheme { + LargeItemButton( + textId = R.string.groupCreate, + icon = R.drawable.ic_group, + onClick = {} + ) + } +} + @Composable fun Cell( modifier: Modifier = Modifier, diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Dimensions.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Dimensions.kt index ac5ce8c4cf..d1608ea24e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Dimensions.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Dimensions.kt @@ -15,7 +15,6 @@ data class Dimensions( val mediumSpacing: Dp = 36.dp, val xlargeSpacing: Dp = 64.dp, - val dividerIndent: Dp = 60.dp, val appBarHeight: Dp = 64.dp, val minItemButtonHeight: Dp = 50.dp, val minLargeItemButtonHeight: Dp = 60.dp,