//
//  AlertController.swift
//  MVMCore
//
//  Created by Scott Pfeil on 3/24/23.
//  Copyright © 2023 myverizon. All rights reserved.
//

import Foundation
import MVMCore

public class AlertController: UIAlertController {
    @objc dynamic public var visible = false
    private let visibleKey = "isVisible"
    
    public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return MVMCoreGetterUtility.isOnIPad() ? .all : .portrait
    }
    
    public override var description: String {
        return "\(super.description)|title=\(title ?? "")|message=\(message ?? "")"
    }
    
    public override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        willChangeValue(forKey: visibleKey)
        visible = true
        didChangeValue(forKey: visibleKey)
    }
    
    public override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        willChangeValue(forKey: visibleKey)
        visible = false
        didChangeValue(forKey: visibleKey)
    }
}

