mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 18:12:44 +02:00
Add loading indicators to the SwiftUI templates. (#6014)
This commit is contained in:
+22
@@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CommonKit
|
||||
|
||||
struct TemplateSimpleScreenCoordinatorParameters {
|
||||
let promptType: TemplateSimpleScreenPromptType
|
||||
@@ -30,6 +31,9 @@ final class TemplateSimpleScreenCoordinator: Coordinator, Presentable {
|
||||
private let templateSimpleScreenHostingController: UIViewController
|
||||
private var templateSimpleScreenViewModel: TemplateSimpleScreenViewModelProtocol
|
||||
|
||||
private var indicatorPresenter: UserIndicatorTypePresenterProtocol
|
||||
private var loadingIndicator: UserIndicator?
|
||||
|
||||
// MARK: Public
|
||||
|
||||
// Must be used only internally
|
||||
@@ -46,9 +50,12 @@ final class TemplateSimpleScreenCoordinator: Coordinator, Presentable {
|
||||
let view = TemplateSimpleScreen(viewModel: viewModel.context)
|
||||
templateSimpleScreenViewModel = viewModel
|
||||
templateSimpleScreenHostingController = VectorHostingController(rootView: view)
|
||||
|
||||
indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: templateSimpleScreenHostingController)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func start() {
|
||||
MXLog.debug("[TemplateSimpleScreenCoordinator] did start.")
|
||||
templateSimpleScreenViewModel.completion = { [weak self] result in
|
||||
@@ -61,4 +68,19 @@ final class TemplateSimpleScreenCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
return self.templateSimpleScreenHostingController
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
/// Show an activity indicator whilst loading.
|
||||
/// - Parameters:
|
||||
/// - label: The label to show on the indicator.
|
||||
/// - isInteractionBlocking: Whether the indicator should block any user interaction.
|
||||
private func startLoading(label: String = VectorL10n.loading, isInteractionBlocking: Bool = true) {
|
||||
loadingIndicator = indicatorPresenter.present(.loading(label: label, isInteractionBlocking: isInteractionBlocking))
|
||||
}
|
||||
|
||||
/// Hide the currently displayed activity indicator.
|
||||
private func stopLoading() {
|
||||
loadingIndicator = nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user