Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  SpinnerPresenter.swift   Sprache: JAVA

 

import MBProgressHUD
import UIKit

@MainActor
enum SpinnerPresenter {
    static func presentSpinner<T>(
        label: String,
        window: UIWindow?,
        while action: () throws -> T
    ) async throws -> T {
        guard let window else {
            fatalError("No window to present UI on")
        }

        let progressHUD = MBProgressHUD(view: window)
        progressHUD.label.numberOfLines = 0
        progressHUD.label.text = String(format: label, TargetManager.appName)
        progressHUD.mode = .indeterminate

        window.addSubview(progressHUD)
        progressHUD.show(animated: true)

        UIApplication.shared.isIdleTimerDisabled = true
        try await Task.sleep(seconds: 0.3)

        let result = try action()

        progressHUD.hide(animated: true)
        progressHUD.removeFromSuperview()

        UIApplication.shared.isIdleTimerDisabled = false
        return result
    }

    /// Shows an indeterminate spinner on top of `view` while the asynchronous `action` runs.
    ///
    /// Use this instead of `presentSpinner(label:window:while:)` if the work is asynchronous or if
    /// the spinner belongs to a specific view instead of the window. Note that the view has to be
    /// the one that is actually visible: a spinner added to the view of a view controller that is
    /// covered by a presented view controller (such as the onboarding wizard) never shows up.
    static func presentSpinner<T>(
        in view: UIView,
        while action: () async throws -> T
    ) async throws -> T {
        let progressHUD = MBProgressHUD.showAdded(to: view, animated: true)
        progressHUD.mode = .indeterminate

        defer {
            progressHUD.hide(animated: true)
        }

        return try await action()
    }
}

Messung
CHZG
859510093

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104850
#Domains=416975