Skip to content

Commit

Permalink
Add GeneralTab so that user can switch back to old mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Dec 28, 2023
1 parent 0d74694 commit 0b45d00
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
276742092B3DC230002A2C75 /* AboutTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 276742052B3DC230002A2C75 /* AboutTab.swift */; };
278322602B0FB0EA0026644C /* CaiyunResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2783225F2B0FB0EA0026644C /* CaiyunResponse.swift */; };
278322622B0FB8EF0026644C /* CaiyunTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278322612B0FB8EF0026644C /* CaiyunTranslateType.swift */; };
278540342B3DE04F004E9488 /* GeneralTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278540332B3DE04F004E9488 /* GeneralTab.swift */; };
27FE95272B3DC55F000AD654 /* EasydictApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FE95262B3DC55F000AD654 /* EasydictApp.swift */; };
27FE98052B3DCB09000AD654 /* NewAppManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FE98042B3DCB09000AD654 /* NewAppManager.swift */; };
27FE98092B3DD536000AD654 /* SettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FE98082B3DD536000AD654 /* SettingView.swift */; };
Expand Down Expand Up @@ -678,6 +679,7 @@
276742052B3DC230002A2C75 /* AboutTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutTab.swift; sourceTree = "<group>"; };
2783225F2B0FB0EA0026644C /* CaiyunResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaiyunResponse.swift; sourceTree = "<group>"; };
278322612B0FB8EF0026644C /* CaiyunTranslateType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaiyunTranslateType.swift; sourceTree = "<group>"; };
278540332B3DE04F004E9488 /* GeneralTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralTab.swift; sourceTree = "<group>"; };
27B7919C2AEC36A1006E07C6 /* Easydict.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Easydict.xcconfig; sourceTree = "<group>"; };
27B7919D2AEC36A1006E07C6 /* Easydict-debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Easydict-debug.xcconfig"; sourceTree = "<group>"; };
27B791A02AEC3A5C006E07C6 /* Easydict-debug.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "Easydict-debug.entitlements"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1987,6 +1989,7 @@
27FE980C2B3DD749000AD654 /* Tabs */ = {
isa = PBXGroup;
children = (
278540332B3DE04F004E9488 /* GeneralTab.swift */,
276742042B3DC230002A2C75 /* PrivacyTab.swift */,
276742052B3DC230002A2C75 /* AboutTab.swift */,
);
Expand Down Expand Up @@ -2503,6 +2506,7 @@
03CF88632B137F650030C199 /* Array+Convenience.swift in Sources */,
03B0231229231FA6001C7E63 /* NSObject+DarkMode.m in Sources */,
03B0233829231FA6001C7E63 /* MMOrderedDictionary.m in Sources */,
278540342B3DE04F004E9488 /* GeneralTab.swift in Sources */,
03BDA7BC2A26DA280079D04F /* XPMArgumentSignature.m in Sources */,
03B0230229231FA6001C7E63 /* EZWordResultView.m in Sources */,
0399C6A529A747E600B4AFCC /* EZDeepLTranslateResponse.m in Sources */,
Expand Down
10 changes: 10 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,16 @@
}
}
},
"other" : {
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "其他"
}
}
}
},
"Parameter Error" : {
"comment" : "Error description",
"localizations" : {
Expand Down
4 changes: 3 additions & 1 deletion Easydict/Feature/Configuration/EZConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

NS_ASSUME_NONNULL_BEGIN

FOUNDATION_EXPORT NSString *const kHideMainWindowKey;
FOUNDATION_EXPORT NSString *const kLaunchAtStartupKey;
FOUNDATION_EXPORT NSString *const kHideMenuBarIconKey;
FOUNDATION_EXPORT NSString *const kEnableBetaNewApp;
FOUNDATION_EXPORT NSString *const kEnableBetaNewAppKey;

static NSString *const EZQuickLinkButtonUpdateNotification = @"EZQuickLinkButtonUpdateNotification";

Expand Down
10 changes: 5 additions & 5 deletions Easydict/Feature/Configuration/EZConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
static NSString *const kForceAutoGetSelectedText = @"EZConfiguration_kForceAutoGetSelectedText";
static NSString *const kDisableEmptyCopyBeepKey = @"EZConfiguration_kDisableEmptyCopyBeepKey";
static NSString *const kClickQueryKey = @"EZConfiguration_kClickQueryKey";
static NSString *const kLaunchAtStartupKey = @"EZConfiguration_kLaunchAtStartupKey";
static NSString *const kHideMainWindowKey = @"EZConfiguration_kHideMainWindowKey";
static NSString *const kAutoQueryOCTTextKey = @"EZConfiguration_kAutoQueryOCTTextKey";
static NSString *const kAutoQuerySelectedTextKey = @"EZConfiguration_kAutoQuerySelectedTextKey";
static NSString *const kAutoQueryPastedTextKey = @"EZConfiguration_kAutoQueryPastedTextKey";
Expand All @@ -45,8 +43,6 @@
static NSString *const kShowGoogleLinkKey = @"EZConfiguration_kShowGoogleLinkKey";
static NSString *const kShowEudicLinkKey = @"EZConfiguration_kShowEudicLinkKey";
static NSString *const kShowAppleDictionaryLinkKey = @"EZConfiguration_kShowAppleDictionaryLinkKey";
NSString *const kHideMenuBarIconKey = @"EZConfiguration_kHideMenuBarIconKey";
NSString *const kEnableBetaNewApp = @"EZConfiguration_kEnableBetaNewApp";
static NSString *const kShowFixedWindowPositionKey = @"EZConfiguration_kShowFixedWindowPositionKey";
static NSString *const kShortcutSelectTranslateWindowTypeKey = @"EZConfiguration_kShortcutSelectTranslateWindowTypeKey";
static NSString *const kMouseSelectTranslateWindowTypeKey = @"EZConfiguration_kMouseSelectTranslateWindowTypeKey";
Expand All @@ -57,6 +53,10 @@
static NSString *const kClearInputKey = @"EZConfiguration_kClearInputKey";
static NSString *const kTranslationControllerFontKey = @"EZConfiguration_kTranslationControllerFontKey";

NSString *const kHideMainWindowKey = @"EZConfiguration_kHideMainWindowKey";
NSString *const kLaunchAtStartupKey = @"EZConfiguration_kLaunchAtStartupKey";
NSString *const kHideMenuBarIconKey = @"EZConfiguration_kHideMenuBarIconKey";
NSString *const kEnableBetaNewAppKey = @"EZConfiguration_kEnableBetaNewAppKey";

@interface EZConfiguration ()

Expand Down Expand Up @@ -367,7 +367,7 @@ - (void)setHideMenuBarIcon:(BOOL)hideMenuBarIcon {

- (void)setEnableBetaNewApp:(BOOL)enableBetaNewApp {
_enableBetaNewApp = enableBetaNewApp;
[NSUserDefaults mm_write:@(enableBetaNewApp) forKey:kEnableBetaNewApp];
[NSUserDefaults mm_write:@(enableBetaNewApp) forKey:kEnableBetaNewAppKey];
[self logSettings:@{@"enable_beta_new_app" : @(enableBetaNewApp)}];
}

Expand Down
2 changes: 1 addition & 1 deletion Easydict/NewApp/NewAppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public final class NewAppManager: NSObject {

override private init() { super.init() }

private static var enableKey: String { kEnableBetaNewApp }
private static var enableKey: String { kEnableBetaNewAppKey }

/// 新的 MenuBarExtra 对齐 EZStatusItem & 可以放弃 macOS 13- 支持后全量
@objc
Expand Down
3 changes: 3 additions & 0 deletions Easydict/NewApp/View/SettingView/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import SwiftUI
struct SettingView: View {
var body: some View {
TabView {
GeneralTab()
.tabItem { Label("setting_general", systemImage: "gear") }
.frame(width: 500, height: 400)
PrivacyTab()
.tabItem { Label("privacy", systemImage: "hand.raised.square") }
.frame(width: 500, height: 400)
Expand Down
56 changes: 56 additions & 0 deletions Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// GeneralTab.swift
// Easydict
//
// Created by Kyle on 2023/12/29.
// Copyright © 2023 izual. All rights reserved.
//

import SwiftUI

@available(macOS 13, *)
struct GeneralTab: View {
var body: some View {
Form {
Section {
HStack {
Text("show_main_window")
Toggle(isOn: $hideMainWindow) {
Text("hide_main_window")
}
}
HStack {
Text("launch")
Toggle(isOn: $launchAtStartup) {
Text("launch_at_startup")
}
}
HStack {
Text("menu_bar_icon")
Toggle(isOn: $hideMenuBarIcon) {
Text("hide_menu_bar_icon")
}
}
HStack {
Text("beta_new_app")
Toggle(isOn: $enableBetaNewApp) {
Text("enable_beta_new_app")
}
}
} header: {
Text("other")
}
}
.formStyle(.grouped)
}

@AppStorage(kHideMainWindowKey) private var hideMainWindow = false
@AppStorage(kLaunchAtStartupKey) private var launchAtStartup = false
@AppStorage(kHideMenuBarIconKey) private var hideMenuBarIcon = false
@AppStorage(kEnableBetaNewAppKey) private var enableBetaNewApp = false
}

@available(macOS 13, *)
#Preview {
GeneralTab()
}

0 comments on commit 0b45d00

Please sign in to comment.