updated to included a LoaderLaunchable
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2ffc8f5293
commit
58a4dc594a
@ -110,6 +110,8 @@
|
||||
EAD062A72A3B67770015965D /* UIView+CALayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062A62A3B67770015965D /* UIView+CALayer.swift */; };
|
||||
EAD062B02A3B873E0015965D /* BadgeIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062AF2A3B873E0015965D /* BadgeIndicator.swift */; };
|
||||
EAD0688E2A55F819002E3A2D /* Loader.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD0688D2A55F819002E3A2D /* Loader.swift */; };
|
||||
EAD068922A560B65002E3A2D /* LoaderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD068912A560B65002E3A2D /* LoaderViewController.swift */; };
|
||||
EAD068942A560C13002E3A2D /* LoaderLaunchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD068932A560C13002E3A2D /* LoaderLaunchable.swift */; };
|
||||
EAD8D2C128BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD8D2C028BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift */; };
|
||||
EAF1FE9929D4850E00101452 /* Clickable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF1FE9829D4850E00101452 /* Clickable.swift */; };
|
||||
EAF1FE9B29DB1A6000101452 /* Changeable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF1FE9A29DB1A6000101452 /* Changeable.swift */; };
|
||||
@ -245,6 +247,8 @@
|
||||
EAD062A62A3B67770015965D /* UIView+CALayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+CALayer.swift"; sourceTree = "<group>"; };
|
||||
EAD062AF2A3B873E0015965D /* BadgeIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeIndicator.swift; sourceTree = "<group>"; };
|
||||
EAD0688D2A55F819002E3A2D /* Loader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Loader.swift; sourceTree = "<group>"; };
|
||||
EAD068912A560B65002E3A2D /* LoaderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoaderViewController.swift; sourceTree = "<group>"; };
|
||||
EAD068932A560C13002E3A2D /* LoaderLaunchable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoaderLaunchable.swift; sourceTree = "<group>"; };
|
||||
EAD8D2C028BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIGestureRecognizer+Publisher.swift"; sourceTree = "<group>"; };
|
||||
EAF1FE9829D4850E00101452 /* Clickable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Clickable.swift; sourceTree = "<group>"; };
|
||||
EAF1FE9A29DB1A6000101452 /* Changeable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Changeable.swift; sourceTree = "<group>"; };
|
||||
@ -710,6 +714,8 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EAD0688D2A55F819002E3A2D /* Loader.swift */,
|
||||
EAD068912A560B65002E3A2D /* LoaderViewController.swift */,
|
||||
EAD068932A560C13002E3A2D /* LoaderLaunchable.swift */,
|
||||
);
|
||||
path = Loader;
|
||||
sourceTree = "<group>";
|
||||
@ -915,6 +921,7 @@
|
||||
EAF7F0B1289B177F00B287F5 /* ColorLabelAttribute.swift in Sources */,
|
||||
EAC9258F2911C9DE00091998 /* EntryField.swift in Sources */,
|
||||
EAB1D2EA28AE84AA00DAE764 /* UIControlPublisher.swift in Sources */,
|
||||
EAD068922A560B65002E3A2D /* LoaderViewController.swift in Sources */,
|
||||
EABFEB642A26473700C4C106 /* NSAttributedString.swift in Sources */,
|
||||
EAF7F13328A2A16500B287F5 /* AttachmentLabelAttributeModel.swift in Sources */,
|
||||
EA0FC2C62914222900DF80B4 /* ButtonGroup.swift in Sources */,
|
||||
@ -973,6 +980,7 @@
|
||||
EA596ABF2A16B4F500300C4B /* Tabs.swift in Sources */,
|
||||
EAC71A212A2E1DC000E47A9F /* SelectorItemBase.swift in Sources */,
|
||||
EAD062A72A3B67770015965D /* UIView+CALayer.swift in Sources */,
|
||||
EAD068942A560C13002E3A2D /* LoaderLaunchable.swift in Sources */,
|
||||
EA985BEC2968A91200F2FF2E /* TitleLockupTitleModel.swift in Sources */,
|
||||
5FC35BE328D51405004EBEAC /* Button.swift in Sources */,
|
||||
);
|
||||
|
||||
@ -28,18 +28,10 @@ open class Loader: View {
|
||||
|
||||
/// The Int used to determine the height and width of the Loader
|
||||
public var size: Int = 40 { didSet { setNeedsUpdate() } }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Lifecycle
|
||||
//--------------------------------------------------
|
||||
|
||||
override open var layer: CAShapeLayer {
|
||||
get { return super.layer as! CAShapeLayer }
|
||||
}
|
||||
|
||||
override open class var layerClass: AnyClass {
|
||||
return CAShapeLayer.self
|
||||
}
|
||||
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
addSubview(icon)
|
||||
|
||||
36
VDS/Components/Loader/LoaderLaunchable.swift
Normal file
36
VDS/Components/Loader/LoaderLaunchable.swift
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// LoaderLaunchable.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 7/5/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public protocol LoaderLaunchable {
|
||||
func presentLoader(surface: Surface, size: Int?)
|
||||
func dismissLoader()
|
||||
}
|
||||
|
||||
extension LoaderLaunchable {
|
||||
public func presentLoader(surface: Surface, size: Int? = nil) {
|
||||
if let presenting = UIApplication.topViewController() {
|
||||
let viewController = LoaderViewController(nibName: nil, bundle: nil).with {
|
||||
$0.surface = surface
|
||||
if let size {
|
||||
$0.size = size
|
||||
}
|
||||
$0.modalPresentationStyle = .overFullScreen
|
||||
$0.modalTransitionStyle = .crossDissolve
|
||||
}
|
||||
presenting.present(viewController, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
public func dismissLoader() {
|
||||
if let presenting = UIApplication.topViewController() as? LoaderViewController {
|
||||
presenting.dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
44
VDS/Components/Loader/LoaderViewController.swift
Normal file
44
VDS/Components/Loader/LoaderViewController.swift
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// 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)
|
||||
])
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user