mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
Feature/3811 appconfig
This commit is contained in:
@@ -17,10 +17,6 @@
|
||||
import SwiftUI
|
||||
import AVKit
|
||||
|
||||
enum AuthenticationServerSelectionScreenAlertType {
|
||||
case showServerMaintenanceInfoMessageAlert, showServerMaintenanceDefaultAlert, showInvalidAppVersionAlert, showDowntimeTimeAlert, showInvalidServerAlert
|
||||
}
|
||||
|
||||
struct AuthenticationServerSelectionScreen: View {
|
||||
// MARK: - Properties
|
||||
|
||||
@@ -39,7 +35,8 @@ struct AuthenticationServerSelectionScreen: View {
|
||||
// bwi #4976 show maintenance alert
|
||||
@State private var isFetchingDowntime = false
|
||||
@State private var showAlert = false
|
||||
@State private var activeAlert: AuthenticationServerSelectionScreenAlertType = .showInvalidAppVersionAlert
|
||||
@State private var isInvalidServerAlert = false
|
||||
@State private var activeAlert: ServerMaintenanceAlertType = .showInvalidAppVersionAlert
|
||||
|
||||
private var textFieldFooterColor: Color {
|
||||
viewModel.viewState.hasValidationError ? theme.colors.alert : theme.colors.tertiaryContent
|
||||
@@ -98,67 +95,12 @@ struct AuthenticationServerSelectionScreen: View {
|
||||
}
|
||||
}
|
||||
.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:
|
||||
if BWIBuildSettings.shared.ignoreBlockingMaintenance && service.isBlocking() {
|
||||
return Alert( title: Text(""),
|
||||
message: Text(ServerDowntimeDefaultService().downtimeText()),
|
||||
primaryButton: .cancel(Text(BWIL10n.blockingDowntimeAlertIgnoreButton)) {
|
||||
UserDefaults.standard.set(false, forKey: "ServerDownTimeBlockingKey")
|
||||
service.setManuallyIgnored()
|
||||
self.submit()
|
||||
},
|
||||
secondaryButton: .destructive(Text(BWIL10n.blockingDowntimeAlertDismissButton))
|
||||
)
|
||||
|
||||
} else {
|
||||
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 {
|
||||
self.submit()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
case .showServerMaintenanceInfoMessageAlert:
|
||||
if BWIBuildSettings.shared.ignoreBlockingMaintenance && service.isBlocking() {
|
||||
return Alert( title: Text(""),
|
||||
message: Text(ServerDowntimeDefaultService().downtimeText()),
|
||||
primaryButton: .cancel(Text(BWIL10n.blockingDowntimeAlertIgnoreButton)) {
|
||||
self.submit()
|
||||
},
|
||||
secondaryButton: .destructive(Text(BWIL10n.blockingDowntimeAlertDismissButton))
|
||||
)
|
||||
|
||||
} else {
|
||||
return Alert(title: Text(""),
|
||||
message: Text(ServerDowntimeDefaultService().downtimeText()),
|
||||
dismissButton: .destructive(Text(service.isBlocking() ? BWIL10n.blockingDowntimeAlertDismissButton : BWIL10n.downtimeAlertDismissButton)) {
|
||||
if service.isBlocking() {
|
||||
return
|
||||
} else {
|
||||
self.submit()
|
||||
}
|
||||
})
|
||||
}
|
||||
case .showServerMaintenanceDefaultAlert:
|
||||
return Alert(title: Text(BWIL10n.downtimeTitle),
|
||||
message: Text(BWIL10n.downtimeDefaultMessage),
|
||||
dismissButton: .destructive(Text(BWIL10n.downtimeAlertDismissButton)) {
|
||||
self.submit()
|
||||
})
|
||||
case .showInvalidServerAlert:
|
||||
if isInvalidServerAlert {
|
||||
return self.invalidServerAlert()
|
||||
} else {
|
||||
return service.alert(alertType: activeAlert) {
|
||||
self.submit()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -274,7 +216,7 @@ struct AuthenticationServerSelectionScreen: View {
|
||||
if isHomeserverAddressValid(viewModel.homeserverAddress) {
|
||||
viewModel.send(viewAction: .confirm)
|
||||
} else {
|
||||
activeAlert = .showInvalidServerAlert
|
||||
isInvalidServerAlert = true
|
||||
showAlert = true
|
||||
}
|
||||
}
|
||||
@@ -362,18 +304,11 @@ struct AuthenticationServerSelectionScreen: View {
|
||||
}
|
||||
|
||||
private func showAlertIfNeeded() {
|
||||
switch service.nextDowntimeStatus() {
|
||||
case .none, .warning:
|
||||
self.submit()
|
||||
break
|
||||
case .ongoing:
|
||||
if service.downtimeType() == .adhocMessage {
|
||||
activeAlert = .showServerMaintenanceInfoMessageAlert
|
||||
} else {
|
||||
activeAlert = .showDowntimeTimeAlert
|
||||
}
|
||||
if service.showAlert() {
|
||||
activeAlert = service.alertType()
|
||||
showAlert = true
|
||||
break
|
||||
} else {
|
||||
self.submit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user