 import CoreLocation
 import MapKit
 
+// enum to hold possible navigation apps on user's device
 public enum PazNavigationApp {
     case AppleMaps
     case GoogleMaps

        }
    }
    
    public var urlString: String {
        switch self {
        case .AppleMaps:
            return "maps.apple.com://"
        case .GoogleMaps:
            return "comgooglemaps://"
        case .Navigon:

        }
    }
    
    /* func to create an Alert where the options
     are the available navigation apps on the user's device.
     The callback informs if the operation was successful */
    public static func directionsAlertController(coordinate: CLLocationCoordinate2D,
                                                 name: String = "Destination",
                                                 title: String = "Directions Using",
                                                 message: String? = nil,
                                                 completion: ((Bool) -> ())? = nil)
        -> UIAlertController {
            
            let directionsAlertView = UIAlertController(title: title,
                                                        message: nil,
                                                        preferredStyle: .actionSheet)
            
            for navigationApp in PazNavigationApp.AvailableServices {
                
                let action = UIAlertAction(title: navigationApp.name,
                                           style: UIAlertActionStyle.default,
                                           handler: { action in
                                            navigationApp.openWithDirections(coordinate: coordinate,
                                                                             name: name,
                                                                             completion: completion)
                })
                
                directionsAlertView.addAction(action)
            }
            
            let cancelAction = UIAlertAction(title: "Dismiss",
                                             style: UIAlertActionStyle.cancel,
                                             handler: { action in completion?(false) })
            
            directionsAlertView.addAction(cancelAction)
            
            return directionsAlertView
    }
}
