Manos Chorianopoulos

MapsViewController accessibilities

......@@ -56,6 +56,7 @@ import MapKit
mapView.delegate = self
mapView.centerToLocation(initialLocation, regionRadius: 1000000)
// mapView.isAccessibilityElement = false
// mapView.clipsToBounds = true
// mapView.layer.cornerRadius = 30
......@@ -178,6 +179,8 @@ import MapKit
// let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
if (filteredMerchants.count == 0) {
self.showDialog("Καταστήματα συνεργάτη", "Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.")
} else {
UIAccessibility.post(notification: .screenChanged, argument: self.navigationItem.titleView)
}
}
......@@ -374,6 +377,23 @@ import MapKit
// mapView.showAnnotations(mapView.annotations, animated: true)
}
private func getMerchantName(_ merchant: swiftApi.MerchantModel) -> String {
if let parent = self.parentMerchantsArray.first(where: {($0._uuid == merchant._parent)}) {
return parent._admin_name
} else {
return merchant._name
}
}
private func addPinAccessibility (annotationView: MKAnnotationView? , merchantModel: swiftApi.MerchantModel, parentName: String?) {
annotationView?.isAccessibilityElement = true
// annotationView?.accessibilityLabel = "Πινέζα, κατάστημα: " + (parent._admin_name)
// annotationView?.accessibilityLabel = "Πινέζα, κατάστημα: " + getMerchantName(merchantModel)
annotationView?.accessibilityLabel = "Πινέζα, κατάστημα: " + (((parentName ?? "").isEmpty ? getMerchantName(merchantModel) : parentName) ?? "")
annotationView?.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
annotationView?.accessibilityTraits = .button
}
private func loadPinDetailsView(_ annotation: MerchantAnnotation) {
self.selectedMerchant = annotation.model
......@@ -395,12 +415,55 @@ import MapKit
self.hoursView.text = ""
self.phoneView.text = self.selectedMerchant?._telephone
self.addressView.text = self.selectedMerchant?._address
setupAccessibilty()
}
func setupAccessibilty () {
self.titleView.isAccessibilityElement = true
self.titleView.accessibilityTraits = .header
self.closeButton.isAccessibilityElement = true
self.closeButton.accessibilityLabel = "Κλείσιμο"
self.closeButton.accessibilityHint = "Διπλό πάτημα για κλείσιμο"
self.closeButton.accessibilityTraits = .button
self.nameImageView.isAccessibilityElement = true
self.nameImageView.accessibilityLabel = "Λογότυπο καταστήματος"
self.nameImageView.accessibilityTraits = .image
self.nameView.isAccessibilityElement = true
// self.nameView.accessibilityLabel = self.nameView.text
self.phoneImageView.isAccessibilityElement = true
self.phoneImageView.accessibilityLabel = "Τηλέφωνο"
self.phoneImageView.accessibilityTraits = .image
self.phoneView.isAccessibilityElement = true
self.phoneView.accessibilityLabel = "Τηλέφωνο: " + formatPhoneNumber(self.phoneView.text ?? "")
self.addressImageView.isAccessibilityElement = true
self.addressImageView.accessibilityLabel = "Διεύθυνση"
self.addressImageView.accessibilityTraits = .image
self.addressView.isAccessibilityElement = true
// self.addressView.accessibilityLabel = self.addressView.text ?? ""
self.directionsButton.isAccessibilityElement = true
self.directionsButton.accessibilityLabel = self.directionsButton.title(for: .normal)
self.directionsButton.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
self.directionsButton.accessibilityTraits = .button
self.hoursView.isAccessibilityElement = true
// self.hoursView.accessibilityLabel = self.hoursView.text ?? ""
}
private func showPinDetailsView() {
self.infoTopConstraint.constant = -320
UIView.animate(withDuration: 1.0) {
self.view.layoutIfNeeded()
UIAccessibility.post(notification: .layoutChanged, argument: self.titleView)
}
}
......@@ -413,6 +476,12 @@ import MapKit
}
}
func formatPhoneNumber(_ phoneNumber: String) -> String {
let cleanedPhoneNumber = phoneNumber.replacingOccurrences(of: "-", with: "")
.replacingOccurrences(of: ".", with: "")
return cleanedPhoneNumber
}
// map view delegate
// public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
//
......@@ -447,7 +516,7 @@ import MapKit
// guard !(annotation is MKUserLocation) else {
// return nil
// }
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom")
if (annotationView == nil) {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom")
......@@ -484,6 +553,8 @@ import MapKit
pinImageView.addSubview(logoImageView)
annotationView?.addSubview(pinImageView)
addPinAccessibility(annotationView: annotationView, merchantModel: merchantModel, parentName: parent._admin_name)
return annotationView
} else {
return nil
......@@ -495,6 +566,8 @@ import MapKit
pinImageView.addSubview(logoImageView)
annotationView?.addSubview(pinImageView)
addPinAccessibility(annotationView: annotationView, merchantModel: merchantModel, parentName: "")
return annotationView
}
......