Skip to content

Commit

Permalink
Font Size and Appearance setting
Browse files Browse the repository at this point in the history
  • Loading branch information
CanglongCl committed Jan 14, 2024
1 parent 84c154a commit d0f16fe
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 2 deletions.
66 changes: 65 additions & 1 deletion Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,7 @@
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"state" : "translated",
"value" : "启用 Beta 特性"
}
}
Expand All @@ -2224,6 +2224,38 @@
}
}
},
"setting.general.appearance.header" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Appearance"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "外观"
}
}
}
},
"setting.general.appearance.light_dark_appearance" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Appearance"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "外观"
}
}
}
},
"setting.general.auto_copy.header" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -2256,6 +2288,38 @@
}
}
},
"setting.general.font.font_size.label" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Font Size"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "字体大小"
}
}
}
},
"setting.general.font.header" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Font"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "字体"
}
}
}
},
"setting.general.input.header" : {
"localizations" : {
"en" : {
Expand Down
3 changes: 2 additions & 1 deletion Easydict/Feature/Configuration/Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
// Copyright © 2023 izual. All rights reserved.
//

import Defaults
import Foundation

@objc enum AppearenceType: Int, CaseIterable {
@objc enum AppearenceType: Int, CaseIterable, Defaults.Serializable {
case followSystem = 0
case light
case dark
Expand Down
3 changes: 3 additions & 0 deletions Easydict/NewApp/Configuration/EZConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ extension Defaults.Keys {
static let enableBetaNewApp = Key<Bool>("EZConfiguration_kEnableBetaNewAppKey", default: false)

static let enableBetaFeature = Key<Bool>("EZBetaFeatureKey", default: false)

static let appearanceType = Key<AppearenceType>("EZConfiguration_kApperanceKey", default: .followSystem)
static let fontSizeOptionIndex = Key<UInt>("EZConfiguration_kTranslationControllerFontKey", default: 0)
}
35 changes: 35 additions & 0 deletions Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ import SwiftUI
struct GeneralTab: View {
var body: some View {
Form {
Section {
Picker("setting.general.appearance.light_dark_appearance", selection: $appearanceType) {
ForEach(AppearenceType.allCases, id: \.rawValue) { option in
Text(option.title)
.tag(option)
}
}
} header: {
Text("setting.general.appearance.header")
}
Section {
FirstAndSecondLanguageSettingView()
Picker("setting.general.language.language_detect_optimize", selection: $languageDetectOptimize) {
Expand Down Expand Up @@ -94,6 +104,28 @@ struct GeneralTab: View {
Text("setting.general.quick_link.header")
}

Section {
let bindingFontSize = Binding<Double>(get: {
Double(fontSizeOptionIndex)
}, set: { newValue in
fontSizeOptionIndex = UInt(newValue)
})
Slider(value: bindingFontSize, in: 0.0 ... 4.0, step: 1) {
Text("setting.general.font.font_size.label")
} minimumValueLabel: {
Text("small")
.font(.system(size: 10))
} maximumValueLabel: {
Text("large")
.font(.system(size: 14))
}
} header: {
Text("setting.general.font.header")
} footer: {
Text("hints_keyboard_shortcuts_font_size")
.font(.footnote)
}

Section {
Toggle(isOn: $launchAtStartup) {
Text("launch_at_startup")
Expand Down Expand Up @@ -160,6 +192,9 @@ struct GeneralTab: View {
@Default(.mouseSelectTranslateWindowType) private var mouseSelectTranslateWindowType
@Default(.shortcutSelectTranslateWindowType) private var shortcutSelectTranslateWindowType
@Default(.enableBetaFeature) private var enableBetaFeature
@Default(.appearanceType) private var appearanceType

@Default(.fontSizeOptionIndex) private var fontSizeOptionIndex
}

@available(macOS 13, *)
Expand Down

0 comments on commit d0f16fe

Please sign in to comment.