Manos Chorianopoulos

MapsViewController accessibilities

...@@ -56,6 +56,7 @@ import MapKit ...@@ -56,6 +56,7 @@ import MapKit
56 56
57 mapView.delegate = self 57 mapView.delegate = self
58 mapView.centerToLocation(initialLocation, regionRadius: 1000000) 58 mapView.centerToLocation(initialLocation, regionRadius: 1000000)
59 +// mapView.isAccessibilityElement = false
59 60
60 // mapView.clipsToBounds = true 61 // mapView.clipsToBounds = true
61 // mapView.layer.cornerRadius = 30 62 // mapView.layer.cornerRadius = 30
...@@ -178,6 +179,8 @@ import MapKit ...@@ -178,6 +179,8 @@ import MapKit
178 // let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) }) 179 // let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
179 if (filteredMerchants.count == 0) { 180 if (filteredMerchants.count == 0) {
180 self.showDialog("Καταστήματα συνεργάτη", "Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.") 181 self.showDialog("Καταστήματα συνεργάτη", "Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.")
182 + } else {
183 + UIAccessibility.post(notification: .screenChanged, argument: self.navigationItem.titleView)
181 } 184 }
182 } 185 }
183 186
...@@ -374,6 +377,23 @@ import MapKit ...@@ -374,6 +377,23 @@ import MapKit
374 // mapView.showAnnotations(mapView.annotations, animated: true) 377 // mapView.showAnnotations(mapView.annotations, animated: true)
375 } 378 }
376 379
380 + private func getMerchantName(_ merchant: swiftApi.MerchantModel) -> String {
381 + if let parent = self.parentMerchantsArray.first(where: {($0._uuid == merchant._parent)}) {
382 + return parent._admin_name
383 + } else {
384 + return merchant._name
385 + }
386 + }
387 +
388 + private func addPinAccessibility (annotationView: MKAnnotationView? , merchantModel: swiftApi.MerchantModel, parentName: String?) {
389 + annotationView?.isAccessibilityElement = true
390 +// annotationView?.accessibilityLabel = "Πινέζα, κατάστημα: " + (parent._admin_name)
391 +// annotationView?.accessibilityLabel = "Πινέζα, κατάστημα: " + getMerchantName(merchantModel)
392 + annotationView?.accessibilityLabel = "Πινέζα, κατάστημα: " + (((parentName ?? "").isEmpty ? getMerchantName(merchantModel) : parentName) ?? "")
393 + annotationView?.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
394 + annotationView?.accessibilityTraits = .button
395 + }
396 +
377 private func loadPinDetailsView(_ annotation: MerchantAnnotation) { 397 private func loadPinDetailsView(_ annotation: MerchantAnnotation) {
378 self.selectedMerchant = annotation.model 398 self.selectedMerchant = annotation.model
379 399
...@@ -395,12 +415,55 @@ import MapKit ...@@ -395,12 +415,55 @@ import MapKit
395 self.hoursView.text = "" 415 self.hoursView.text = ""
396 self.phoneView.text = self.selectedMerchant?._telephone 416 self.phoneView.text = self.selectedMerchant?._telephone
397 self.addressView.text = self.selectedMerchant?._address 417 self.addressView.text = self.selectedMerchant?._address
418 +
419 + setupAccessibilty()
420 + }
421 +
422 + func setupAccessibilty () {
423 + self.titleView.isAccessibilityElement = true
424 + self.titleView.accessibilityTraits = .header
425 +
426 + self.closeButton.isAccessibilityElement = true
427 + self.closeButton.accessibilityLabel = "Κλείσιμο"
428 + self.closeButton.accessibilityHint = "Διπλό πάτημα για κλείσιμο"
429 + self.closeButton.accessibilityTraits = .button
430 +
431 + self.nameImageView.isAccessibilityElement = true
432 + self.nameImageView.accessibilityLabel = "Λογότυπο καταστήματος"
433 + self.nameImageView.accessibilityTraits = .image
434 +
435 + self.nameView.isAccessibilityElement = true
436 +// self.nameView.accessibilityLabel = self.nameView.text
437 +
438 + self.phoneImageView.isAccessibilityElement = true
439 + self.phoneImageView.accessibilityLabel = "Τηλέφωνο"
440 + self.phoneImageView.accessibilityTraits = .image
441 +
442 + self.phoneView.isAccessibilityElement = true
443 + self.phoneView.accessibilityLabel = "Τηλέφωνο: " + formatPhoneNumber(self.phoneView.text ?? "")
444 +
445 + self.addressImageView.isAccessibilityElement = true
446 + self.addressImageView.accessibilityLabel = "Διεύθυνση"
447 + self.addressImageView.accessibilityTraits = .image
448 +
449 + self.addressView.isAccessibilityElement = true
450 +// self.addressView.accessibilityLabel = self.addressView.text ?? ""
451 +
452 + self.directionsButton.isAccessibilityElement = true
453 + self.directionsButton.accessibilityLabel = self.directionsButton.title(for: .normal)
454 + self.directionsButton.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
455 + self.directionsButton.accessibilityTraits = .button
456 +
457 + self.hoursView.isAccessibilityElement = true
458 +// self.hoursView.accessibilityLabel = self.hoursView.text ?? ""
398 } 459 }
399 460
400 private func showPinDetailsView() { 461 private func showPinDetailsView() {
401 self.infoTopConstraint.constant = -320 462 self.infoTopConstraint.constant = -320
402 UIView.animate(withDuration: 1.0) { 463 UIView.animate(withDuration: 1.0) {
403 self.view.layoutIfNeeded() 464 self.view.layoutIfNeeded()
465 +
466 + UIAccessibility.post(notification: .layoutChanged, argument: self.titleView)
404 } 467 }
405 } 468 }
406 469
...@@ -413,6 +476,12 @@ import MapKit ...@@ -413,6 +476,12 @@ import MapKit
413 } 476 }
414 } 477 }
415 478
479 + func formatPhoneNumber(_ phoneNumber: String) -> String {
480 + let cleanedPhoneNumber = phoneNumber.replacingOccurrences(of: "-", with: "")
481 + .replacingOccurrences(of: ".", with: "")
482 + return cleanedPhoneNumber
483 + }
484 +
416 // map view delegate 485 // map view delegate
417 // public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { 486 // public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
418 // 487 //
...@@ -447,7 +516,7 @@ import MapKit ...@@ -447,7 +516,7 @@ import MapKit
447 // guard !(annotation is MKUserLocation) else { 516 // guard !(annotation is MKUserLocation) else {
448 // return nil 517 // return nil
449 // } 518 // }
450 - 519 +
451 var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom") 520 var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom")
452 if (annotationView == nil) { 521 if (annotationView == nil) {
453 annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom") 522 annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom")
...@@ -484,6 +553,8 @@ import MapKit ...@@ -484,6 +553,8 @@ import MapKit
484 pinImageView.addSubview(logoImageView) 553 pinImageView.addSubview(logoImageView)
485 annotationView?.addSubview(pinImageView) 554 annotationView?.addSubview(pinImageView)
486 555
556 + addPinAccessibility(annotationView: annotationView, merchantModel: merchantModel, parentName: parent._admin_name)
557 +
487 return annotationView 558 return annotationView
488 } else { 559 } else {
489 return nil 560 return nil
...@@ -495,6 +566,8 @@ import MapKit ...@@ -495,6 +566,8 @@ import MapKit
495 pinImageView.addSubview(logoImageView) 566 pinImageView.addSubview(logoImageView)
496 annotationView?.addSubview(pinImageView) 567 annotationView?.addSubview(pinImageView)
497 568
569 + addPinAccessibility(annotationView: annotationView, merchantModel: merchantModel, parentName: "")
570 +
498 return annotationView 571 return annotationView
499 } 572 }
500 573
......