//
//  ExitJourneyViewController.swift
//  MyTatvaCare
//
//  Created by Nirav Ramani on 03/06/25.
//

import UIKit

class ExitJourneyViewController: UIViewController {
    
    //MARK: - Variables
    @IBOutlet weak var labelTitle: UILabel!
    @IBOutlet weak var labelDesc: UILabel!
    
    @IBOutlet weak var labelImportantNote: UILabel!
    @IBOutlet weak var labelImportantNoteDesc: UILabel!
    
    @IBOutlet var closeButton: UIButton!
    @IBOutlet weak var buttonExit: CustomOverlayButton!
    @IBOutlet weak var buttonCancel: CustomOverlayButton!
    
    //MARK: - Class Methods
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
        setupLayout()
    }
    
    func setupLayout() {
        
        closeButton.setImage(loadImage(named: "ic_close_popup"), for: .normal)
        
        labelTitle.font = FontManager.font(ofSize: 18, weight: .medium)
        labelTitle.textColor = CustomColor.shared.primaryBlack
        
        labelDesc.font = FontManager.font(ofSize: 16, weight: .regular)
        labelDesc.textColor = CustomColor.shared.primaryBlack
        
        labelImportantNote.font = FontManager.font(ofSize: 20, weight: .medium)
        labelImportantNote.textColor = CustomColor.shared.primaryBlack
        
        labelImportantNoteDesc.font = FontManager.font(ofSize: 14, weight: .regular)
        labelImportantNoteDesc.textColor = CustomColor.shared.primaryBlack
        
        buttonCancel.labelText = "Cancel"
        buttonCancel.setBorderOnly()
        buttonCancel.buttonTapCallback = {
            self.dismiss(animated: true)
        }
        
        buttonExit.labelText = "Exit"
        buttonExit.setRedButton()
        buttonExit.buttonTapCallback = {
            if let rootVC = UIApplication.shared.connectedScenes
                .compactMap({ ($0 as? UIWindowScene)?.windows.first?.rootViewController })
                .first {
                rootVC.dismiss(animated: true, completion: nil)
            } else if let rootViewController = UIApplication.shared.keyWindow?.rootViewController {
                rootViewController.dismiss(animated: true, completion: nil)
            }
        }
    }
    

    //MARK: - Action Methods
    @IBAction func buttonCloseTouchUpInside(_ sender: UIButton) {
        dismiss(animated: true)
    }
   
}
