Created
August 29, 2019 12:57
-
-
Save agiguere/0b1c23f6a804acc2492616b67301fe04 to your computer and use it in GitHub Desktop.
SAP Fiori for iOS SDK Code Snippet: FUI Loading Indicator Providing Protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SAPFiori | |
/// SAP Fiori loading indicator helper / utility methods | |
public protocol FUILoadingIndicatorProviding: class { | |
var loadingIndicator: FUILoadingIndicatorView? { get set } | |
} | |
public extension FUILoadingIndicatorProviding where Self: UIViewController { | |
/// Show a loading indicator | |
/// | |
/// - Parameter message: Message description to be display | |
func showLoadingIndicator(_ message: String = "") { | |
DispatchQueue.main.async { | |
let indicator = FUILoadingIndicatorView(frame: self.view.frame) | |
indicator.text = message | |
self.view.addSubview(indicator) | |
indicator.show() | |
self.loadingIndicator = indicator | |
} | |
} | |
/// Hide the current loading indicator | |
func hideLoadingIndicator() { | |
DispatchQueue.main.async { | |
guard let loadingIndicator = self.loadingIndicator else { return } | |
loadingIndicator.dismiss() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment