Move RoomBadge to atomic package and rename to MatrixBadge
This commit is contained in:
parent
66e51bcea7
commit
86a839ea73
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.theme.ElementTheme
|
||||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||||
import io.element.android.features.leaveroom.api.LeaveRoomView
|
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.BlockUserDialogs
|
||||||
import io.element.android.features.userprofile.shared.blockuser.BlockUserSection
|
import io.element.android.features.userprofile.shared.blockuser.BlockUserSection
|
||||||
import io.element.android.libraries.architecture.coverage.ExcludeFromCoverage
|
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.ClickableLinkText
|
||||||
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
||||||
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
||||||
|
|
@ -412,23 +412,23 @@ private fun BadgeList(
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
) {
|
) {
|
||||||
if (isEncrypted) {
|
if (isEncrypted) {
|
||||||
RoomBadge.View(
|
MatrixBadgeAtom.View(
|
||||||
text = stringResource(R.string.screen_room_details_badge_encrypted),
|
text = stringResource(R.string.screen_room_details_badge_encrypted),
|
||||||
icon = CompoundIcons.LockSolid(),
|
icon = CompoundIcons.LockSolid(),
|
||||||
type = RoomBadge.Type.Positive,
|
type = MatrixBadgeAtom.Type.Positive,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
RoomBadge.View(
|
MatrixBadgeAtom.View(
|
||||||
text = stringResource(R.string.screen_room_details_badge_not_encrypted),
|
text = stringResource(R.string.screen_room_details_badge_not_encrypted),
|
||||||
icon = CompoundIcons.LockOff(),
|
icon = CompoundIcons.LockOff(),
|
||||||
type = RoomBadge.Type.Neutral,
|
type = MatrixBadgeAtom.Type.Neutral,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
RoomBadge.View(
|
MatrixBadgeAtom.View(
|
||||||
text = stringResource(R.string.screen_room_details_badge_public),
|
text = stringResource(R.string.screen_room_details_badge_public),
|
||||||
icon = CompoundIcons.Public(),
|
icon = CompoundIcons.Public(),
|
||||||
type = RoomBadge.Type.Neutral,
|
type = MatrixBadgeAtom.Type.Neutral,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* Please see LICENSE in the repository root for full details.
|
* 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.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
|
@ -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.badgePositiveBackgroundColor
|
||||||
import io.element.android.libraries.designsystem.theme.badgePositiveContentColor
|
import io.element.android.libraries.designsystem.theme.badgePositiveContentColor
|
||||||
|
|
||||||
object RoomBadge {
|
object MatrixBadgeAtom {
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Positive,
|
Positive,
|
||||||
Neutral,
|
Neutral,
|
||||||
Negative
|
Negative
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable fun View(
|
@Composable
|
||||||
|
fun View(
|
||||||
text: String,
|
text: String,
|
||||||
icon: ImageVector,
|
icon: ImageVector,
|
||||||
type: Type,
|
type: Type,
|
||||||
|
|
@ -60,36 +61,30 @@ object RoomBadge {
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun RoomBadgePositivePreview() {
|
internal fun MatrixBadgeAtomPositivePreview() = ElementPreview {
|
||||||
ElementPreview {
|
MatrixBadgeAtom.View(
|
||||||
RoomBadge.View(
|
text = "Trusted",
|
||||||
text = "Trusted",
|
icon = CompoundIcons.Verified(),
|
||||||
icon = CompoundIcons.Verified(),
|
type = MatrixBadgeAtom.Type.Positive,
|
||||||
type = RoomBadge.Type.Positive,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun RoomBadgeNeutralPreview() {
|
internal fun MatrixBadgeAtomNeutralPreview() = ElementPreview {
|
||||||
ElementPreview {
|
MatrixBadgeAtom.View(
|
||||||
RoomBadge.View(
|
text = "Public room",
|
||||||
text = "Public room",
|
icon = CompoundIcons.Public(),
|
||||||
icon = CompoundIcons.Public(),
|
type = MatrixBadgeAtom.Type.Neutral,
|
||||||
type = RoomBadge.Type.Neutral,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun RoomBadgeNegativePreview() {
|
internal fun MatrixBadgeAtomNegativePreview() = ElementPreview {
|
||||||
ElementPreview {
|
MatrixBadgeAtom.View(
|
||||||
RoomBadge.View(
|
text = "Not trusted",
|
||||||
text = "Not trusted",
|
icon = CompoundIcons.Error(),
|
||||||
icon = CompoundIcons.Error(),
|
type = MatrixBadgeAtom.Type.Negative,
|
||||||
type = RoomBadge.Type.Negative,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -71,6 +71,9 @@ class KonsistPreviewTest {
|
||||||
"IconsCompoundPreview",
|
"IconsCompoundPreview",
|
||||||
"IconsOtherPreview",
|
"IconsOtherPreview",
|
||||||
"MarkdownTextComposerEditPreview",
|
"MarkdownTextComposerEditPreview",
|
||||||
|
"MatrixBadgeAtomPositivePreview",
|
||||||
|
"MatrixBadgeAtomNeutralPreview",
|
||||||
|
"MatrixBadgeAtomNegativePreview",
|
||||||
"MentionSpanPreview",
|
"MentionSpanPreview",
|
||||||
"MessageComposerViewVoicePreview",
|
"MessageComposerViewVoicePreview",
|
||||||
"MessagesReactionButtonAddPreview",
|
"MessagesReactionButtonAddPreview",
|
||||||
|
|
@ -95,9 +98,6 @@ class KonsistPreviewTest {
|
||||||
"PollContentViewEndedPreview",
|
"PollContentViewEndedPreview",
|
||||||
"PollContentViewUndisclosedPreview",
|
"PollContentViewUndisclosedPreview",
|
||||||
"ReadReceiptBottomSheetPreview",
|
"ReadReceiptBottomSheetPreview",
|
||||||
"RoomBadgePositivePreview",
|
|
||||||
"RoomBadgeNeutralPreview",
|
|
||||||
"RoomBadgeNegativePreview",
|
|
||||||
"RoomMemberListViewBannedPreview",
|
"RoomMemberListViewBannedPreview",
|
||||||
"SasEmojisPreview",
|
"SasEmojisPreview",
|
||||||
"SecureBackupSetupViewChangePreview",
|
"SecureBackupSetupViewChangePreview",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue