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

44 lines
1.2 KiB
Swift

//
// LoaderLaunchable.swift
// VDS
//
// Created by Matt Bruce on 7/5/23.
//
import Foundation
import UIKit
/// Protocol used for any object to be able to launch a loader
public protocol LoaderLaunchable {
func presentLoader(surface: Surface, size: Int?)
func dismissLoader()
}
extension LoaderLaunchable {
/// Default implementation for presenting
/// - Parameters:
/// - surface: Surface for the Loader
/// - size: Size for the loader, nil is default.
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)
}
}
/// Dismisses the Loader
public func dismissLoader() {
if let presenting = UIApplication.topViewController() as? LoaderViewController {
presenting.dismiss(animated: true)
}
}
}