Newer
Older
Meterage_iOS / Meterage / Utils / LoadingHub.swift
//
//  LoadingHub.swift
//  Meterage
//
//  Created by 203 on 2023/2/2.
//

import Foundation
import MBProgressHUD

class LoadingHub {
    public static var shared = LoadingHub()
    private var window: UIWindow {
        UIApplication.shared.keyWindow!
    }
    public weak var hud: MBProgressHUD?

    func showLoading(text: String = "") {
        hud = MBProgressHUD.showAdded(to: window, animated: true)
        hud?.label.text = text
    }

    func hideLoading() {
        MBProgressHUD.hide(for: window, animated: true)
    }
}