Refactor Alerts

This commit is contained in:
世界
2025-12-01 18:22:06 +08:00
parent 8e764c56eb
commit 4ddfcdb324
40 changed files with 324 additions and 224 deletions
+5 -5
View File
@@ -11,7 +11,7 @@ struct MainView: View {
@State private var selection = NavigationPage.dashboard
@State private var importProfile: LibboxProfileContent?
@State private var importRemoteProfile: LibboxImportRemoteProfile?
@State private var alert: Alert?
@State private var alert: AlertState?
@State private var showGroups = false
@State private var showConnections = false
@State private var buttonState = ButtonVisibilityState()
@@ -122,7 +122,7 @@ struct MainView: View {
.onAppear {
environments.postReload()
}
.alertBinding($alert)
.alert($alert)
.onChangeCompat(of: scenePhase) { newValue in
if newValue == .active {
environments.postReload()
@@ -185,7 +185,7 @@ struct MainView: View {
var error: NSError?
importRemoteProfile = LibboxParseRemoteProfileImportLink(url.absoluteString, &error)
if let error {
alert = Alert(error)
alert = AlertState(error: error)
return
}
if selection != .dashboard {
@@ -197,14 +197,14 @@ struct MainView: View {
importProfile = try .from(Data(contentsOf: url))
url.stopAccessingSecurityScopedResource()
} catch {
alert = Alert(error)
alert = AlertState(error: error)
return
}
if selection != .dashboard {
selection = .dashboard
}
} else {
alert = Alert(errorMessage: String(localized: "Handled unknown URL \(url.absoluteString)"))
alert = AlertState(errorMessage: String(localized: "Handled unknown URL \(url.absoluteString)"))
}
}
}