mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-05 23:47:44 +02:00
Feature/2821 server maintenance info
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum OnBoardingSplashScreenAlertType {
|
||||
case showServerMaintenanceAlert, showServerMaintenanceDefaultAlert, showInvalidAppVersionAlert, showDowntimeTimeAlert
|
||||
}
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
/// The splash screen shown at the beginning of the onboarding flow.
|
||||
struct OnboardingBwiSplashScreen: View {
|
||||
@@ -26,13 +30,13 @@ struct OnboardingBwiSplashScreen: View {
|
||||
|
||||
@Environment(\.theme) private var theme
|
||||
@Environment(\.layoutDirection) private var layoutDirection
|
||||
private let service = ServerDowntimeDefaultService()
|
||||
|
||||
/// The dimensions of the stack with the action buttons and page indicator.
|
||||
@State private var overlayFrame: CGRect = .zero
|
||||
@State private var showServerMaintananceAlert = false
|
||||
@State private var showServerMaintananceDefaultAlert = false
|
||||
@State private var showInvalidAppVersionAlert = false
|
||||
@State private var isFetchingDowntime = false
|
||||
@State private var showAlert = false
|
||||
@State private var activeAlert: OnBoardingSplashScreenAlertType = .showInvalidAppVersionAlert
|
||||
|
||||
// MARK: Public
|
||||
|
||||
@@ -74,53 +78,81 @@ struct OnboardingBwiSplashScreen: View {
|
||||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.alert(isPresented: $showServerMaintananceAlert) {
|
||||
Alert(title: Text(BWIL10n.downtimeTitle),
|
||||
message: Text(ServerDowntimeDefaultService().downtimeText()),
|
||||
dismissButton: .destructive(Text(BWIL10n.downtimeAlertDismissButton)) {
|
||||
viewModel.send(viewAction: .login)
|
||||
})
|
||||
}
|
||||
.alert(isPresented: $showServerMaintananceDefaultAlert) {
|
||||
Alert(title: Text(BWIL10n.downtimeTitle),
|
||||
message: Text(BWIL10n.downtimeDefaultMessage),
|
||||
dismissButton: .destructive(Text(BWIL10n.downtimeAlertDismissButton)) {
|
||||
viewModel.send(viewAction: .login)
|
||||
})
|
||||
}
|
||||
.alert(isPresented: $showInvalidAppVersionAlert) {
|
||||
Alert(title: Text(BWIL10n.bwiOutdatedVersionWarningTitle),
|
||||
message: Text(BWIL10n.bwiOutdatedVersionWarningMessage(AppInfo.current.displayName)),
|
||||
dismissButton: .destructive(Text(BWIL10n.bwiOutdatedVersionAppstoreButton), action: {
|
||||
let iTunesLink = "itms://itunes.apple.com/app/BwMessenger/id1518548153?mt=8"
|
||||
UIApplication.shared.open(URL(string: iTunesLink)!, options: [:], completionHandler: nil)
|
||||
}))
|
||||
}
|
||||
.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 = "itms://itunes.apple.com/app/BwMessenger/id1518548153?mt=8"
|
||||
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(BWIL10n.downtimeAlertDismissButton)) {
|
||||
return
|
||||
})
|
||||
case .showServerMaintenanceAlert:
|
||||
return Alert(title: Text(BWIL10n.downtimeTitle),
|
||||
message: Text(ServerDowntimeDefaultService().downtimeText()),
|
||||
dismissButton: .destructive(Text(BWIL10n.downtimeAlertDismissButton)) {
|
||||
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)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private func startButtonAction() {
|
||||
// let service = ServerDowntimeDefaultService()
|
||||
// if service.isDowntimePresentable() /*&& service.isDowntimeNow()*/ {
|
||||
// showServerMaintananceAlert = true
|
||||
// } else {
|
||||
if BWIBuildSettings.shared.enableMaintenanceInfoOnWelcomeScreen {
|
||||
isFetchingDowntime = true // show progresview
|
||||
|
||||
if BWIBuildSettings.shared.useTestDataForDowntime {
|
||||
service.fetchDowntimes {
|
||||
self.isFetchingDowntime = false // hide progressview
|
||||
self.showAlertIfNeeded()
|
||||
}
|
||||
} else {
|
||||
service.fetchDowntimesWithDirectRequest { success in
|
||||
DispatchQueue.main.async {
|
||||
self.isFetchingDowntime = false // hide progressview
|
||||
if success {
|
||||
self.showAlertIfNeeded()
|
||||
} else {
|
||||
showAlert = true
|
||||
activeAlert = .showServerMaintenanceDefaultAlert
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
viewModel.send(viewAction: .login)
|
||||
// }
|
||||
|
||||
// isFetchingDowntime = true // show progresview
|
||||
//
|
||||
// let service = ServerDowntimeDefaultService()
|
||||
// service.fetchDowntimesWithDirectRequest { success in
|
||||
// self.isFetchingDowntime = false // hide progressview
|
||||
// if success {
|
||||
// if service.isDowntimePresentable() && service.isDowntimeNow() {
|
||||
// showServerMaintananceAlert = true
|
||||
// } else {
|
||||
// viewModel.send(viewAction: .login)
|
||||
// }
|
||||
// } else {
|
||||
// showServerMaintananceDefaultAlert = true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func showAlertIfNeeded() {
|
||||
switch service.nextDowntimeType() {
|
||||
case .none:
|
||||
viewModel.send(viewAction: .login)
|
||||
break
|
||||
case .ongoing:
|
||||
showAlert = true
|
||||
activeAlert = .showDowntimeTimeAlert
|
||||
break
|
||||
case .warning:
|
||||
// only show active downtimes
|
||||
viewModel.send(viewAction: .login)
|
||||
// showAlert = true
|
||||
// activeAlert = .showServerMaintenanceAlert
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user