//
//  MyTunesListRouter.swift
//  myTunes
//
//  Created by MacOS on 23.03.2022.
//  Copyright (c) 2022 ___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

protocol MyTunesListRoutingLogic: AnyObject {
    func routeToDetails(index: Int)
    func routeToFavorites()
}

protocol MyTunesListDataPassing: AnyObject {
    var dataStore: MyTunesListDataStore? { get }
}

final class MyTunesListRouter:  MyTunesListRoutingLogic, MyTunesListDataPassing {
    weak var viewController: MyTunesListViewController?
    var dataStore: MyTunesListDataStore?
    
    func routeToDetails(index: Int) {
        let storyBoard = UIStoryboard(name: "MyTunesDetails", bundle: nil)
        let destVC: MyTunesDetailsViewController = storyBoard.instantiateViewController(identifier: "MyTunesDetails")
        let myTune = dataStore?.myTunesList?[index]
        destVC.router?.dataStore?.myTune = myTune
        destVC.modalPresentationStyle = .fullScreen
        viewController?.navigationController?.pushViewController(destVC, animated: true)
    }
    
    func routeToFavorites() {
        let storyBoard = UIStoryboard(name: "FavoriteList", bundle: nil)
        let destVC: FavoriteListViewController = storyBoard.instantiateViewController(identifier: "FavoriteList")
        destVC.modalPresentationStyle = .fullScreen
        viewController?.navigationController?.pushViewController(destVC, animated: true)
    }
}
