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

import UIKit

protocol AttachmentAlertVCDelegate {
    func handleImageGalleryTap(_ sender: UIButton)
    func handleTakePictureFromCameraTap(_ sender: UIButton)
    func handleVideoGalleryTap(_ sender: UIButton)
    func handleRecordVideoFromCameraTap(_ sender: UIButton)
    func handleDocumentButtonTap()
    func handleMusicButtonTap()
    func handleGifButtonTap()
    func handleContactButtonTap()
    func handleLocationButtonTap()
}

class AttachmentAlertVC: UIViewController {
    
    // MARK: - Properties
    
    var delegate: AttachmentAlertVCDelegate?
    
    // MARK: - View Life Cycles

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        self.initialConfig()
    }
    
    //MARK: - Selectors
    
    // Image Gallery Button Action
    @IBAction func imageGalleryButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleImageGalleryTap(sender)
        }
    }
    
    // Take Picture Button Action
    @IBAction func takePictureButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleTakePictureFromCameraTap(sender)
        }
    }
    
    // Video Gallery Button Action
    @IBAction func videoGalleryButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleVideoGalleryTap(sender)
        }
    }
    
    // Record Video Button Action
    @IBAction func recordVideoButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleRecordVideoFromCameraTap(sender)
        }
    }
    
    // File Button Action
    @IBAction func fileButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleDocumentButtonTap()
        }
    }
    
    // Music Button Action
    @IBAction func musicButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleMusicButtonTap()
        }
    }
    
    // Gif Button Action
    @IBAction func gifButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleGifButtonTap()
        }
    }
    
    // Contact Button Action
    @IBAction func contactButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleContactButtonTap()
        }
    }
    
    // Location Button Action
    @IBAction func locationButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleLocationButtonTap()
        }
    }
    
    // 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)
    }

}
