//
//  ThemeAlertVC.swift
//  WoWonder
//
//  Created by UnikApp on 17/12/22.
//  Copyright © 2022 ScriptSun. All rights reserved.
//

import UIKit

protocol ThemeAlertVCDelegate {
    func handleThemeTap(themeType: String)
}

class ThemeAlertVC: UIViewController {
    
    // MARK: - Properties
    
    var delegate: ThemeAlertVCDelegate?
    
    // MARK: - View Life Cycles
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.initialConfig()
    }
    
    // MARK: - Selectors
    
    // Light Button Action
    @IBAction func lightButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleThemeTap(themeType: "Light")
        }
    }
    
    // Dark Button Action
    @IBAction func darkButtonClick(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleThemeTap(themeType: "Dark")
        }
    }
    
    // Battery Saver Button Action
    @IBAction func batterySaverButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true) {
            self.delegate?.handleThemeTap(themeType: "Set by Battery saver (Auto)")
        }
    }
    
    // Close Button Action
    @IBAction func closeButtonAction(_ sender: UIButton) {
        self.view.endEditing(true)
        self.dismiss(animated: true, completion: nil)
    }
    
    // MARK: - Helper Functions
    
    // Initial Config
    func initialConfig() {
        self.view.backgroundColor = .black.withAlphaComponent(0.4)
    }
    
}
