//
//  CallMessageAlertVC.swift
//  WoWonder
//
//  Created by iMac on 30/09/23.
//  Copyright © 2023 ScriptSun. All rights reserved.
//

import UIKit

protocol CallMessageAlertVCDelegate {
    func handleCallMessageTap(message: String)
    func handleCustomMessageButtonTap(sender: UIButton)
}

class CallMessageAlertVC: UIViewController {
    
    // MARK: - Properties
    
    var delegate: CallMessageAlertVCDelegate?
    
    // MARK: - View Life Cycles

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        self.initialConfig()
    }
    
    //MARK: - Selectors
    
    // Message Button Action
    @IBAction func messageButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            if sender.tag == 1001 {
                self.delegate?.handleCallMessageTap(message: "Can't Talk Now, What's Up?")
            }
            if sender.tag == 1002 {
                self.delegate?.handleCallMessageTap(message: "I'll Call You Right Back")
            }
            if sender.tag == 1003 {
                self.delegate?.handleCallMessageTap(message: "I'll Call You Later")
            }
            if sender.tag == 1004 {
                self.delegate?.handleCallMessageTap(message: "Can't talk now. call me later")
            }
        }
    }
    
    // Custom Message Button Action
    @IBAction func customMessageButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleCustomMessageButtonTap(sender: sender)
        }
    }
    
    // Close Button Action
    @IBAction func closeButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true)
    }
    
    // MARK: - Helper Functions
    
    // Initial Config
    func initialConfig() {
        self.view.backgroundColor = .black.withAlphaComponent(0.4)
    }
    
}
