Add CloudKit status indicator to advanced prefs
This commit is contained in:
parent
5ab22e742b
commit
79b9108a8f
|
@ -8,15 +8,18 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
import CoreData
|
import CoreData
|
||||||
|
import CloudKit
|
||||||
|
|
||||||
struct AdvancedPrefsView : View {
|
struct AdvancedPrefsView : View {
|
||||||
@ObservedObject var preferences = Preferences.shared
|
@ObservedObject var preferences = Preferences.shared
|
||||||
@State private var imageCacheSize: Int64 = 0
|
@State private var imageCacheSize: Int64 = 0
|
||||||
@State private var mastodonCacheSize: Int64 = 0
|
@State private var mastodonCacheSize: Int64 = 0
|
||||||
|
@State private var cloudKitStatus: CKAccountStatus?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
formattingSection
|
formattingSection
|
||||||
|
cloudKitSection
|
||||||
errorReportingSection
|
errorReportingSection
|
||||||
cachingSection
|
cachingSection
|
||||||
}
|
}
|
||||||
|
@ -49,6 +52,39 @@ struct AdvancedPrefsView : View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cloudKitSection: some View {
|
||||||
|
Section {
|
||||||
|
HStack {
|
||||||
|
Text("iCloud Status")
|
||||||
|
Spacer()
|
||||||
|
switch cloudKitStatus {
|
||||||
|
case nil:
|
||||||
|
EmptyView()
|
||||||
|
case .available:
|
||||||
|
Text("Available")
|
||||||
|
case .couldNotDetermine:
|
||||||
|
Text("Could not determine")
|
||||||
|
case .noAccount:
|
||||||
|
Text("No account")
|
||||||
|
case .restricted:
|
||||||
|
Text("Restricted")
|
||||||
|
case .temporarilyUnavailable:
|
||||||
|
Text("Temporarily Unavailable")
|
||||||
|
@unknown default:
|
||||||
|
Text(String(describing: cloudKitStatus!))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.task {
|
||||||
|
CKContainer.default().accountStatus { status, error in
|
||||||
|
if let error {
|
||||||
|
Logging.general.error("Unable to get CloudKit status: \(String(describing: error))")
|
||||||
|
} else {
|
||||||
|
self.cloudKitStatus = status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var errorReportingSection: some View {
|
var errorReportingSection: some View {
|
||||||
Section {
|
Section {
|
||||||
Toggle("Report Errors Automatically", isOn: $preferences.reportErrorsAutomatically)
|
Toggle("Report Errors Automatically", isOn: $preferences.reportErrorsAutomatically)
|
||||||
|
|
Loading…
Reference in New Issue