Display an icon in the room header for rooms with shared history (#5016)
* feat: Display an icon in the room header for rooms with shared history * fix: Apply suggestions from code review - Simplifies `isRoomHistoryShared` expressions using type inferrence. - Adds failure messages to unit test. Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * fix: Remove extension method in favour of field on configuration. * fix: Distinguish between `shared` and `worldReadable` icons. * refactor: Use `RoomHistorySharingState` enum with extension methods --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,7 @@ struct RoomHeaderView: View {
|
||||
var roomSubtitle: String?
|
||||
let roomAvatar: RoomAvatar
|
||||
var dmRecipientVerificationState: UserIdentityVerificationState?
|
||||
var roomHistorySharingState: RoomHistorySharingState?
|
||||
|
||||
let mediaProvider: MediaProviderProtocol?
|
||||
|
||||
@@ -63,6 +64,11 @@ struct RoomHeaderView: View {
|
||||
if let dmRecipientVerificationState {
|
||||
VerificationBadge(verificationState: dmRecipientVerificationState, size: .xSmall, relativeTo: .compound.bodyMDSemibold)
|
||||
}
|
||||
|
||||
if let historySharingIcon {
|
||||
CompoundIcon(historySharingIcon, size: .xSmall, relativeTo: .compound.bodyMDSemibold)
|
||||
.foregroundStyle(.compound.iconInfoPrimary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,6 +79,14 @@ struct RoomHeaderView: View {
|
||||
mediaProvider: mediaProvider)
|
||||
.accessibilityIdentifier(A11yIdentifiers.roomScreen.avatar)
|
||||
}
|
||||
|
||||
private var historySharingIcon: KeyPath<CompoundIcons, Image>? {
|
||||
switch roomHistorySharingState {
|
||||
case .shared: \.history
|
||||
case .worldReadable: \.userProfileSolid
|
||||
case .none: nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension RoomHeaderView {
|
||||
@@ -106,19 +120,26 @@ struct RoomHeaderView_Previews: PreviewProvider, TestablePreview {
|
||||
makeHeader(avatarURL: .mockMXCAvatar,
|
||||
roomSubtitle: "Subtitle",
|
||||
verificationState: .verified)
|
||||
makeHeader(avatarURL: .mockMXCAvatar, verificationState: .notVerified, historySharingState: .shared)
|
||||
makeHeader(avatarURL: .mockMXCAvatar, verificationState: .notVerified, historySharingState: .worldReadable)
|
||||
makeHeader(avatarURL: .mockMXCAvatar, verificationState: .verified, historySharingState: .shared)
|
||||
makeHeader(avatarURL: .mockMXCAvatar, verificationState: .verificationViolation, historySharingState: .worldReadable)
|
||||
}
|
||||
.previewLayout(.sizeThatFits)
|
||||
}
|
||||
|
||||
static func makeHeader(avatarURL: URL?,
|
||||
roomSubtitle: String? = nil,
|
||||
verificationState: UserIdentityVerificationState) -> some View {
|
||||
verificationState: UserIdentityVerificationState,
|
||||
historySharingState: RoomHistorySharingState? = nil) -> some View {
|
||||
RoomHeaderView(roomName: "Some Room name",
|
||||
roomSubtitle: roomSubtitle,
|
||||
roomAvatar: .room(id: "1",
|
||||
name: "Some Room Name",
|
||||
avatarURL: avatarURL),
|
||||
dmRecipientVerificationState: verificationState,
|
||||
roomHistorySharingState: historySharingState,
|
||||
|
||||
mediaProvider: MediaProviderMock(configuration: .init())) { }
|
||||
.padding()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user