Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Defaults for Privacy & About tabs #360

Merged
merged 7 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 izual. All rights reserved.
//

import Defaults
import SwiftUI

@available(macOS 13, *)
Expand All @@ -20,7 +21,7 @@ struct AboutTab: View {
.font(.system(size: 26, weight: .semibold))
Text("current_version") + Text(verbatim: " \(version)")
.font(.system(size: 14))
Toggle("auto_check_update", isOn: $autoChecksForUpdates)
Toggle("auto_check_update", isOn: autoChecksForUpdates)
Text(verbatim: "(") + Text("lastest_version") + Text(verbatim: " \(lastestVersion ?? version))")

HStack {
Expand All @@ -45,8 +46,13 @@ struct AboutTab: View {
}
}

@AppStorage("EZConfiguration_kAutomaticallyChecksForUpdatesKey")
private var autoChecksForUpdates = false
private var autoChecksForUpdates: Binding<Bool> {
.init(
get: { Configuration.shared.automaticallyChecksForUpdates },
set: { newValue in Configuration.shared.automaticallyChecksForUpdates = newValue }
)
}

@State
private var lastestVersion: String?
private var appName: String {
Expand Down
7 changes: 3 additions & 4 deletions Easydict/NewApp/View/SettingView/Tabs/PrivacyTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 izual. All rights reserved.
//

import Defaults
import SwiftUI

@available(macOS 13, *)
Expand Down Expand Up @@ -33,11 +34,9 @@ struct PrivacyTab: View {
.formStyle(.grouped)
}

@AppStorage("EZConfiguration_kAllowCrashLogKey")
private var allowCollectCrashLog = true
@Default(.allowCrashLog) private var allowCollectCrashLog

@AppStorage("EZConfiguration_kAllowAnalyticsKey")
private var allowCollectAnalytics = true
@Default(.allowAnalytics) private var allowCollectAnalytics
}

@available(macOS 13, *)
Expand Down