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 contentView: UIView? { didSet { updateView() }}
|
||||
open var closeButtonText: String = "Close" { didSet { updateView() }}
|
||||
|
||||
open var presenter: UIView? { didSet { updateView() }}
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration
|
||||
//--------------------------------------------------
|
||||
@ -50,28 +50,41 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
||||
isModalInPresentation = true
|
||||
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() {
|
||||
view.accessibilityElements = [tooltipDialog]
|
||||
|
||||
//left-right swipe
|
||||
view.publisher(for: UISwipeGestureRecognizer().with{ $0.direction = .right })
|
||||
.sink { [weak self] swipe in
|
||||
guard let self else { return }
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
}.store(in: &subscribers)
|
||||
|
||||
guard let self else { return }
|
||||
self.dismiss()
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//tapping in background
|
||||
view.publisher(for: UITapGestureRecognizer().with{ $0.numberOfTapsRequired = 1 })
|
||||
.sink { [weak self] swipe in
|
||||
guard let self else { return }
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
}.store(in: &subscribers)
|
||||
|
||||
guard let self else { return }
|
||||
self.dismiss()
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//clicking button
|
||||
onClickSubscriber = tooltipDialog.closeButton.publisher(for: .touchUpInside)
|
||||
.sink {[weak self] button in
|
||||
guard let self else { return }
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
guard let self else { return }
|
||||
self.dismiss()
|
||||
}
|
||||
|
||||
view.addSubview(tooltipDialog)
|
||||
|
||||
@ -160,9 +173,8 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
//--------------------------------------------------
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
|
||||
layer.cornerRadius = 8
|
||||
|
||||
contentStackView.isAccessibilityElement = true
|
||||
contentStackView.addArrangedSubview(titleLabel)
|
||||
contentStackView.addArrangedSubview(contentLabel)
|
||||
scrollView.addSubview(contentStackView)
|
||||
@ -204,7 +216,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
|
||||
|
||||
backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||
scrollView.indicatorStyle = surface == .light ? .black : .white
|
||||
|
||||
@ -257,6 +269,7 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
closeButton.setTitleColor(closeButtonTextColor, for: .normal)
|
||||
closeButton.setTitleColor(closeButtonTextColor, for: .highlighted)
|
||||
closeButton.setTitle(closeButtonText, for: .normal)
|
||||
closeButton.accessibilityLabel = closeButtonText
|
||||
|
||||
contentStackView.setNeedsLayout()
|
||||
contentStackView.layoutIfNeeded()
|
||||
@ -282,7 +295,19 @@ open class TooltipDialog: View, UIScrollViewDelegate {
|
||||
//stackView between the bottom of the scrollView
|
||||
contentStackViewBottomConstraint?.constant = -containerViewInset
|
||||
}
|
||||
|
||||
|
||||
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