Manos Chorianopoulos

CouponsVC accessibilitues

......@@ -193,6 +193,8 @@ import UIKit
// discriptionLabel.text = htmlText.htmlToString
discriptionLabel.text = couponSetData?.inner_text ?? ""
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
setupAccessibilty(name: nameLabel.text ?? "", discount: dicountLabel.text ?? "", description: discriptionLabel.text ?? "", expirationString: "", expirationDate: (coupon.expirationDate))
}
func configureCell(coupon: swiftApi.CouponItemModel, isMarket: Bool) {
......@@ -334,6 +336,8 @@ import UIKit
discriptionLabel.text = htmlText.htmlToString
// discriptionLabel.text = coupon.inner_text ?? ""
let expirationString = expirationLabel.text == "Το κουπόνι έληξε" ? "Το κουπόνι έληξε" : ""
setupAccessibilty(name: nameLabel.text ?? "", discount: dicountLabel.text ?? "", description: discriptionLabel.text ?? "", expirationString: expirationString, expirationDate: (coupon.expirationDate))
}
func configureCell(coupon: swiftApi.CouponItemModel, isSMCoupon: Bool) {
......@@ -378,6 +382,34 @@ import UIKit
// discriptionLabel.text = htmlText.htmlToString
discriptionLabel.text = couponSetData?.inner_text ?? ""
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
setupAccessibilty(name: nameLabel.text ?? "", discount: dicountLabel.text ?? "", description: discriptionLabel.text ?? "", expirationString: "", expirationDate: (coupon.expirationDate))
}
func setupAccessibilty (name: String, discount: String, description: String, expirationString: String, expirationDate: Date?) {
var formatedExpiration = ""
if (expirationString.isEmpty) {
let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
if let date = 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 = expirationString
}
} else {
formatedExpiration = expirationString
}
self.isAccessibilityElement = true
self.accessibilityLabel = name + ", " + discount + ", " + description + ", " + formatedExpiration
self.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
self.accessibilityTraits = .button
}
// Configure the cell with visibility of the selectView, a selected state, and select Button Action
......
......@@ -44,6 +44,9 @@ import SwiftEventBus
tableView.delegate = self
tableView.dataSource = self
// Temporarily disable the table view's accessibility to prevent immediate focus shift
self.tableView.accessibilityElementsHidden = true
// tableView.clipsToBounds = true
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
......@@ -65,6 +68,19 @@ import SwiftEventBus
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.tableView.accessibilityElementsHidden = false
}
}
// MARK: - Functions
func handleEmptyView() {
if (self.coupons.count == 0) {
......@@ -75,7 +91,7 @@ import SwiftEventBus
self.emptyViewHeight.constant = 0
}
}
// MARK: - API Functions
func getCouponsRequest() {
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in
......
......@@ -53,6 +53,10 @@ extension UIViewController {
if let imgBackArrow = UIImage(named: icon, in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
imageView.image = imgBackArrow
}
view.isAccessibilityElement = true
view.accessibilityLabel = "Πίσω"
view.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
view.accessibilityTraits = .button
view.addSubview(imageView)
let backTap = UITapGestureRecognizer(target: self, action: #selector(moveToBack(_:)))
......
......@@ -841,6 +841,7 @@ public class swiftApi {
public let name: String?
public let image: String?
public let expiration: String?
public let expirationDate: Date?
public let created: String?
public let description: String?
public let discount: String?
......@@ -944,8 +945,10 @@ public class swiftApi {
dateFormatter.dateFormat = "dd/MM/yyyy"
let resultString = dateFormatter.string(from: date)
self.expiration = resultString
self.expirationDate = date
} else {
self.expiration = ""
self.expirationDate = Date()
}
let createdString = dictionary["created"] as? String? ?? ""
......