Manos Chorianopoulos

CouponsVC accessibilitues

...@@ -193,6 +193,8 @@ import UIKit ...@@ -193,6 +193,8 @@ import UIKit
193 // discriptionLabel.text = htmlText.htmlToString 193 // discriptionLabel.text = htmlText.htmlToString
194 discriptionLabel.text = couponSetData?.inner_text ?? "" 194 discriptionLabel.text = couponSetData?.inner_text ?? ""
195 expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "") 195 expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
196 +
197 + setupAccessibilty(name: nameLabel.text ?? "", discount: dicountLabel.text ?? "", description: discriptionLabel.text ?? "", expirationString: "", expirationDate: (coupon.expirationDate))
196 } 198 }
197 199
198 func configureCell(coupon: swiftApi.CouponItemModel, isMarket: Bool) { 200 func configureCell(coupon: swiftApi.CouponItemModel, isMarket: Bool) {
...@@ -334,6 +336,8 @@ import UIKit ...@@ -334,6 +336,8 @@ import UIKit
334 discriptionLabel.text = htmlText.htmlToString 336 discriptionLabel.text = htmlText.htmlToString
335 // discriptionLabel.text = coupon.inner_text ?? "" 337 // discriptionLabel.text = coupon.inner_text ?? ""
336 338
339 + let expirationString = expirationLabel.text == "Το κουπόνι έληξε" ? "Το κουπόνι έληξε" : ""
340 + setupAccessibilty(name: nameLabel.text ?? "", discount: dicountLabel.text ?? "", description: discriptionLabel.text ?? "", expirationString: expirationString, expirationDate: (coupon.expirationDate))
337 } 341 }
338 342
339 func configureCell(coupon: swiftApi.CouponItemModel, isSMCoupon: Bool) { 343 func configureCell(coupon: swiftApi.CouponItemModel, isSMCoupon: Bool) {
...@@ -378,6 +382,34 @@ import UIKit ...@@ -378,6 +382,34 @@ import UIKit
378 // discriptionLabel.text = htmlText.htmlToString 382 // discriptionLabel.text = htmlText.htmlToString
379 discriptionLabel.text = couponSetData?.inner_text ?? "" 383 discriptionLabel.text = couponSetData?.inner_text ?? ""
380 expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "") 384 expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
385 +
386 + setupAccessibilty(name: nameLabel.text ?? "", discount: dicountLabel.text ?? "", description: discriptionLabel.text ?? "", expirationString: "", expirationDate: (coupon.expirationDate))
387 + }
388 +
389 + func setupAccessibilty (name: String, discount: String, description: String, expirationString: String, expirationDate: Date?) {
390 + var formatedExpiration = ""
391 + if (expirationString.isEmpty) {
392 + let dateFormatter = DateFormatter()
393 + // dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
394 + dateFormatter.locale = Locale(identifier: "en_US_POSIX")
395 + if let date = expirationDate {
396 + // Set output format in Greek
397 + dateFormatter.locale = Locale(identifier: "el_GR") // Greek locale
398 + dateFormatter.dateFormat = "d MMMM yyyy"
399 + let resultString = dateFormatter.string(from: date)
400 + formatedExpiration = "Ισχύει έως " + resultString
401 + } else {
402 + formatedExpiration = expirationString
403 + }
404 +
405 + } else {
406 + formatedExpiration = expirationString
407 + }
408 +
409 + self.isAccessibilityElement = true
410 + self.accessibilityLabel = name + ", " + discount + ", " + description + ", " + formatedExpiration
411 + self.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
412 + self.accessibilityTraits = .button
381 } 413 }
382 414
383 // Configure the cell with visibility of the selectView, a selected state, and select Button Action 415 // Configure the cell with visibility of the selectView, a selected state, and select Button Action
......
...@@ -44,6 +44,9 @@ import SwiftEventBus ...@@ -44,6 +44,9 @@ import SwiftEventBus
44 tableView.delegate = self 44 tableView.delegate = self
45 tableView.dataSource = self 45 tableView.dataSource = self
46 46
47 + // Temporarily disable the table view's accessibility to prevent immediate focus shift
48 + self.tableView.accessibilityElementsHidden = true
49 +
47 // tableView.clipsToBounds = true 50 // tableView.clipsToBounds = true
48 // tableView.layer.cornerRadius = 30 51 // tableView.layer.cornerRadius = 30
49 // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius 52 // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
...@@ -65,6 +68,19 @@ import SwiftEventBus ...@@ -65,6 +68,19 @@ import SwiftEventBus
65 self.navigationController?.hideHairline() 68 self.navigationController?.hideHairline()
66 } 69 }
67 70
71 + public override func viewDidAppear(_ animated: Bool) {
72 + super.viewDidAppear(animated)
73 +
74 +// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
75 + UIAccessibility.post(notification: .screenChanged, argument: self.navigationItem.titleView)
76 +// }
77 +
78 + // Re-enable table view accessibility after the announcement
79 + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
80 + self.tableView.accessibilityElementsHidden = false
81 + }
82 + }
83 +
68 // MARK: - Functions 84 // MARK: - Functions
69 func handleEmptyView() { 85 func handleEmptyView() {
70 if (self.coupons.count == 0) { 86 if (self.coupons.count == 0) {
...@@ -75,7 +91,7 @@ import SwiftEventBus ...@@ -75,7 +91,7 @@ import SwiftEventBus
75 self.emptyViewHeight.constant = 0 91 self.emptyViewHeight.constant = 0
76 } 92 }
77 } 93 }
78 - 94 +
79 // MARK: - API Functions 95 // MARK: - API Functions
80 func getCouponsRequest() { 96 func getCouponsRequest() {
81 swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in 97 swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in
......
...@@ -53,6 +53,10 @@ extension UIViewController { ...@@ -53,6 +53,10 @@ extension UIViewController {
53 if let imgBackArrow = UIImage(named: icon, in: MyEmptyClass.resourceBundle(), compatibleWith: nil) { 53 if let imgBackArrow = UIImage(named: icon, in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
54 imageView.image = imgBackArrow 54 imageView.image = imgBackArrow
55 } 55 }
56 + view.isAccessibilityElement = true
57 + view.accessibilityLabel = "Πίσω"
58 + view.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
59 + view.accessibilityTraits = .button
56 view.addSubview(imageView) 60 view.addSubview(imageView)
57 61
58 let backTap = UITapGestureRecognizer(target: self, action: #selector(moveToBack(_:))) 62 let backTap = UITapGestureRecognizer(target: self, action: #selector(moveToBack(_:)))
......
...@@ -841,6 +841,7 @@ public class swiftApi { ...@@ -841,6 +841,7 @@ public class swiftApi {
841 public let name: String? 841 public let name: String?
842 public let image: String? 842 public let image: String?
843 public let expiration: String? 843 public let expiration: String?
844 + public let expirationDate: Date?
844 public let created: String? 845 public let created: String?
845 public let description: String? 846 public let description: String?
846 public let discount: String? 847 public let discount: String?
...@@ -944,8 +945,10 @@ public class swiftApi { ...@@ -944,8 +945,10 @@ public class swiftApi {
944 dateFormatter.dateFormat = "dd/MM/yyyy" 945 dateFormatter.dateFormat = "dd/MM/yyyy"
945 let resultString = dateFormatter.string(from: date) 946 let resultString = dateFormatter.string(from: date)
946 self.expiration = resultString 947 self.expiration = resultString
948 + self.expirationDate = date
947 } else { 949 } else {
948 self.expiration = "" 950 self.expiration = ""
951 + self.expirationDate = Date()
949 } 952 }
950 953
951 let createdString = dictionary["created"] as? String? ?? "" 954 let createdString = dictionary["created"] as? String? ?? ""
......