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 TemplateUserProfileCoordinatorParameters {
|
||||
let session: MXSession
|
||||
@@ -30,6 +31,9 @@ final class TemplateUserProfileCoordinator: Coordinator, Presentable {
|
||||
private let templateUserProfileHostingController: UIViewController
|
||||
private var templateUserProfileViewModel: TemplateUserProfileViewModelProtocol
|
||||
|
||||
private var indicatorPresenter: UserIndicatorTypePresenterProtocol
|
||||
private var loadingIndicator: UserIndicator?
|
||||
|
||||
// MARK: Public
|
||||
|
||||
// Must be used only internally
|
||||
@@ -46,9 +50,12 @@ final class TemplateUserProfileCoordinator: Coordinator, Presentable {
|
||||
.addDependency(AvatarService.instantiate(mediaManager: parameters.session.mediaManager))
|
||||
templateUserProfileViewModel = viewModel
|
||||
templateUserProfileHostingController = VectorHostingController(rootView: view)
|
||||
|
||||
indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: templateUserProfileHostingController)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func start() {
|
||||
MXLog.debug("[TemplateUserProfileCoordinator] did start.")
|
||||
templateUserProfileViewModel.completion = { [weak self] result in
|
||||
@@ -64,4 +71,19 @@ final class TemplateUserProfileCoordinator: Coordinator, Presentable {
|
||||
func toPresentable() -> UIViewController {
|
||||
return self.templateUserProfileHostingController
|
||||
}
|
||||
|
||||
// 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