Manos Chorianopoulos

CouponViewController accessibilities

......@@ -49,10 +49,15 @@ import SwiftEventBus
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
// Temporarily disable the table view's accessibility to prevent immediate focus shift
// self.mainView.accessibilityElementsHidden = true
// if ((profile != nil) && (profile?._nonTelco == true)) {
if (swiftApi().getUserNonTelco() == true) {
nonTelcoDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές.");
}
// if (swiftApi().getUserNonTelco() == true) {
// nonTelcoDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές.");
// } else {
// UIAccessibility.post(notification: .screenChanged, argument: self.navigationItem.titleView)
// }
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
......@@ -138,6 +143,7 @@ import SwiftEventBus
toggleTerms()
setupAccessibilty()
}
public override func viewWillAppear(_ animated: Bool) {
......@@ -148,6 +154,22 @@ import SwiftEventBus
self.navigationController?.hideHairline()
}
public override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// if ((profile != nil) && (profile?._nonTelco == true)) {
if (swiftApi().getUserNonTelco() == true) {
nonTelcoDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές.");
} else {
UIAccessibility.post(notification: .screenChanged, argument: self.navigationItem.titleView)
}
// Re-enable table view accessibility after the announcement
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
// self.mainView.accessibilityElementsHidden = false
// }
}
public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
......@@ -156,6 +178,23 @@ import SwiftEventBus
}
// MARK: - Functions
func setupAccessibilty() {
couponImage.isAccessibilityElement = true
couponImage.accessibilityLabel = "Φωτογραφία εκπτωτικού κουπονιού"
couponImage.accessibilityTraits = .image
redeemButton.isAccessibilityElement = true
redeemButton.accessibilityLabel = redeemButton.title(for: .normal)
redeemButton.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
redeemButton.accessibilityTraits = .button
termsButton.isAccessibilityElement = true
termsButton.accessibilityLabel = termsButton.title(for: .normal)
termsButton.accessibilityHint = "Διπλό πάτημα για εμφάνιση"
termsButton.accessibilityTraits = .button
termsButton.accessibilityValue = "Συμπτυγμένο"
}
func nonTelcoDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
......@@ -183,11 +222,17 @@ import SwiftEventBus
termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
termsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.accessibilityValue = "Ανεπτυγμένο"
termsButton.accessibilityHint = "Διπλό πάτημα για απόκρυψη"
} else {
termsTextView.isHidden = true
termsTextViewHeight.constant = CGFloat(0)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.accessibilityValue = "Συμπτυγμένο"
termsButton.accessibilityHint = "Διπλό πάτημα για εμφάνιση"
}
}
......