Skip to content

Commit

Permalink
refractor: use binding to set autoChecksForUpdates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry23011 committed Jan 24, 2024
1 parent c63f22d commit 351c87d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion Easydict/NewApp/Configuration/Configuration+Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ 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
10 changes: 8 additions & 2 deletions Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,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 @@ -46,7 +46,13 @@ struct AboutTab: View {
}
}

@Default(.autoCheckForUpdates) private var autoChecksForUpdates
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

0 comments on commit 351c87d

Please sign in to comment.