Make the translation info view accessible at the root of a thread
This commit is contained in:
parent
3b87916d9a
commit
9c30ecd9c0
|
@ -108,6 +108,7 @@ extension StatusThreadRootTableViewCell {
|
||||||
statusView.viewModel.isContentReveal
|
statusView.viewModel.isContentReveal
|
||||||
? statusView.contentMetaText.textView
|
? statusView.contentMetaText.textView
|
||||||
: statusView.spoilerOverlayView,
|
: statusView.spoilerOverlayView,
|
||||||
|
statusView.translatedInfoView,
|
||||||
statusView.mediaGridContainerView,
|
statusView.mediaGridContainerView,
|
||||||
statusView.pollTableView,
|
statusView.pollTableView,
|
||||||
statusView.pollStatusStackView,
|
statusView.pollStatusStackView,
|
||||||
|
|
|
@ -197,8 +197,17 @@ public final class StatusView: UIView {
|
||||||
label.numberOfLines = 0
|
label.numberOfLines = 0
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
lazy var translatedInfoView: UIView = {
|
|
||||||
let containerView = UIView()
|
private class TranslatedInfoView: UIView {
|
||||||
|
var revertAction: (() -> Void)?
|
||||||
|
|
||||||
|
override func accessibilityActivate() -> Bool {
|
||||||
|
revertAction?()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public private(set) lazy var translatedInfoView: UIView = {
|
||||||
|
let containerView = TranslatedInfoView()
|
||||||
|
|
||||||
let revertButton = UIButton()
|
let revertButton = UIButton()
|
||||||
revertButton.titleLabel?.font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 13, weight: .bold))
|
revertButton.titleLabel?.font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 13, weight: .bold))
|
||||||
|
@ -231,6 +240,13 @@ public final class StatusView: UIView {
|
||||||
|
|
||||||
containerView.isHidden = true
|
containerView.isHidden = true
|
||||||
|
|
||||||
|
containerView.isAccessibilityElement = true
|
||||||
|
containerView.accessibilityLabel = L10n.Common.Controls.Status.Translation.showOriginal
|
||||||
|
containerView.accessibilityTraits = [.button]
|
||||||
|
containerView.revertAction = { [weak self] in
|
||||||
|
self?.revertTranslation()
|
||||||
|
}
|
||||||
|
|
||||||
return containerView
|
return containerView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -750,10 +766,12 @@ extension StatusView {
|
||||||
.sink { [weak self] translatedFromLanguage, translatedUsingProvider in
|
.sink { [weak self] translatedFromLanguage, translatedUsingProvider in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
if let translatedFromLanguage = translatedFromLanguage {
|
if let translatedFromLanguage = translatedFromLanguage {
|
||||||
self.translatedInfoLabel.text = L10n.Common.Controls.Status.Translation.translatedFrom(
|
let label = L10n.Common.Controls.Status.Translation.translatedFrom(
|
||||||
Locale.current.localizedString(forIdentifier: translatedFromLanguage) ?? L10n.Common.Controls.Status.Translation.unknownLanguage,
|
Locale.current.localizedString(forIdentifier: translatedFromLanguage) ?? L10n.Common.Controls.Status.Translation.unknownLanguage,
|
||||||
translatedUsingProvider ?? L10n.Common.Controls.Status.Translation.unknownProvider
|
translatedUsingProvider ?? L10n.Common.Controls.Status.Translation.unknownProvider
|
||||||
)
|
)
|
||||||
|
self.translatedInfoLabel.text = label
|
||||||
|
self.translatedInfoView.accessibilityValue = label
|
||||||
self.translatedInfoView.isHidden = false
|
self.translatedInfoView.isHidden = false
|
||||||
} else {
|
} else {
|
||||||
self.translatedInfoView.isHidden = true
|
self.translatedInfoView.isHidden = true
|
||||||
|
|
Loading…
Reference in New Issue