vds_ios/VDS/Components/Loader/LoaderViewController.swift
Matt Bruce 58a4dc594a updated to included a LoaderLaunchable
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-07-05 16:04:38 -05:00

45 lines
1.1 KiB
Swift

//
// LoaderViewController.swift
// VDS
//
// Created by Matt Bruce on 7/5/23.
//
import Foundation
import UIKit
import VDSColorTokens
public class LoaderViewController: UIViewController, Surfaceable {
private var loader = Loader()
private var backgroundColorConfiguration = SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryDark)
public var surface: Surface = .light
public var size: Int?
public override func viewDidLoad() {
super.viewDidLoad()
setup()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
updateView()
}
open func updateView() {
view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.8)
if let size {
loader.size = size
}
loader.surface = surface
}
private func setup() {
view.addSubview(loader)
NSLayoutConstraint.activate([
loader.centerXAnchor.constraint(equalTo: view.centerXAnchor),
loader.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}
}