Skip to content

Commit

Permalink
Merge branch 'dev' into service_api_key_config
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng authored Feb 1, 2024
2 parents ad4b861 + 8a3715d commit 4fd55ee
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"images" : [
{
"filename" : "release_18.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "release_36.png",
"filename" : "rounded.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "release_54.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"localizable" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"images" : [
{
"filename" : "debug_20 1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "debug_40 1.png",
"filename" : "square.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "debug_60 1.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 18 additions & 1 deletion Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,23 @@
}
}
},
"modify_menubar_icon" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Menu bar icon"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "菜单栏图标"
}
}
}
},
"mouse_select_translate_window_type" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -3877,4 +3894,4 @@
}
},
"version" : "1.0"
}
}
4 changes: 2 additions & 2 deletions Easydict/Feature/StatusItem/EZMenuItemManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ - (void)setup {
NSStatusBarButton *button = statusItem.button;

#if DEBUG
NSImage *image = [NSImage imageNamed:@"status_icon_debug"];
NSImage *image = [NSImage imageNamed:@"rounded_menu_bar_icon"];
#else
NSImage *image = [NSImage imageNamed:@"status_icon"];
NSImage *image = [NSImage imageNamed:@"square_menu_bar_icon"];
#endif

[button setImage:image];
Expand Down
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 selectedMenuBarIcon = Key<MenuBarIconType>("EZConfiguration_kSelectedMenuBarIconKey", default: .square)
}

extension Defaults.Keys {
Expand Down
22 changes: 14 additions & 8 deletions Easydict/NewApp/EasydictApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ struct EasydictApp: App {
@AppStorage(Defaults.Key<Bool>.hideMenuBarIcon.name)
private var hideMenuBar = Defaults.Key<Bool>.hideMenuBarIcon.defaultValue

private var menuBarImage: String {
#if DEBUG
"status_icon_debug"
#else
"status_icon"
#endif
}
@Default(.selectedMenuBarIcon)
private var menuBarIcon

var body: some Scene {
if #available(macOS 13, *) {
Expand All @@ -47,9 +42,13 @@ struct EasydictApp: App {
Label {
Text("Easydict")
} icon: {
Image(menuBarImage)
Image(menuBarIcon.rawValue)
.resizable()
#if DEBUG
.renderingMode(.original)
#else
.renderingMode(.template)
#endif
.scaledToFit()
}
.help("Easydict 🍃")
Expand All @@ -67,3 +66,10 @@ extension Bool {
mutating set { self = newValue.toggledValue }
}
}

enum MenuBarIconType: String, CaseIterable, Defaults.Serializable, Identifiable {
var id: Self { self }

case square = "square_menu_bar_icon"
case rounded = "rounded_menu_bar_icon"
}
13 changes: 13 additions & 0 deletions Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import SwiftUI

@available(macOS 13, *)
struct GeneralTab: View {
@Environment(\.colorScheme) var colorScheme

var body: some View {
Form {
Section {
Expand Down Expand Up @@ -136,6 +138,16 @@ struct GeneralTab: View {
Toggle(isOn: $hideMenuBarIcon) {
Text("hide_menu_bar_icon")
}
Picker(
"modify_menubar_icon",
selection: $selectedMenuBarIcon
) {
ForEach(MenuBarIconType.allCases) { option in
Image(option.rawValue)
.renderingMode(.template)
.foregroundStyle(.primary)
}
}
} header: {
Text("setting.general.other.header")
}
Expand Down Expand Up @@ -180,6 +192,7 @@ struct GeneralTab: View {
@Default(.appearanceType) private var appearanceType

@Default(.fontSizeOptionIndex) private var fontSizeOptionIndex
@Default(.selectedMenuBarIcon) private var selectedMenuBarIcon
}

@available(macOS 13, *)
Expand Down

0 comments on commit 4fd55ee

Please sign in to comment.