Feature/3811 appconfig

This commit is contained in:
Frank Rotermund
2023-09-19 11:21:12 +00:00
parent e3cfb301a9
commit 5dd5dc2db7
13 changed files with 205 additions and 145 deletions
@@ -16,10 +16,6 @@
import SwiftUI
enum OnBoardingSplashScreenAlertType {
case showServerMaintenanceInfoMessageAlert, showServerMaintenanceDefaultAlert, showInvalidAppVersionAlert, showDowntimeTimeAlert
}
@available(iOS 14.0, *)
/// The splash screen shown at the beginning of the onboarding flow.
struct OnboardingBwiSplashScreen: View {
@@ -36,7 +32,7 @@ struct OnboardingBwiSplashScreen: View {
@State private var overlayFrame: CGRect = .zero
@State private var isFetchingDowntime = false
@State private var showAlert = false
@State private var activeAlert: OnBoardingSplashScreenAlertType = .showInvalidAppVersionAlert
@State private var activeAlert: ServerMaintenanceAlertType = .showInvalidAppVersionAlert
// MARK: Public
@@ -79,40 +75,8 @@ struct OnboardingBwiSplashScreen: View {
.navigationTitle("")
.navigationBarHidden(true)
.alert(isPresented: $showAlert, content: {
switch activeAlert {
case .showInvalidAppVersionAlert:
return Alert(title: Text(BWIL10n.bwiOutdatedVersionWarningTitle),
message: Text(BWIL10n.bwiOutdatedVersionWarningMessage(AppInfo.current.displayName)),
dismissButton: .destructive(Text(BWIL10n.bwiOutdatedVersionAppstoreButton), action: {
let iTunesLink = BWIBuildSettings.shared.itunesAppLink
UIApplication.shared.open(URL(string: iTunesLink)!, options: [:], completionHandler: nil)
}))
case .showDowntimeTimeAlert:
return Alert(title: Text(BWIL10n.downtimeTitle),
message: Text(ServerDowntimeDefaultService().downtimeText() != "" ? BWIL10n.downtimeDefaultMessage + "\n\n" + ServerDowntimeDefaultService().downtimeText() : BWIL10n.downtimeDefaultMessage),
dismissButton: .destructive(Text(service.isBlocking() ? BWIL10n.blockingDowntimeAlertDismissButton : BWIL10n.downtimeAlertDismissButton)) {
if service.isBlocking() {
return
} else {
viewModel.send(viewAction: .login)
}
})
case .showServerMaintenanceInfoMessageAlert:
return Alert(title: Text(""),
message: Text(ServerDowntimeDefaultService().downtimeText()),
dismissButton: .destructive(Text(service.isBlocking() ? BWIL10n.blockingDowntimeAlertDismissButton : BWIL10n.downtimeAlertDismissButton)) {
if service.isBlocking() {
return
} else {
viewModel.send(viewAction: .login)
}
})
case .showServerMaintenanceDefaultAlert:
return Alert(title: Text(BWIL10n.downtimeTitle),
message: Text(BWIL10n.downtimeDefaultMessage),
dismissButton: .destructive(Text(BWIL10n.downtimeAlertDismissButton)) {
viewModel.send(viewAction: .login)
})
service.alert(alertType: activeAlert) {
viewModel.send(viewAction: .login)
}
})
}
@@ -146,24 +110,11 @@ struct OnboardingBwiSplashScreen: View {
private func showAlertIfNeeded() {
switch service.nextDowntimeStatus() {
case .none:
viewModel.send(viewAction: .login)
break
case .ongoing:
if service.downtimeType() == .adhocMessage {
activeAlert = .showServerMaintenanceInfoMessageAlert
} else {
activeAlert = .showDowntimeTimeAlert
}
if service.showAlert() {
activeAlert = service.alertType()
showAlert = true
break
case .warning:
// only show active downtimes
} else {
viewModel.send(viewAction: .login)
// showAlert = true
// activeAlert = .showServerMaintenanceAlert
break
}
}
}