add in cloudkit toggle

This commit is contained in:
Trey t
2022-01-26 12:08:40 -06:00
parent 6c96602bff
commit 8c58b37be5
10 changed files with 88 additions and 38 deletions

View File

@@ -20,6 +20,8 @@ struct SettingsView: View {
@State private var showWhyBGMode = false
@ObservedObject var syncMonitor = SyncMonitor.shared
@AppStorage(UserDefaultsStore.Keys.useCloudKit.rawValue) private var useCloudKit = false
var body: some View {
ZStack {
Color(UIColor.secondarySystemBackground)
@@ -27,13 +29,18 @@ struct SettingsView: View {
VStack {
closeButtonView
.padding()
cloudKitEnable
addTestDataCell
clearDB
changeIcon
showOnboardingButton
whyBackgroundMode
specialThanksCell
cloudKitStatus
if useCloudKit {
cloudKitStatus
}
Spacer()
}
.padding()
@@ -192,6 +199,25 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
}
private var cloudKitEnable: some View {
ZStack {
Color(UIColor.systemBackground)
VStack {
Toggle(String(localized: "settings_use_cloudkit_title"),
isOn: $useCloudKit)
.onChange(of: useCloudKit) { value in
print(value)
PersistenceController.shared.switchContainer()
}
.padding()
Text(String(localized: "settings_use_cloudkit_body"))
}
.padding(.bottom)
}
.fixedSize(horizontal: false, vertical: true)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
}
private var cloudKitStatus: some View {
ZStack {
Color(UIColor.systemBackground)