// Copyright © 2022 Olo Inc. All rights reserved.
// This software is made available under the Olo Pay SDK License (See LICENSE.md file)
//
//  OloPayView.swift
//  OlopaysdkReactNative
//
//  Created by Justin Anderson on 8/23/23.
//  Copyright © 2023 Facebook. All rights reserved.
//

import Foundation

class OloPayView : UIView, OloPayViewProtocol {
    var viewIsDirty: Bool = false
    weak var viewController: UIViewController? = nil
    
    func updateAllProperties() {
        fatalError("This method must be implemented in a subclass")
    }
    
    func createViewController() -> UIViewController {
        fatalError("This method must be implemented in a subclass")
    }
    
    @objc override func layoutSubviews() {
        super.layoutSubviews()
        
        if viewController == nil {
            embed(view: self, parentViewController: parentViewController)
        } else {
            viewController?.view.frame = bounds
        }

        if viewIsDirty {
            updateAllProperties()
            viewIsDirty = false
        }
    }
}
