Skip to content

Commit dfaeea0

Browse files
committed
add a spinner when starting LLS
1 parent ac7f259 commit dfaeea0

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
184184
}
185185

186186
private func startLiveLocationSharingInRoom(duration: Duration) async {
187+
showLoader()
188+
defer {
189+
hideLoader()
190+
}
191+
187192
let result = await liveLocationManager.startLiveLocation(roomID: roomProxy.id,
188193
duration: duration)
189194

@@ -222,15 +227,28 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
222227
}
223228

224229
private func showErrorIndicator() {
225-
userIndicatorController.submitIndicator(UserIndicator(id: statusIndicatorID,
230+
userIndicatorController.submitIndicator(UserIndicator(id: Self.statusIndicatorID,
226231
type: .toast,
227232
title: L10n.errorUnknown,
228233
iconName: "xmark"))
229234
}
230235

231-
private var statusIndicatorID: String {
232-
"\(Self.self)-Status"
236+
private func showLoader() {
237+
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorID,
238+
type: .modal(progress: .indeterminate,
239+
interactiveDismissDisabled: true,
240+
allowsInteraction: false),
241+
title: L10n.commonLoading,
242+
persistent: true))
243+
}
244+
245+
private func hideLoader() {
246+
userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorID)
233247
}
248+
249+
private static let loadingIndicatorID = "\(LocationSharingScreenViewModel.self)-Loading"
250+
251+
private static let statusIndicatorID = "\(LocationSharingScreenViewModel.self)-Status"
234252
}
235253

236254
extension LocationSharingScreenViewModel {

0 commit comments

Comments
 (0)