Add a generic ErrorAlertInfo type.

Adopt it in Location Sharing and Polls.
This commit is contained in:
Doug
2022-03-03 16:30:00 +00:00
committed by Doug
parent 66bf8f0428
commit 572b1ff3bb
8 changed files with 85 additions and 57 deletions
@@ -72,14 +72,14 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
state.showLoadingIndicator = true
}
func stopLoading(error: LocationSharingErrorAlertInfo.AlertType?) {
func stopLoading(error: LocationSharingAlertType?) {
state.showLoadingIndicator = false
if let error = error {
state.bindings.alertInfo = LocationSharingErrorAlertInfo(id: error,
title: VectorL10n.locationSharingPostFailureTitle,
subtitle: VectorL10n.locationSharingPostFailureSubtitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, nil))
state.bindings.alertInfo = ErrorAlertInfo(id: error,
title: VectorL10n.locationSharingPostFailureTitle,
message: VectorL10n.locationSharingPostFailureSubtitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, nil))
}
}
@@ -96,18 +96,18 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
switch error {
case .failedLoadingMap:
state.bindings.alertInfo = LocationSharingErrorAlertInfo(id: .mapLoadingError,
title: VectorL10n.locationSharingLoadingMapErrorTitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, primaryButtonCompletion))
state.bindings.alertInfo = ErrorAlertInfo(id: LocationSharingAlertType.mapLoadingError,
title: VectorL10n.locationSharingLoadingMapErrorTitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, primaryButtonCompletion))
case .failedLocatingUser:
state.bindings.alertInfo = LocationSharingErrorAlertInfo(id: .userLocatingError,
title: VectorL10n.locationSharingLocatingUserErrorTitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, primaryButtonCompletion))
state.bindings.alertInfo = ErrorAlertInfo(id: LocationSharingAlertType.userLocatingError,
title: VectorL10n.locationSharingLocatingUserErrorTitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, primaryButtonCompletion))
case .invalidLocationAuthorization:
state.bindings.alertInfo = LocationSharingErrorAlertInfo(id: .authorizationError,
title: VectorL10n.locationSharingInvalidAuthorizationErrorTitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.locationSharingInvalidAuthorizationNotNow, primaryButtonCompletion),
secondaryButton: (VectorL10n.locationSharingInvalidAuthorizationSettings, {
state.bindings.alertInfo = ErrorAlertInfo(id: LocationSharingAlertType.authorizationError,
title: VectorL10n.locationSharingInvalidAuthorizationErrorTitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.locationSharingInvalidAuthorizationNotNow, primaryButtonCompletion),
secondaryButton: (VectorL10n.locationSharingInvalidAuthorizationSettings, {
if let applicationSettingsURL = URL(string:UIApplication.openSettingsURLString) {
UIApplication.shared.open(applicationSettingsURL)
}