Skip to content

Commit 065f247

Browse files
committed
remove overrideLabel
1 parent 9a27dae commit 065f247

File tree

7 files changed

+14
-70
lines changed

7 files changed

+14
-70
lines changed

src/config/appimoptionview.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ private let presetApps: [String] = [
1010

1111
struct AppIMOptionView: OptionView {
1212
let label: String
13-
let overrideLabel: String? = nil
1413
let openPanel = NSOpenPanel()
1514
@ObservedObject var model: AppIMOption
1615
@State private var appIcon: NSImage? = nil

src/config/cssoptionview.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ private let fcitxPrefix = "fcitx:///file/css/"
66

77
struct CssOptionView: OptionView {
88
let label: String
9-
let overrideLabel: String? = nil
109
@ObservedObject var model: CssOption
1110

1211
var body: some View {

src/config/imageoptionview.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ private let imageDir = wwwDir.appendingPathComponent("img")
99

1010
struct ImageOptionView: OptionView {
1111
let label: String
12-
let overrideLabel: String? = nil
1312
@ObservedObject var model: ImageOption
1413

1514
var body: some View {

src/config/optionviews.swift

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ import SwiftyJSON
55

66
protocol OptionView: View {
77
var label: String { get }
8-
var overrideLabel: String? { get }
98
}
109

1110
struct BooleanOptionView: OptionView {
1211
let label: String
13-
var overrideLabel: String? {
14-
return label
15-
}
1612
@ObservedObject var model: BooleanOption
1713
var body: some View {
1814
Toggle("", isOn: $model.value)
@@ -32,7 +28,6 @@ func recordedKeyView(_ pair: (String, String?)) -> some View {
3228

3329
struct KeyOptionView: OptionView {
3430
let label: String
35-
let overrideLabel: String? = nil
3631
@ObservedObject var model: KeyOption
3732
@State private var showRecorder = false
3833
@State private var recordedShortcut: (String, String?) = ("", nil)
@@ -76,7 +71,6 @@ struct KeyOptionView: OptionView {
7671

7772
struct StringOptionView: OptionView {
7873
let label: String
79-
let overrideLabel: String? = nil
8074
@ObservedObject var model: StringOption
8175
var body: some View {
8276
TextField(label, text: $model.value)
@@ -93,7 +87,6 @@ let numberFormatter: NumberFormatter = {
9387

9488
struct IntegerOptionView: OptionView {
9589
let label: String
96-
let overrideLabel: String? = nil
9790
@ObservedObject var model: IntegerOption
9891
@FocusState private var isFocused: Bool
9992

@@ -140,7 +133,6 @@ struct IntegerOptionView: OptionView {
140133

141134
struct ColorOptionView: OptionView {
142135
let label: String
143-
let overrideLabel: String? = nil
144136
@ObservedObject var model: ColorOption
145137
var body: some View {
146138
HStack {
@@ -195,7 +187,6 @@ class ExternalConfigViewModel: ObservableObject {
195187
struct ExternalOptionView: OptionView {
196188
let label: String
197189
let model: ExternalOption
198-
let overrideLabel: String? = ""
199190

200191
@StateObject private var viewModel = ExternalConfigViewModel()
201192
@State private var showExportCurrentTheme = false
@@ -284,7 +275,6 @@ struct ExternalOptionView: OptionView {
284275

285276
struct EnumOptionView: OptionView {
286277
let label: String
287-
let overrideLabel: String? = nil
288278
@ObservedObject var model: EnumOption
289279
var body: some View {
290280
Picker("", selection: $model.value) {
@@ -297,7 +287,6 @@ struct EnumOptionView: OptionView {
297287

298288
struct ListOptionView<T: Option & EmptyConstructible>: OptionView {
299289
let label: String
300-
let overrideLabel: String? = nil
301290
@ObservedObject var model: ListOption<T>
302291

303292
var body: some View {
@@ -371,7 +360,6 @@ struct ListOptionView<T: Option & EmptyConstructible>: OptionView {
371360

372361
struct FontOptionView: OptionView {
373362
let label: String
374-
let overrideLabel: String? = nil
375363
@ObservedObject var model: FontOption
376364
@State private var selectorIsOpen = false
377365
@State var searchInput = ""
@@ -457,7 +445,6 @@ struct FontOptionView: OptionView {
457445

458446
struct PunctuationMapOptionView: OptionView {
459447
let label: String
460-
let overrideLabel: String? = nil
461448
@ObservedObject var model: PunctuationMapOption
462449

463450
var body: some View {
@@ -486,14 +473,13 @@ struct PunctuationMapOptionView: OptionView {
486473

487474
struct GroupOptionView: OptionView {
488475
let label: String
489-
let overrideLabel: String? = nil
490476
let children: [Config]
491477

492478
var body: some View {
493479
Grid(alignment: .topLeading) {
494480
ForEach(children) { child in
495481
let subView = buildViewImpl(config: child)
496-
let subLabel = Text(subView.overrideLabel ?? subView.label)
482+
let subLabel = Text(subView.label)
497483
if subView is GroupOptionView {
498484
// If this is a nested group, put it inside a box, and let
499485
// it span two columns.
@@ -519,16 +505,20 @@ struct GroupOptionView: OptionView {
519505
// Otherwise, put the label in the left column and the
520506
// content in the right column.
521507
GridRow {
522-
subLabel
523-
.frame(minWidth: 100, maxWidth: 250, alignment: .trailing)
524-
.help(NSLocalizedString("Right click to reset this item", comment: ""))
525-
.contextMenu {
526-
Button {
527-
child.resetToDefault()
528-
} label: {
529-
Text("Reset to default")
508+
if subView is ExternalOptionView {
509+
HStack {} // Label is baked in button.
510+
} else {
511+
subLabel
512+
.frame(minWidth: 100, maxWidth: 250, alignment: .trailing)
513+
.help(NSLocalizedString("Right click to reset this item", comment: ""))
514+
.contextMenu {
515+
Button {
516+
child.resetToDefault()
517+
} label: {
518+
Text("Reset to default")
519+
}
530520
}
531-
}
521+
}
532522
AnyView(subView)
533523
}
534524
}
@@ -539,7 +529,6 @@ struct GroupOptionView: OptionView {
539529

540530
struct UnsupportedOptionView: OptionView {
541531
let label = ""
542-
let overrideLabel: String? = nil
543532
let model: any Option
544533

545534
var body: some View {
@@ -611,42 +600,3 @@ func buildViewImpl(config: Config) -> any OptionView {
611600
func buildView(config: Config) -> AnyView {
612601
AnyView(buildViewImpl(config: config))
613602
}
614-
615-
let testConfig = Config(
616-
path: "Fuzzy",
617-
description: "Fuzzy",
618-
kind: .group([
619-
Config(
620-
path: "AN_ANG", description: "Fuzzy an ang",
621-
kind: .option(BooleanOption(defaultValue: false, value: true))),
622-
Config(
623-
path: "foo", description: "FOOOO!",
624-
kind: .option(StringOption(defaultValue: "", value: "semicolon"))),
625-
Config(
626-
path: "external", description: "External test",
627-
kind: .option(ExternalOption(option: "Punctuation", external: "fcitx://addon/punctuation"))),
628-
Config(
629-
path: "Shuangpin Profile", description: "双拼方案",
630-
kind: .option(
631-
EnumOption(
632-
defaultValue: "Ziranma", value: "MS", enumStrings: ["Ziranma", "MS"],
633-
enumStringsI18n: ["自然码", "微软"]))),
634-
Config(
635-
path: "interval", description: "int test",
636-
kind: .option(IntegerOption(defaultValue: 0, value: 10, min: 0, max: 1000))),
637-
// Config(
638-
// path: "list", description: "List test",
639-
// kind: .option(
640-
// ListOption(
641-
// defaultValue: ["a", "b", "c"], value: ["c", "d"], elementType: "String"))
642-
// ),
643-
]))
644-
645-
#Preview {
646-
VStack {
647-
buildView(config: testConfig)
648-
Button("Print") {
649-
print(testConfig.encodeValue())
650-
}
651-
}
652-
}

src/config/pluginoptionview.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import SwiftUI
33

44
struct PluginOptionView: OptionView {
55
let label: String
6-
let overrideLabel: String? = nil
76
@ObservedObject var model: PluginOption
87
@State private var availablePlugins = [String]()
98

src/config/userthemeoptionview.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ private let themeDir = localDir.appendingPathComponent("theme")
55

66
struct UserThemeOptionView: OptionView {
77
let label: String
8-
let overrideLabel: String? = nil
98
@ObservedObject var model: UserThemeOption
109

1110
var body: some View {

src/config/vimmodeoptionview.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import SwiftUI
22

33
struct VimModeOptionView: OptionView {
44
let label: String
5-
let overrideLabel: String? = nil
65
let openPanel = NSOpenPanel()
76
@ObservedObject var model: VimModeOption
87

0 commit comments

Comments
 (0)