* replace NavigationStack with ElementNavigationStack to allow the content to be rendered without a NavigationStack in a11y tests * fix a11y tests * update xcodeproject * swiftformat fix * use iOS 26.1 for CI * use a wrapper to solve the issue for a11y tests * ElementNavigationStack only uses the trick in DEBUG mode, and added a swiftlint rule to prevent the usage of NavigationStack
81 lines
2.5 KiB
Swift
81 lines
2.5 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2022-2025 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 Compound
|
|
import SwiftUI
|
|
|
|
struct ReportContentScreen: View {
|
|
@Bindable var context: ReportContentScreenViewModel.Context
|
|
|
|
var body: some View {
|
|
Form {
|
|
reasonSection
|
|
|
|
ignoreUserSection
|
|
}
|
|
.scrollDismissesKeyboard(.immediately)
|
|
.compoundList()
|
|
.navigationTitle(L10n.actionReportContent)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar { toolbar }
|
|
.interactiveDismissDisabled()
|
|
}
|
|
|
|
private var reasonSection: some View {
|
|
Section {
|
|
ListRow(label: .plain(title: L10n.screenReportContentHint),
|
|
kind: .textField(text: $context.reasonText, axis: .vertical))
|
|
.lineLimit(4, reservesSpace: true)
|
|
} footer: {
|
|
Text(L10n.screenReportContentExplanation)
|
|
.compoundListSectionFooter()
|
|
}
|
|
}
|
|
|
|
private var ignoreUserSection: some View {
|
|
Section {
|
|
ListRow(label: .plain(title: L10n.screenReportContentBlockUser),
|
|
kind: .toggle($context.ignoreUser))
|
|
.accessibilityIdentifier(A11yIdentifiers.reportContent.ignoreUser)
|
|
} footer: {
|
|
Text(L10n.screenReportContentBlockUserHint)
|
|
.compoundListSectionFooter()
|
|
}
|
|
}
|
|
|
|
@ToolbarContentBuilder
|
|
private var toolbar: some ToolbarContent {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button(L10n.actionCancel) {
|
|
context.send(viewAction: .cancel)
|
|
}
|
|
}
|
|
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button(L10n.actionSend) {
|
|
context.send(viewAction: .submit)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - Previews
|
|
|
|
struct ReportContentScreen_Previews: PreviewProvider, TestablePreview {
|
|
static let viewModel = ReportContentScreenViewModel(eventID: "",
|
|
senderID: "",
|
|
roomProxy: JoinedRoomProxyMock(.init()),
|
|
clientProxy: ClientProxyMock(.init()))
|
|
|
|
static var previews: some View {
|
|
ElementNavigationStack {
|
|
ReportContentScreen(context: viewModel.context)
|
|
}
|
|
}
|
|
}
|