Fix preview

This commit is contained in:
世界
2023-07-30 15:35:10 +08:00
parent 2ca6c515b9
commit fed5419ea0
8 changed files with 94 additions and 73 deletions
@@ -58,7 +58,7 @@ public struct DashboardView: View {
if ApplicationLibrary.inPreview {
ActiveDashboardView()
} else if let profile = extensionProfile.wrappedValue {
ActiveDashboardView().environmentObject(profile)
DashboardView1().environmentObject(profile)
} else {
FormView {
InstallProfileButton()
@@ -66,4 +66,28 @@ public struct DashboardView: View {
}
}
}
struct DashboardView1: View {
@EnvironmentObject private var profile: ExtensionProfile
@State private var alert: Alert?
var body: some View {
ActiveDashboardView()
.environmentObject(profile)
EmptyView()
.alertBinding($alert)
.onChangeCompat(of: profile.status) { newValue in
if newValue == .disconnecting || newValue == .connected {
Task.detached {
if let serviceError = try? String(contentsOf: ExtensionProvider.errorFile) {
DispatchQueue.main.async {
alert = Alert(errorMessage: serviceError)
}
try? FileManager.default.removeItem(at: ExtensionProvider.errorFile)
}
}
}
}
}
}
}