forked from shadowfacts/Tusker
Add CloudKit status indicator to advanced prefs
This commit is contained in:
parent
5ab22e742b
commit
79b9108a8f
|
@ -8,15 +8,18 @@
|
|||
import SwiftUI
|
||||
import Pachyderm
|
||||
import CoreData
|
||||
import CloudKit
|
||||
|
||||
struct AdvancedPrefsView : View {
|
||||
@ObservedObject var preferences = Preferences.shared
|
||||
@State private var imageCacheSize: Int64 = 0
|
||||
@State private var mastodonCacheSize: Int64 = 0
|
||||
@State private var cloudKitStatus: CKAccountStatus?
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
formattingSection
|
||||
cloudKitSection
|
||||
errorReportingSection
|
||||
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 {
|
||||
Section {
|
||||
Toggle("Report Errors Automatically", isOn: $preferences.reportErrorsAutomatically)
|
||||
|
|
Loading…
Reference in New Issue