//
//  LoginPresenter.swift
//  Auth
//
//  Created by Adam Cseke on 2022. 02. 23..
//  Copyright (c) 2022. levivig. All rights reserved.
//
//  This file was generated by the 🐍 VIPER generator
//

import Foundation
import UIKit

final class LoginPresenter {

    // MARK: - Private properties -

    private unowned let view: LoginViewInterface
    private let interactor: LoginInteractorInterface
    private let wireframe: LoginWireframeInterface
    
    private var phoneNumber: String = ""
    private var currentInput: String = ""

    // MARK: - Lifecycle -

    init(
        view: LoginViewInterface,
        interactor: LoginInteractorInterface,
        wireframe: LoginWireframeInterface,
        phoneNumber: String
    ) {
        self.view = view
        self.interactor = interactor
        self.wireframe = wireframe
        self.phoneNumber = phoneNumber
    }
    
    func viewDidLoad() {
        view.pushPhoneNumber(phoneNumber: phoneNumber)
    }
}

// MARK: - Extensions -

extension LoginPresenter: LoginPresenterInterface {
    func presentAlert(title: String, description: String, buttonText: String, alertImage: UIImage) {
        wireframe.presentAlert(title: title, description: description, buttonText: buttonText, alertImage: alertImage)
    }
    
    func inputChanged(text: String) {
        self.currentInput = text
        
        view.setButton(enable: text.count >= 1)
        
    }
    
    func signOutButtonTapped() {
        wireframe.backToHome()
    }
}
