vds_ios/VDS/Components/Loader/LoaderViewController.swift
Matt Bruce fcbb6e99e4 added comments
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-07-10 14:46:19 -05:00

55 lines
1.9 KiB
Swift

//
// LoaderViewController.swift
// VDS
//
// Created by Matt Bruce on 7/5/23.
//
import Foundation
import UIKit
import VDSColorTokens
/// ViewController to show the Loader, this will be presented using the LoaderLaunchable Protocl.
open class LoaderViewController: UIViewController, Surfaceable {
//--------------------------------------------------
// MARK: - Private Properties
//--------------------------------------------------
private var loader = Loader()
private var backgroundColorConfiguration = SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryDark)
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
/// Current Surface used within this Control and used to passdown to child views
open var surface: Surface = .light { didSet { updateView() }}
/// Size of the Height and Width of the Loader view.
open var size: Int? { didSet { updateView() }}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(loader)
NSLayoutConstraint.activate([
loader.centerXAnchor.constraint(equalTo: view.centerXAnchor),
loader.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
updateView()
}
/// Update this view based off of property chang
open func updateView() {
view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.8)
if let size {
loader.size = size
}
loader.surface = surface
}
}