Skip to content

Commit c550436

Browse files
jmartinespElementBot
and
ElementBot
authored
Fix MainActionButton layout for long texts (#3158)
* Fix `MainActionButton` layout for long texts * Update screenshots --------- Co-authored-by: ElementBot <[email protected]>
1 parent d9a498c commit c550436

File tree

42 files changed

+97
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+97
-85
lines changed

libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/button/MainActionButton.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ package io.element.android.libraries.designsystem.components.button
1818

1919
import androidx.compose.foundation.clickable
2020
import androidx.compose.foundation.interaction.MutableInteractionSource
21+
import androidx.compose.foundation.layout.Arrangement
2122
import androidx.compose.foundation.layout.Column
2223
import androidx.compose.foundation.layout.Row
2324
import androidx.compose.foundation.layout.Spacer
2425
import androidx.compose.foundation.layout.height
2526
import androidx.compose.foundation.layout.padding
26-
import androidx.compose.foundation.layout.width
2727
import androidx.compose.foundation.layout.widthIn
2828
import androidx.compose.material.ripple.rememberRipple
2929
import androidx.compose.material3.LocalContentColor
@@ -33,6 +33,9 @@ import androidx.compose.runtime.remember
3333
import androidx.compose.ui.Alignment
3434
import androidx.compose.ui.Modifier
3535
import androidx.compose.ui.graphics.vector.ImageVector
36+
import androidx.compose.ui.text.style.Hyphens
37+
import androidx.compose.ui.text.style.TextAlign
38+
import androidx.compose.ui.text.style.TextOverflow
3639
import androidx.compose.ui.tooling.preview.Preview
3740
import androidx.compose.ui.unit.dp
3841
import io.element.android.compound.theme.ElementTheme
@@ -61,7 +64,7 @@ fun MainActionButton(
6164
onClick = onClick,
6265
indication = ripple
6366
)
64-
.widthIn(min = 76.dp),
67+
.widthIn(min = 76.dp, max = 96.dp),
6568
horizontalAlignment = Alignment.CenterHorizontally,
6669
) {
6770
val tintColor = if (enabled) LocalContentColor.current else MaterialTheme.colorScheme.secondary
@@ -73,8 +76,10 @@ fun MainActionButton(
7376
Spacer(modifier = Modifier.height(14.dp))
7477
Text(
7578
title,
76-
style = ElementTheme.typography.fontBodyMdMedium,
79+
style = ElementTheme.typography.fontBodyMdMedium.copy(hyphens = Hyphens.Auto),
7780
color = tintColor,
81+
overflow = TextOverflow.Visible,
82+
textAlign = TextAlign.Center,
7883
)
7984
}
8085
}
@@ -89,13 +94,20 @@ internal fun MainActionButtonPreview() {
8994

9095
@Composable
9196
private fun ContentsToPreview() {
92-
Row(Modifier.padding(10.dp)) {
97+
Row(
98+
modifier = Modifier.padding(10.dp),
99+
horizontalArrangement = Arrangement.spacedBy(20.dp)
100+
) {
93101
MainActionButton(
94102
title = "Share",
95103
imageVector = CompoundIcons.ShareAndroid(),
96104
onClick = { },
97105
)
98-
Spacer(modifier = Modifier.width(20.dp))
106+
MainActionButton(
107+
title = "Share with a long text",
108+
imageVector = CompoundIcons.ShareAndroid(),
109+
onClick = { },
110+
)
99111
MainActionButton(
100112
title = "Share",
101113
imageVector = CompoundIcons.ShareAndroid(),
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 1 addition & 1 deletion
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)