//
//  MapRouter.swift
//  CurrentAddress
//
//  Created by vitor.ferrazvarela on 02/05/20.
//  Copyright (c) 2020 ___ORGANIZATIONNAME___. All rights reserved.
//
//  This file was generated by the Clean Swift Xcode Templates so
//  you can apply clean architecture to your iOS and Mac projects,
//  see http://clean-swift.com
//

import UIKit

@objc protocol MapRoutingLogic
{
    //func routeToSomewhere(segue: UIStoryboardSegue?)
    func routeToPlacemark(segue: UIStoryboardSegue?)
}

protocol MapDataPassing
{
    var dataStore: MapDataStore? { get }
}

class MapRouter: NSObject, MapRoutingLogic, MapDataPassing
{
    weak var viewController: MapViewController?
    var dataStore: MapDataStore?
    
    // MARK: Routing
    func routeToPlacemark(segue: UIStoryboardSegue?) {
        if let segue = segue {
            let destinationVC = segue.destination as! PlacemarkViewController
            var destinationDS = destinationVC.router!.dataStore!
            passDataToSomewhere(source: dataStore!, destination: &destinationDS)
        }
    }
    //func routeToSomewhere(segue: UIStoryboardSegue?)
    //{
    //  if let segue = segue {
    //    let destinationVC = segue.destination as! SomewhereViewController
    //    var destinationDS = destinationVC.router!.dataStore!
    //    passDataToSomewhere(source: dataStore!, destination: &destinationDS)
    //  } else {
    //    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    //    let destinationVC = storyboard.instantiateViewController(withIdentifier: "SomewhereViewController") as! SomewhereViewController
    //    var destinationDS = destinationVC.router!.dataStore!
    //    passDataToSomewhere(source: dataStore!, destination: &destinationDS)
    //    navigateToSomewhere(source: viewController!, destination: destinationVC)
    //  }
    //}
    
    // MARK: Navigation
    
    //func navigateToSomewhere(source: MapViewController, destination: SomewhereViewController)
    //{
    //  source.show(destination, sender: nil)
    //}
    
    // MARK: Passing data
    
    func passDataToSomewhere(source: MapDataStore, destination: inout PlacemarkDataStore)
    {
      destination.placemark = source.placemark
    }
}
