Add history sharing badges to room details (#6132)

* feat: Add history sharing badges to room details view

* tests: Add snapshots for history sharing room details badges

* fix: Disable soft-wrapping in badges, use FlowRow

* tests: Add unit test for `RoomDetailsState` and history sharing badges.

* tests: Add `MatrixBadgeAtomNeutralWrappingPreview` to exceptions

* chore: Re-order `MatrixBadgeAtom` previews

* fix: Add `Immutable` annotation to `RoomHistoryVisibility`.

* fix: Correct translation for shared badge
This commit is contained in:
Skye Elliot 2026-02-06 19:03:52 +00:00 committed by GitHub
parent 26de441215
commit 1e268b0709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 156 additions and 3 deletions

View file

@ -98,6 +98,18 @@ internal fun MatrixBadgeAtomNegativePreview() = ElementPreview {
)
}
@PreviewsDayNight
@Composable
internal fun MatrixBadgeAtomNeutralWrappingPreview() = ElementPreview {
MatrixBadgeAtom.View(
MatrixBadgeAtom.MatrixBadgeData(
text = "How much wood could a wood chuck chuck if a wood chuck could chuck wood",
icon = CompoundIcons.LockOff(),
type = MatrixBadgeAtom.Type.Info,
)
)
}
@PreviewsDayNight
@Composable
internal fun MatrixBadgeAtomInfoPreview() = ElementPreview {

View file

@ -9,9 +9,10 @@
package io.element.android.libraries.designsystem.atomic.molecules
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.atomic.atoms.MatrixBadgeAtom
@ -22,10 +23,11 @@ fun MatrixBadgeRowMolecule(
data: ImmutableList<MatrixBadgeAtom.MatrixBadgeData>,
modifier: Modifier = Modifier,
) {
Row(
FlowRow(
modifier = modifier
.padding(start = 16.dp, end = 16.dp, top = 8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
for (badge in data) {
MatrixBadgeAtom.View(badge)

View file

@ -21,6 +21,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
@ -63,6 +64,8 @@ fun Badge(
text = text,
style = ElementTheme.typography.fontBodySmRegular,
color = textColor,
overflow = TextOverflow.Ellipsis,
softWrap = false,
)
}
}