//
//  RoleCreateBaseController.swift

//
//  Created by Leon on 2025/8/9.
//

import UIKit

class RoleCreateBaseController<Container: UIView>: CLViewController <Container>{

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        baseSetupViews()
        baseSetupDats()
        baseSetupEvents()
    }
    
    private func baseSetupViews() {
        navigationView.setupBackButtonCloseIcon()
        navigationView.tapBackButtonAction = {[weak self] in
            self?.alertToClose()
        }
    }
    
    private func baseSetupDats(){
        
    }
    
    private func baseSetupEvents(){
        
    }
    
    private func alertToClose(){
        view.endEditing(true)
        
        let alert = Alert(title: "内容未保存", text: "内容未保存，是否继续退出？")
        let action1 = AlertAction(title: "退出", actionStyle: .destructive) {[weak self] in
            self?.close(dismissFirst: true)
        }
        let action2 = AlertAction(title: "Cancel", actionStyle: .cancel)
        alert.addAction(action1)
        alert.addAction(action2)
        alert.show()
        
        
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
