//
//  ChildPresenter.swift
//  DataPassing
//
//  Created by Raymond Law on 3/22/18.
//  Copyright (c) 2018 Clean Swift LLC. 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 ChildPresentationLogic
{
  func presentGreeting(response: Child.ShowGreeting.Response)
  func presentTellParent(response: Child.TellParent.Response)
}

class ChildPresenter: ChildPresentationLogic
{
  weak var viewController: ChildDisplayLogic?
  
  // MARK: Show greeting
  
  func presentGreeting(response: Child.ShowGreeting.Response)
  {
    let greeting = response.name.isEmpty ? "Hello" : "\(response.name), do you want to go to Toys R Us before they bankrupt?"
    let viewModel = Child.ShowGreeting.ViewModel(greeting: greeting)
    viewController?.displayGreeting(viewModel: viewModel)
  }
  
  // MARK: Tell child
  
  func presentTellParent(response: Child.TellParent.Response)
  {
    let viewModel = Child.TellParent.ViewModel()
    viewController?.displayTellParent(viewModel: viewModel)
  }
}
