Manos Chorianopoulos

CouponBarcodeViewController accessibilities

......@@ -90,6 +90,9 @@ import AVFoundation
// Do any additional setup after loading the view.
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
// Temporarily disable the table view's accessibility to prevent immediate focus shift
self.mainView.accessibilityElementsHidden = true
// backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
......@@ -552,6 +555,7 @@ import AVFoundation
print("Coupon Description: " + (couponSetData?.short_description ?? ""))
print("Coupon Expiration: " + (coupon?.expiration ?? ""))
setupAccessibilty()
}
public override func viewWillAppear(_ animated: Bool) {
......@@ -562,6 +566,19 @@ import AVFoundation
self.navigationController?.hideHairline()
}
public override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
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)
......@@ -571,6 +588,44 @@ import AVFoundation
// MARK: - Functions
func setupAccessibilty () {
couponImage.isAccessibilityElement = true
couponImage.accessibilityLabel = "Φωτογραφία εκπτωτικού κουπονιού"
couponImage.accessibilityTraits = .image
var formatedExpiration = ""
let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
if let date = coupon?.expirationDate {
// Set output format in Greek
dateFormatter.locale = Locale(identifier: "el_GR") // Greek locale
dateFormatter.dateFormat = "d MMMM yyyy"
let resultString = dateFormatter.string(from: date)
formatedExpiration = "Ισχύει έως " + resultString
} else {
formatedExpiration = "Ισχύει έως " + (coupon?.expiration ?? "")
}
expirationLabel.isAccessibilityElement = true
expirationLabel.accessibilityLabel = formatedExpiration
redeemButton.isAccessibilityElement = true
redeemButton.accessibilityLabel = redeemButton.title(for: .normal)
redeemButton.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
redeemButton.accessibilityTraits = .button
mapButton.isAccessibilityElement = true
mapButton.accessibilityLabel = mapButton.title(for: .normal)
mapButton.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
mapButton.accessibilityTraits = .button
termsButton.isAccessibilityElement = true
termsButton.accessibilityLabel = termsButton.title(for: .normal)
termsButton.accessibilityHint = "Διπλό πάτημα για εμφάνιση"
termsButton.accessibilityTraits = .button
termsButton.accessibilityValue = "Συμπτυγμένο"
}
func toggleTerms() {
if (termsVisible) {
termsTextView.isHidden = false
......@@ -578,11 +633,18 @@ import AVFoundation
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 = "Διπλό πάτημα για εμφάνιση"
}
}
......