From fd09e6ef17efa7c3240ac0cc8f11b8b5c0b9425b Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Wed, 10 Feb 2021 19:02:54 -0800 Subject: [PATCH] VoiceOver --- Views/UIKit/Content Views/StatusView.swift | 61 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/Views/UIKit/Content Views/StatusView.swift b/Views/UIKit/Content Views/StatusView.swift index 6c42fbd..42e5f61 100644 --- a/Views/UIKit/Content Views/StatusView.swift +++ b/Views/UIKit/Content Views/StatusView.swift @@ -696,7 +696,6 @@ private extension StatusView { title: NSLocalizedString("account.unblock", comment: ""), image: UIImage(systemName: "slash.circle"), attributes: .destructive) { _ in -// viewModel.accountViewModel.unblock() viewModel.accountViewModel.confirmUnblock() }) } else { @@ -871,7 +870,7 @@ private extension StatusView { || statusConfiguration.viewModel.configuration.isContextParent } - // swiftlint:disable:next function_body_length + // swiftlint:disable:next function_body_length cyclomatic_complexity func accessibilityCustomActions(viewModel: StatusViewModel) -> [UIAccessibilityCustomAction] { guard !viewModel.configuration.isContextParent else { return [] @@ -991,12 +990,70 @@ private extension StatusView { } ] } else { + if let relationship = viewModel.accountViewModel.relationship { + if relationship.muting { + actions.append(UIAccessibilityCustomAction( + name: NSLocalizedString("account.unmute", comment: "")) { _ in + viewModel.accountViewModel.confirmUnmute() + + return true + }) + } else { + actions.append(UIAccessibilityCustomAction( + name: NSLocalizedString("account.mute", comment: "")) { _ in + viewModel.accountViewModel.confirmMute() + + return true + }) + } + + if relationship.blocking { + actions.append(UIAccessibilityCustomAction( + name: NSLocalizedString("account.unblock", comment: "")) { _ in + viewModel.accountViewModel.confirmUnblock() + + return true + }) + } else { + actions.append(UIAccessibilityCustomAction( + name: NSLocalizedString("account.block", comment: "")) { _ in + viewModel.accountViewModel.confirmBlock() + + return true + }) + } + } actions.append(UIAccessibilityCustomAction( name: NSLocalizedString("report", comment: "")) { _ in viewModel.reportStatus() return true }) + + if !viewModel.accountViewModel.isLocal, + let domain = viewModel.accountViewModel.domain, + let relationship = viewModel.accountViewModel.relationship { + + if relationship.domainBlocking { + actions.append(UIAccessibilityCustomAction( + name: String.localizedStringWithFormat( + NSLocalizedString("account.domain-unblock-%@", comment: ""), + domain)) { _ in + viewModel.accountViewModel.confirmDomainUnblock(domain: domain) + + return true + }) + } else { + actions.append(UIAccessibilityCustomAction( + name: String.localizedStringWithFormat( + NSLocalizedString("account.domain-block-%@", comment: ""), + domain)) { _ in + viewModel.accountViewModel.confirmDomainBlock(domain: domain) + + return true + }) + } + } } }