From 6c837d417a9dface038948aaa29686ddb1577038 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Tue, 23 Jan 2024 16:39:31 +0800 Subject: [PATCH] perf: add new advanced tab --- Easydict.xcodeproj/project.pbxproj | 4 ++ Easydict/App/Localizable.xcstrings | 19 ++++++++- .../NewApp/View/SettingView/SettingView.swift | 6 +++ .../View/SettingView/Tabs/AdvancedTab.swift | 42 +++++++++++++++++++ .../View/SettingView/Tabs/GeneralTab.swift | 15 ------- 5 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 43ca6f7b7..0feacd3fa 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -70,6 +70,7 @@ 037E006D2B3DC098006491C6 /* EZOpenAIService+EZPromptMessages.m in Sources */ = {isa = PBXBuildFile; fileRef = 03CF27FA2B3A787900E19B57 /* EZOpenAIService+EZPromptMessages.m */; }; 038030952B4106800009230C /* CocoaLumberjack in Frameworks */ = {isa = PBXBuildFile; productRef = 038030942B4106800009230C /* CocoaLumberjack */; }; 038030972B4106800009230C /* CocoaLumberjackSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 038030962B4106800009230C /* CocoaLumberjackSwift */; }; + 03832F542B5F6BE200D0DC64 /* AdvancedTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03832F532B5F6BE200D0DC64 /* AdvancedTab.swift */; }; 0383914C292FBE120009828C /* Main.strings in Resources */ = {isa = PBXBuildFile; fileRef = 03839140292FBE120009828C /* Main.strings */; }; 0383914D292FBE120009828C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 03839143292FBE120009828C /* Assets.xcassets */; }; 0383914E292FBE120009828C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 03839144292FBE120009828C /* ViewController.m */; }; @@ -421,6 +422,7 @@ 037852B529588EDE00D0E2CF /* EZCustomTableRowView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZCustomTableRowView.m; sourceTree = ""; }; 037852B7295D49F900D0E2CF /* EZTableRowView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZTableRowView.h; sourceTree = ""; }; 037852B8295D49F900D0E2CF /* EZTableRowView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZTableRowView.m; sourceTree = ""; }; + 03832F532B5F6BE200D0DC64 /* AdvancedTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedTab.swift; sourceTree = ""; }; 03839141292FBE120009828C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 03839142292FBE120009828C /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 03839143292FBE120009828C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -2099,6 +2101,7 @@ 0A8685C72B552A590022534F /* DisabledAppTab.swift */, 276742042B3DC230002A2C75 /* PrivacyTab.swift */, 276742052B3DC230002A2C75 /* AboutTab.swift */, + 03832F532B5F6BE200D0DC64 /* AdvancedTab.swift */, ); path = Tabs; sourceTree = ""; @@ -2831,6 +2834,7 @@ DC46DF802B4417B900DEAE3E /* Configuration.swift in Sources */, 036E7D7B293F4FC8002675DF /* EZOpenLinkButton.m in Sources */, EAED41EC2B54AA920005FE0A /* ServiceConfigurationSection.swift in Sources */, + 03832F542B5F6BE200D0DC64 /* AdvancedTab.swift in Sources */, 276742092B3DC230002A2C75 /* AboutTab.swift in Sources */, 03008B2E2941956D0062B821 /* EZURLSchemeHandler.m in Sources */, DC6D9C872B352EBC0055EFFC /* FontSizeHintView.swift in Sources */, diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index aacf0329e..d96c42854 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -2,7 +2,14 @@ "sourceLanguage" : "en", "strings" : { "" : { - + "localizations" : { + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "" + } + } + } }, "about" : { "comment" : "about", @@ -37,6 +44,16 @@ } } }, + "advanced" : { + "localizations" : { + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "高级" + } + } + } + }, "ali_translate" : { "extractionState" : "manual", "localizations" : { diff --git a/Easydict/NewApp/View/SettingView/SettingView.swift b/Easydict/NewApp/View/SettingView/SettingView.swift index f64f70efc..ec5c395ab 100644 --- a/Easydict/NewApp/View/SettingView/SettingView.swift +++ b/Easydict/NewApp/View/SettingView/SettingView.swift @@ -12,6 +12,7 @@ enum SettingTab: Int { case general case service case disabled + case advanced case privacy case about } @@ -34,6 +35,9 @@ struct SettingView: View { DisabledAppTab() .tabItem { Label("disabled_app_list", systemImage: "nosign") } .tag(SettingTab.disabled) + AdvancedTab() + .tabItem { Label("advanced", systemImage: "wrench.and.screwdriver") } + .tag(SettingTab.advanced) PrivacyTab() .tabItem { Label("privacy", systemImage: "hand.raised.square") } @@ -71,6 +75,8 @@ struct SettingView: View { 320 case .about: 450 + default: + 400 } let newSize = CGSize(width: maxWidth, height: height) diff --git a/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift b/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift new file mode 100644 index 000000000..55b9da5c3 --- /dev/null +++ b/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift @@ -0,0 +1,42 @@ +// +// AdvancedTab.swift +// Easydict +// +// Created by tisfeng on 2024/1/23. +// Copyright © 2024 izual. All rights reserved. +// + +import Defaults +import SwiftUI + +@available(macOS 13, *) +struct AdvancedTab: View { + var body: some View { + Form { + Section { + Picker("setting.general.advance.default_tts_service", selection: $defaultTTSServiceType) { + ForEach(TTSServiceType.allCases, id: \.rawValue) { option in + Text(option.localizedStringResource) + .tag(option) + } + } + Toggle("setting.general.advance.enable_beta_feature", isOn: $enableBetaFeature) + Toggle(isOn: $enableBetaNewApp) { + Text("enable_beta_new_app") + } + } header: { + Text("setting.general.advance.header") + } + } + .formStyle(.grouped) + } + + @Default(.defaultTTSServiceType) private var defaultTTSServiceType + @Default(.enableBetaFeature) private var enableBetaFeature + @Default(.enableBetaNewApp) private var enableBetaNewApp +} + +@available(macOS 13, *) +#Preview { + AdvancedTab() +} diff --git a/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift b/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift index 84668e464..6471771c1 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift @@ -139,21 +139,6 @@ struct GeneralTab: View { } header: { Text("other") } - - Section { - Picker("setting.general.advance.default_tts_service", selection: $defaultTTSServiceType) { - ForEach(TTSServiceType.allCases, id: \.rawValue) { option in - Text(option.localizedStringResource) - .tag(option) - } - } - Toggle("setting.general.advance.enable_beta_feature", isOn: $enableBetaFeature) - Toggle(isOn: $enableBetaNewApp) { - Text("enable_beta_new_app") - } - } header: { - Text("setting.general.advance.header") - } } .formStyle(.grouped) }