Skip to content

Commit

Permalink
refractor: migrate from AppStorage to Defaults in Privacy and About tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry23011 committed Jan 24, 2024
1 parent 27c8ece commit c63f22d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions Easydict/NewApp/Configuration/Configuration+Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extension Defaults.Keys {

static let appearanceType = Key<AppearenceType>("EZConfiguration_kApperanceKey", default: .followSystem)
static let fontSizeOptionIndex = Key<UInt>("EZConfiguration_kTranslationControllerFontKey", default: 0)
static let autoCheckForUpdates = Key<Bool>("EZConfiguration_kAutomaticallyChecksForUpdatesKey", default: false)
}

extension Defaults.Keys {
Expand Down
4 changes: 2 additions & 2 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 Down Expand Up @@ -45,8 +46,7 @@ struct AboutTab: View {
}
}

@AppStorage("EZConfiguration_kAutomaticallyChecksForUpdatesKey")
private var autoChecksForUpdates = false
@Default(.autoCheckForUpdates) private var autoChecksForUpdates
@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

0 comments on commit c63f22d

Please sign in to comment.