Move RoomBadge to atomic package and rename to MatrixBadge
This commit is contained in:
parent
1bfa43b6d8
commit
77b87af52a
3 changed files with 32 additions and 37 deletions
|
|
@ -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(
|
|||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.roomdetails.impl.components
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||
import io.element.android.libraries.designsystem.components.Badge
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.badgeNegativeBackgroundColor
|
||||
import io.element.android.libraries.designsystem.theme.badgeNegativeContentColor
|
||||
import io.element.android.libraries.designsystem.theme.badgeNeutralBackgroundColor
|
||||
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 {
|
||||
enum class Type {
|
||||
Positive,
|
||||
Neutral,
|
||||
Negative
|
||||
}
|
||||
|
||||
@Composable fun View(
|
||||
text: String,
|
||||
icon: ImageVector,
|
||||
type: Type,
|
||||
) {
|
||||
val backgroundColor = when (type) {
|
||||
Type.Positive -> ElementTheme.colors.badgePositiveBackgroundColor
|
||||
Type.Neutral -> ElementTheme.colors.badgeNeutralBackgroundColor
|
||||
Type.Negative -> ElementTheme.colors.badgeNegativeBackgroundColor
|
||||
}
|
||||
val textColor = when (type) {
|
||||
Type.Positive -> ElementTheme.colors.badgePositiveContentColor
|
||||
Type.Neutral -> ElementTheme.colors.badgeNeutralContentColor
|
||||
Type.Negative -> ElementTheme.colors.badgeNegativeContentColor
|
||||
}
|
||||
val iconColor = when (type) {
|
||||
Type.Positive -> ElementTheme.colors.iconSuccessPrimary
|
||||
Type.Neutral -> ElementTheme.colors.iconSecondary
|
||||
Type.Negative -> ElementTheme.colors.iconCriticalPrimary
|
||||
}
|
||||
Badge(
|
||||
text = text,
|
||||
icon = icon,
|
||||
backgroundColor = backgroundColor,
|
||||
iconColor = iconColor,
|
||||
textColor = textColor,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun RoomBadgePositivePreview() {
|
||||
ElementPreview {
|
||||
RoomBadge.View(
|
||||
text = "Trusted",
|
||||
icon = CompoundIcons.Verified(),
|
||||
type = RoomBadge.Type.Positive,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun RoomBadgeNeutralPreview() {
|
||||
ElementPreview {
|
||||
RoomBadge.View(
|
||||
text = "Public room",
|
||||
icon = CompoundIcons.Public(),
|
||||
type = RoomBadge.Type.Neutral,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun RoomBadgeNegativePreview() {
|
||||
ElementPreview {
|
||||
RoomBadge.View(
|
||||
text = "Not trusted",
|
||||
icon = CompoundIcons.Error(),
|
||||
type = RoomBadge.Type.Negative,
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue