update for bug
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2c7666c214
commit
d275c476b3
@ -36,7 +36,7 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
|||||||
open var contentText: String? { didSet { updateView() }}
|
open var contentText: String? { didSet { updateView() }}
|
||||||
open var contentView: UIView? { didSet { updateView() }}
|
open var contentView: UIView? { didSet { updateView() }}
|
||||||
open var closeButtonText: String = "Close" { didSet { updateView() }}
|
open var closeButtonText: String = "Close" { didSet { updateView() }}
|
||||||
|
open var presenter: UIView? { didSet { updateView() }}
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -50,28 +50,41 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
|||||||
isModalInPresentation = true
|
isModalInPresentation = true
|
||||||
setup()
|
setup()
|
||||||
}
|
}
|
||||||
|
open override func viewDidAppear(_ animated: Bool) {
|
||||||
|
super.viewDidAppear(animated)
|
||||||
|
UIAccessibility.post(notification: .screenChanged, argument: tooltipDialog)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func dismiss() {
|
||||||
|
dismiss(animated: true) { [weak self] in
|
||||||
|
guard let self, let presenter else { return }
|
||||||
|
UIAccessibility.post(notification: .layoutChanged, argument: presenter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open func setup() {
|
open func setup() {
|
||||||
|
view.accessibilityElements = [tooltipDialog]
|
||||||
|
|
||||||
//left-right swipe
|
//left-right swipe
|
||||||
view.publisher(for: UISwipeGestureRecognizer().with{ $0.direction = .right })
|
view.publisher(for: UISwipeGestureRecognizer().with{ $0.direction = .right })
|
||||||
.sink { [weak self] swipe in
|
.sink { [weak self] swipe in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
self.dismiss(animated: true, completion: nil)
|
self.dismiss()
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
//tapping in background
|
//tapping in background
|
||||||
view.publisher(for: UITapGestureRecognizer().with{ $0.numberOfTapsRequired = 1 })
|
view.publisher(for: UITapGestureRecognizer().with{ $0.numberOfTapsRequired = 1 })
|
||||||
.sink { [weak self] swipe in
|
.sink { [weak self] swipe in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
self.dismiss(animated: true, completion: nil)
|
self.dismiss()
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
//clicking button
|
//clicking button
|
||||||
onClickSubscriber = tooltipDialog.closeButton.publisher(for: .touchUpInside)
|
onClickSubscriber = tooltipDialog.closeButton.publisher(for: .touchUpInside)
|
||||||
.sink {[weak self] button in
|
.sink {[weak self] button in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
self.dismiss(animated: true, completion: nil)
|
self.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
view.addSubview(tooltipDialog)
|
view.addSubview(tooltipDialog)
|
||||||
|
|
||||||
@ -160,9 +173,8 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
layer.cornerRadius = 8
|
layer.cornerRadius = 8
|
||||||
|
contentStackView.isAccessibilityElement = true
|
||||||
contentStackView.addArrangedSubview(titleLabel)
|
contentStackView.addArrangedSubview(titleLabel)
|
||||||
contentStackView.addArrangedSubview(contentLabel)
|
contentStackView.addArrangedSubview(contentLabel)
|
||||||
scrollView.addSubview(contentStackView)
|
scrollView.addSubview(contentStackView)
|
||||||
@ -257,6 +269,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
|||||||
closeButton.setTitleColor(closeButtonTextColor, for: .normal)
|
closeButton.setTitleColor(closeButtonTextColor, for: .normal)
|
||||||
closeButton.setTitleColor(closeButtonTextColor, for: .highlighted)
|
closeButton.setTitleColor(closeButtonTextColor, for: .highlighted)
|
||||||
closeButton.setTitle(closeButtonText, for: .normal)
|
closeButton.setTitle(closeButtonText, for: .normal)
|
||||||
|
closeButton.accessibilityLabel = closeButtonText
|
||||||
|
|
||||||
contentStackView.setNeedsLayout()
|
contentStackView.setNeedsLayout()
|
||||||
contentStackView.layoutIfNeeded()
|
contentStackView.layoutIfNeeded()
|
||||||
@ -285,4 +298,16 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
|||||||
|
|
||||||
heightConstraint?.constant = contentHeight
|
heightConstraint?.constant = contentHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func updateAccessibilityLabel() {
|
||||||
|
var label = Tooltip.accessibleText(for: titleText, content: contentText, closeButtonText: closeButtonText)
|
||||||
|
if !label.isEmpty {
|
||||||
|
label += ","
|
||||||
|
}
|
||||||
|
|
||||||
|
contentStackView.accessibilityLabel = "\(label) Click on the \(closeButtonText) button to close."
|
||||||
|
contentStackView.accessibilityHint = "Tooltip"
|
||||||
|
contentStackView.accessibilityValue = "expanded"
|
||||||
|
accessibilityElements = [contentStackView, closeButton]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user