Manos Chorianopoulos

CouponViewController accessibilities

...@@ -49,10 +49,15 @@ import SwiftEventBus ...@@ -49,10 +49,15 @@ import SwiftEventBus
49 setBackButton() 49 setBackButton()
50 setNavigationTitle("Εκπτωτικό κουπόνι") 50 setNavigationTitle("Εκπτωτικό κουπόνι")
51 51
52 + // Temporarily disable the table view's accessibility to prevent immediate focus shift
53 + // self.mainView.accessibilityElementsHidden = true
54 +
52 // if ((profile != nil) && (profile?._nonTelco == true)) { 55 // if ((profile != nil) && (profile?._nonTelco == true)) {
53 - if (swiftApi().getUserNonTelco() == true) { 56 + // if (swiftApi().getUserNonTelco() == true) {
54 - nonTelcoDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές."); 57 + // nonTelcoDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές.");
55 - } 58 + // } else {
59 + // UIAccessibility.post(notification: .screenChanged, argument: self.navigationItem.titleView)
60 + // }
56 61
57 backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 62 backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
58 63
...@@ -138,6 +143,7 @@ import SwiftEventBus ...@@ -138,6 +143,7 @@ import SwiftEventBus
138 143
139 toggleTerms() 144 toggleTerms()
140 145
146 + setupAccessibilty()
141 } 147 }
142 148
143 public override func viewWillAppear(_ animated: Bool) { 149 public override func viewWillAppear(_ animated: Bool) {
...@@ -147,6 +153,22 @@ import SwiftEventBus ...@@ -147,6 +153,22 @@ import SwiftEventBus
147 153
148 self.navigationController?.hideHairline() 154 self.navigationController?.hideHairline()
149 } 155 }
156 +
157 + public override func viewDidAppear(_ animated: Bool) {
158 + super.viewDidAppear(animated)
159 +
160 + // if ((profile != nil) && (profile?._nonTelco == true)) {
161 + if (swiftApi().getUserNonTelco() == true) {
162 + nonTelcoDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές.");
163 + } else {
164 + UIAccessibility.post(notification: .screenChanged, argument: self.navigationItem.titleView)
165 + }
166 +
167 + // Re-enable table view accessibility after the announcement
168 + // DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
169 + // self.mainView.accessibilityElementsHidden = false
170 + // }
171 + }
150 172
151 public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool { 173 public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
152 UIApplication.shared.open(URL) 174 UIApplication.shared.open(URL)
...@@ -156,6 +178,23 @@ import SwiftEventBus ...@@ -156,6 +178,23 @@ import SwiftEventBus
156 } 178 }
157 179
158 // MARK: - Functions 180 // MARK: - Functions
181 + func setupAccessibilty() {
182 + couponImage.isAccessibilityElement = true
183 + couponImage.accessibilityLabel = "Φωτογραφία εκπτωτικού κουπονιού"
184 + couponImage.accessibilityTraits = .image
185 +
186 + redeemButton.isAccessibilityElement = true
187 + redeemButton.accessibilityLabel = redeemButton.title(for: .normal)
188 + redeemButton.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
189 + redeemButton.accessibilityTraits = .button
190 +
191 + termsButton.isAccessibilityElement = true
192 + termsButton.accessibilityLabel = termsButton.title(for: .normal)
193 + termsButton.accessibilityHint = "Διπλό πάτημα για εμφάνιση"
194 + termsButton.accessibilityTraits = .button
195 + termsButton.accessibilityValue = "Συμπτυγμένο"
196 + }
197 +
159 func nonTelcoDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { 198 func nonTelcoDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
160 199
161 let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) 200 let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
...@@ -183,11 +222,17 @@ import SwiftEventBus ...@@ -183,11 +222,17 @@ import SwiftEventBus
183 termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height 222 termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
184 223
185 termsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal) 224 termsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
225 +
226 + termsButton.accessibilityValue = "Ανεπτυγμένο"
227 + termsButton.accessibilityHint = "Διπλό πάτημα για απόκρυψη"
186 } else { 228 } else {
187 termsTextView.isHidden = true 229 termsTextView.isHidden = true
188 termsTextViewHeight.constant = CGFloat(0) 230 termsTextViewHeight.constant = CGFloat(0)
189 231
190 termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal) 232 termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
233 +
234 + termsButton.accessibilityValue = "Συμπτυγμένο"
235 + termsButton.accessibilityHint = "Διπλό πάτημα για εμφάνιση"
191 } 236 }
192 } 237 }
193 238
......