* running all the tests * setting up CI * fixed the workflow * workflow on pull request, just to make it appear * removed the test to run var * fix archived tests name * improved the tests, by filtering out some noise * pr suggestions and added an improvement to the filtering * improved the interrupt handler * improved the UI interruption monitor handler * some more refinement to handle the interruptor + false positive for non human readable labels * reverted wrong commit * ready for review, removed the on pull request check * pr suggestions
82 lines
3.1 KiB
Swift
82 lines
3.1 KiB
Swift
//
|
|
// Copyright 2022-2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Combine
|
|
import Compound
|
|
import SwiftUI
|
|
|
|
struct RoomHeaderView: View {
|
|
let roomName: String
|
|
let roomAvatar: RoomAvatar
|
|
var dmRecipientVerificationState: UserIdentityVerificationState?
|
|
|
|
let mediaProvider: MediaProviderProtocol?
|
|
|
|
var body: some View {
|
|
if #available(iOS 19, *) {
|
|
// https://github.com/element-hq/element-x-ios/issues/4180
|
|
// Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSLayoutConstraint constant is not finite!
|
|
content
|
|
} else if ProcessInfo.isRunningAccessibilityTests {
|
|
// Accessibility tests scale up the dynamic size in real time which may break the view
|
|
content
|
|
} else {
|
|
content
|
|
// Take up as much space as possible, with a leading alignment for use in the principal toolbar position
|
|
.frame(idealWidth: .greatestFiniteMagnitude, maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
}
|
|
|
|
private var content: some View {
|
|
HStack(spacing: 8) {
|
|
avatarImage
|
|
.accessibilityHidden(true)
|
|
|
|
HStack(spacing: 4) {
|
|
Text(roomName)
|
|
.lineLimit(1)
|
|
.font(.compound.bodyLGSemibold)
|
|
.accessibilityIdentifier(A11yIdentifiers.roomScreen.name)
|
|
|
|
if let dmRecipientVerificationState {
|
|
VerificationBadge(verificationState: dmRecipientVerificationState)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private var avatarImage: some View {
|
|
RoomAvatarImage(avatar: roomAvatar,
|
|
avatarSize: .room(on: .timeline),
|
|
mediaProvider: mediaProvider)
|
|
.accessibilityIdentifier(A11yIdentifiers.roomScreen.avatar)
|
|
}
|
|
}
|
|
|
|
struct RoomHeaderView_Previews: PreviewProvider, TestablePreview {
|
|
static var previews: some View {
|
|
VStack(spacing: 8) {
|
|
makeHeader(avatarURL: nil, verificationState: .notVerified)
|
|
makeHeader(avatarURL: .mockMXCAvatar, verificationState: .notVerified)
|
|
makeHeader(avatarURL: .mockMXCAvatar, verificationState: .verified)
|
|
makeHeader(avatarURL: .mockMXCAvatar, verificationState: .verificationViolation)
|
|
}
|
|
.previewLayout(.sizeThatFits)
|
|
}
|
|
|
|
static func makeHeader(avatarURL: URL?,
|
|
verificationState: UserIdentityVerificationState) -> some View {
|
|
RoomHeaderView(roomName: "Some Room name",
|
|
roomAvatar: .room(id: "1",
|
|
name: "Some Room Name",
|
|
avatarURL: avatarURL),
|
|
dmRecipientVerificationState: verificationState,
|
|
mediaProvider: MediaProviderMock(configuration: .init()))
|
|
.padding()
|
|
}
|
|
}
|