Browse Source

Move RoomBadge to atomic package and rename to MatrixBadge

pull/3718/head
Benoit Marty 2 weeks ago committed by Benoit Marty
parent
commit
77b87af52a
  1. 14
      features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsView.kt
  2. 49
      libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/MatrixBadgeAtom.kt
  3. 6
      tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt

14
features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsView.kt

@ -41,10 +41,10 @@ import im.vector.app.features.analytics.plan.Interaction @@ -41,10 +41,10 @@ import im.vector.app.features.analytics.plan.Interaction
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.leaveroom.api.LeaveRoomView
import io.element.android.features.roomdetails.impl.components.RoomBadge
import io.element.android.features.userprofile.shared.blockuser.BlockUserDialogs
import io.element.android.features.userprofile.shared.blockuser.BlockUserSection
import io.element.android.libraries.architecture.coverage.ExcludeFromCoverage
import io.element.android.libraries.designsystem.atomic.atoms.MatrixBadgeAtom
import io.element.android.libraries.designsystem.components.ClickableLinkText
import io.element.android.libraries.designsystem.components.avatar.AvatarData
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
@ -412,23 +412,23 @@ private fun BadgeList( @@ -412,23 +412,23 @@ private fun BadgeList(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
if (isEncrypted) {
RoomBadge.View(
MatrixBadgeAtom.View(
text = stringResource(R.string.screen_room_details_badge_encrypted),
icon = CompoundIcons.LockSolid(),
type = RoomBadge.Type.Positive,
type = MatrixBadgeAtom.Type.Positive,
)
} else {
RoomBadge.View(
MatrixBadgeAtom.View(
text = stringResource(R.string.screen_room_details_badge_not_encrypted),
icon = CompoundIcons.LockOff(),
type = RoomBadge.Type.Neutral,
type = MatrixBadgeAtom.Type.Neutral,
)
}
if (isPublic) {
RoomBadge.View(
MatrixBadgeAtom.View(
text = stringResource(R.string.screen_room_details_badge_public),
icon = CompoundIcons.Public(),
type = RoomBadge.Type.Neutral,
type = MatrixBadgeAtom.Type.Neutral,
)
}
}

49
features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/components/RoomBadge.kt → libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/atoms/MatrixBadgeAtom.kt

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.features.roomdetails.impl.components
package io.element.android.libraries.designsystem.atomic.atoms
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
@ -21,14 +21,15 @@ import io.element.android.libraries.designsystem.theme.badgeNeutralContentColor @@ -21,14 +21,15 @@ import io.element.android.libraries.designsystem.theme.badgeNeutralContentColor
import io.element.android.libraries.designsystem.theme.badgePositiveBackgroundColor
import io.element.android.libraries.designsystem.theme.badgePositiveContentColor
object RoomBadge {
object MatrixBadgeAtom {
enum class Type {
Positive,
Neutral,
Negative
}
@Composable fun View(
@Composable
fun View(
text: String,
icon: ImageVector,
type: Type,
@ -60,36 +61,30 @@ object RoomBadge { @@ -60,36 +61,30 @@ object RoomBadge {
@PreviewsDayNight
@Composable
internal fun RoomBadgePositivePreview() {
ElementPreview {
RoomBadge.View(
text = "Trusted",
icon = CompoundIcons.Verified(),
type = RoomBadge.Type.Positive,
)
}
internal fun MatrixBadgeAtomPositivePreview() = ElementPreview {
MatrixBadgeAtom.View(
text = "Trusted",
icon = CompoundIcons.Verified(),
type = MatrixBadgeAtom.Type.Positive,
)
}
@PreviewsDayNight
@Composable
internal fun RoomBadgeNeutralPreview() {
ElementPreview {
RoomBadge.View(
text = "Public room",
icon = CompoundIcons.Public(),
type = RoomBadge.Type.Neutral,
)
}
internal fun MatrixBadgeAtomNeutralPreview() = ElementPreview {
MatrixBadgeAtom.View(
text = "Public room",
icon = CompoundIcons.Public(),
type = MatrixBadgeAtom.Type.Neutral,
)
}
@PreviewsDayNight
@Composable
internal fun RoomBadgeNegativePreview() {
ElementPreview {
RoomBadge.View(
text = "Not trusted",
icon = CompoundIcons.Error(),
type = RoomBadge.Type.Negative,
)
}
internal fun MatrixBadgeAtomNegativePreview() = ElementPreview {
MatrixBadgeAtom.View(
text = "Not trusted",
icon = CompoundIcons.Error(),
type = MatrixBadgeAtom.Type.Negative,
)
}

6
tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt

@ -71,6 +71,9 @@ class KonsistPreviewTest { @@ -71,6 +71,9 @@ class KonsistPreviewTest {
"IconsCompoundPreview",
"IconsOtherPreview",
"MarkdownTextComposerEditPreview",
"MatrixBadgeAtomPositivePreview",
"MatrixBadgeAtomNeutralPreview",
"MatrixBadgeAtomNegativePreview",
"MentionSpanPreview",
"MessageComposerViewVoicePreview",
"MessagesReactionButtonAddPreview",
@ -95,9 +98,6 @@ class KonsistPreviewTest { @@ -95,9 +98,6 @@ class KonsistPreviewTest {
"PollContentViewEndedPreview",
"PollContentViewUndisclosedPreview",
"ReadReceiptBottomSheetPreview",
"RoomBadgePositivePreview",
"RoomBadgeNeutralPreview",
"RoomBadgeNegativePreview",
"RoomMemberListViewBannedPreview",
"SasEmojisPreview",
"SecureBackupSetupViewChangePreview",

Loading…
Cancel
Save