add Sparkle appcast
This commit is contained in:
@@ -22,13 +22,11 @@ struct PreferencesView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
@EnvironmentObject private var updateViewModel: UpdateViewModel
|
||||
@EnvironmentObject private var sparkleUpdater: SparkleUpdater
|
||||
|
||||
@AppStorage("pingInterval") private var storedPingInterval: Int = 10
|
||||
@AppStorage("refreshInterval") private var storedRefreshInterval: Int = 60
|
||||
@AppStorage("showIntervalIndicator") private var showIntervalIndicator: Bool = true
|
||||
@AppStorage("autoCheckUpdates") private var autoCheckUpdates: Bool = true
|
||||
@AppStorage("includePrereleaseUpdates") private var includePrereleaseUpdates: Bool = true
|
||||
|
||||
@State private var pingIntervalSlider: Double = 10
|
||||
@State private var refreshIntervalSlider: Double = 60
|
||||
@@ -126,11 +124,8 @@ struct PreferencesView: View {
|
||||
case .alerts:
|
||||
AlertsPreferencesView()
|
||||
case .updates:
|
||||
UpdatesPreferencesView(
|
||||
autoCheckUpdates: $autoCheckUpdates,
|
||||
includePrereleaseUpdates: $includePrereleaseUpdates
|
||||
)
|
||||
.environmentObject(updateViewModel)
|
||||
UpdatesPreferencesView()
|
||||
.environmentObject(sparkleUpdater)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,46 +227,39 @@ private struct MonitorPreferencesView: View {
|
||||
}
|
||||
|
||||
private struct UpdatesPreferencesView: View {
|
||||
@Binding var autoCheckUpdates: Bool
|
||||
@Binding var includePrereleaseUpdates: Bool
|
||||
@EnvironmentObject var updateViewModel: UpdateViewModel
|
||||
@EnvironmentObject var sparkleUpdater: SparkleUpdater
|
||||
|
||||
private var automaticallyChecksBinding: Binding<Bool> {
|
||||
Binding(
|
||||
get: { sparkleUpdater.automaticallyChecksForUpdates },
|
||||
set: { sparkleUpdater.automaticallyChecksForUpdates = $0 }
|
||||
)
|
||||
}
|
||||
|
||||
private var automaticallyDownloadsBinding: Binding<Bool> {
|
||||
Binding(
|
||||
get: { sparkleUpdater.automaticallyDownloadsUpdates },
|
||||
set: { sparkleUpdater.automaticallyDownloadsUpdates = $0 }
|
||||
)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Toggle("Automatically check for updates", isOn: $autoCheckUpdates)
|
||||
.toggleStyle(.switch)
|
||||
VStack(alignment: .leading, spacing: 18) {
|
||||
Toggle("Automatically check for updates", isOn: automaticallyChecksBinding)
|
||||
Toggle("Automatically download updates", isOn: automaticallyDownloadsBinding)
|
||||
|
||||
Toggle("Include pre-release builds", isOn: $includePrereleaseUpdates)
|
||||
.toggleStyle(.switch)
|
||||
|
||||
HStack {
|
||||
if updateViewModel.isChecking {
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
Text("Checking for updates…")
|
||||
.foregroundColor(.secondary)
|
||||
} else {
|
||||
Button("Check Now") {
|
||||
updateViewModel.checkForUpdates(userInitiated: true)
|
||||
}
|
||||
}
|
||||
Button(action: sparkleUpdater.checkForUpdates) {
|
||||
Label("Check for Updates Now", systemImage: "sparkles")
|
||||
}
|
||||
|
||||
if let release = updateViewModel.latestFetchedRelease {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("Latest available: \(release.versionString)")
|
||||
.font(.subheadline)
|
||||
if release.prerelease {
|
||||
Text("Pre-release build")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
Text("Updates are delivered via Sparkle. Configure your appcast URL and public EdDSA key in Info.plist (keys `SUFeedURL` and `SUPublicEDKey`).")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.top, 4)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.toggleStyle(.switch)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user