|
1 | 1 | import Preferences |
| 2 | +import SharedUIComponents |
2 | 3 | import SwiftUI |
3 | 4 |
|
4 | 5 | #if canImport(ProHostApp) |
@@ -36,112 +37,109 @@ struct SuggestionSettingsView: View { |
36 | 37 |
|
37 | 38 | var body: some View { |
38 | 39 | Form { |
39 | | - Group { |
40 | | - Picker(selection: $settings.suggestionPresentationMode) { |
41 | | - ForEach(PresentationMode.allCases, id: \.rawValue) { |
42 | | - switch $0 { |
43 | | - case .nearbyTextCursor: |
44 | | - Text("Nearby Text Cursor").tag($0) |
45 | | - case .floatingWidget: |
46 | | - Text("Floating Widget").tag($0) |
47 | | - } |
| 40 | + Picker(selection: $settings.suggestionPresentationMode) { |
| 41 | + ForEach(PresentationMode.allCases, id: \.rawValue) { |
| 42 | + switch $0 { |
| 43 | + case .nearbyTextCursor: |
| 44 | + Text("Nearby Text Cursor").tag($0) |
| 45 | + case .floatingWidget: |
| 46 | + Text("Floating Widget").tag($0) |
48 | 47 | } |
49 | | - } label: { |
50 | | - Text("Presentation") |
51 | 48 | } |
| 49 | + } label: { |
| 50 | + Text("Presentation") |
| 51 | + } |
52 | 52 |
|
53 | | - Picker(selection: $settings.suggestionFeatureProvider) { |
54 | | - ForEach(SuggestionFeatureProvider.allCases, id: \.rawValue) { |
55 | | - switch $0 { |
56 | | - case .gitHubCopilot: |
57 | | - Text("GitHub Copilot").tag($0) |
58 | | - case .codeium: |
59 | | - Text("Codeium").tag($0) |
60 | | - } |
| 53 | + Picker(selection: $settings.suggestionFeatureProvider) { |
| 54 | + ForEach(SuggestionFeatureProvider.allCases, id: \.rawValue) { |
| 55 | + switch $0 { |
| 56 | + case .gitHubCopilot: |
| 57 | + Text("GitHub Copilot").tag($0) |
| 58 | + case .codeium: |
| 59 | + Text("Codeium").tag($0) |
61 | 60 | } |
62 | | - } label: { |
63 | | - Text("Feature Provider") |
64 | 61 | } |
| 62 | + } label: { |
| 63 | + Text("Feature Provider") |
| 64 | + } |
65 | 65 |
|
66 | | - Toggle(isOn: $settings.realtimeSuggestionToggle) { |
67 | | - Text("Real-time Suggestion") |
68 | | - } |
| 66 | + Toggle(isOn: $settings.realtimeSuggestionToggle) { |
| 67 | + Text("Real-time Suggestion") |
| 68 | + } |
69 | 69 |
|
70 | | - #if canImport(ProHostApp) |
71 | | - WithFeatureEnabled(\.tabToAcceptSuggestion) { |
72 | | - Toggle(isOn: $settings.acceptSuggestionWithTab) { |
73 | | - Text("Accept Suggestion with Tab") |
74 | | - } |
| 70 | + #if canImport(ProHostApp) |
| 71 | + WithFeatureEnabled(\.tabToAcceptSuggestion) { |
| 72 | + Toggle(isOn: $settings.acceptSuggestionWithTab) { |
| 73 | + Text("Accept Suggestion with Tab") |
75 | 74 | } |
76 | | - #endif |
77 | | - |
78 | | - HStack { |
79 | | - Toggle(isOn: $settings.disableSuggestionFeatureGlobally) { |
80 | | - Text("Disable Suggestion Feature Globally") |
81 | | - } |
| 75 | + } |
| 76 | + #endif |
82 | 77 |
|
83 | | - Button("Exception List") { |
84 | | - isSuggestionFeatureEnabledListPickerOpen = true |
85 | | - } |
86 | | - }.sheet(isPresented: $isSuggestionFeatureEnabledListPickerOpen) { |
87 | | - SuggestionFeatureEnabledProjectListView( |
88 | | - isOpen: $isSuggestionFeatureEnabledListPickerOpen |
89 | | - ) |
| 78 | + HStack { |
| 79 | + Toggle(isOn: $settings.disableSuggestionFeatureGlobally) { |
| 80 | + Text("Disable Suggestion Feature Globally") |
90 | 81 | } |
91 | 82 |
|
92 | | - HStack { |
93 | | - Button("Disabled Language List") { |
94 | | - isSuggestionFeatureDisabledLanguageListViewOpen = true |
95 | | - } |
96 | | - }.sheet(isPresented: $isSuggestionFeatureDisabledLanguageListViewOpen) { |
97 | | - SuggestionFeatureDisabledLanguageListView( |
98 | | - isOpen: $isSuggestionFeatureDisabledLanguageListViewOpen |
99 | | - ) |
| 83 | + Button("Exception List") { |
| 84 | + isSuggestionFeatureEnabledListPickerOpen = true |
100 | 85 | } |
| 86 | + }.sheet(isPresented: $isSuggestionFeatureEnabledListPickerOpen) { |
| 87 | + SuggestionFeatureEnabledProjectListView( |
| 88 | + isOpen: $isSuggestionFeatureEnabledListPickerOpen |
| 89 | + ) |
| 90 | + } |
101 | 91 |
|
102 | | - HStack { |
103 | | - Slider(value: $settings.realtimeSuggestionDebounce, in: 0...2, step: 0.1) { |
104 | | - Text("Real-time Suggestion Debounce") |
105 | | - } |
| 92 | + HStack { |
| 93 | + Button("Disabled Language List") { |
| 94 | + isSuggestionFeatureDisabledLanguageListViewOpen = true |
| 95 | + } |
| 96 | + }.sheet(isPresented: $isSuggestionFeatureDisabledLanguageListViewOpen) { |
| 97 | + SuggestionFeatureDisabledLanguageListView( |
| 98 | + isOpen: $isSuggestionFeatureDisabledLanguageListViewOpen |
| 99 | + ) |
| 100 | + } |
106 | 101 |
|
107 | | - Text( |
108 | | - "\(settings.realtimeSuggestionDebounce.formatted(.number.precision(.fractionLength(2))))s" |
109 | | - ) |
110 | | - .font(.body) |
111 | | - .monospacedDigit() |
112 | | - .padding(.vertical, 2) |
113 | | - .padding(.horizontal, 6) |
114 | | - .background( |
115 | | - RoundedRectangle(cornerRadius: 4, style: .continuous) |
116 | | - .fill(Color.primary.opacity(0.1)) |
117 | | - ) |
| 102 | + HStack { |
| 103 | + Slider(value: $settings.realtimeSuggestionDebounce, in: 0...2, step: 0.1) { |
| 104 | + Text("Real-time Suggestion Debounce") |
118 | 105 | } |
119 | 106 |
|
120 | | - Divider() |
| 107 | + Text( |
| 108 | + "\(settings.realtimeSuggestionDebounce.formatted(.number.precision(.fractionLength(2))))s" |
| 109 | + ) |
| 110 | + .font(.body) |
| 111 | + .monospacedDigit() |
| 112 | + .padding(.vertical, 2) |
| 113 | + .padding(.horizontal, 6) |
| 114 | + .background( |
| 115 | + RoundedRectangle(cornerRadius: 4, style: .continuous) |
| 116 | + .fill(Color.primary.opacity(0.1)) |
| 117 | + ) |
121 | 118 | } |
| 119 | + } |
122 | 120 |
|
123 | | - Group { |
124 | | - Toggle(isOn: $settings.suggestionDisplayCompactMode) { |
125 | | - Text("Hide Buttons") |
126 | | - } |
| 121 | + SettingsDivider("UI") |
127 | 122 |
|
128 | | - Toggle(isOn: $settings.hideCommonPrecedingSpacesInSuggestion) { |
129 | | - Text("Hide Common Preceding Spaces") |
130 | | - } |
| 123 | + Form { |
| 124 | + Toggle(isOn: $settings.suggestionDisplayCompactMode) { |
| 125 | + Text("Hide Buttons") |
| 126 | + } |
131 | 127 |
|
132 | | - HStack { |
133 | | - TextField(text: .init(get: { |
134 | | - "\(Int(settings.suggestionCodeFontSize))" |
135 | | - }, set: { |
136 | | - settings.suggestionCodeFontSize = Double(Int($0) ?? 0) |
137 | | - })) { |
138 | | - Text("Font size of suggestion code") |
139 | | - } |
140 | | - .textFieldStyle(.roundedBorder) |
| 128 | + Toggle(isOn: $settings.hideCommonPrecedingSpacesInSuggestion) { |
| 129 | + Text("Hide Common Preceding Spaces") |
| 130 | + } |
141 | 131 |
|
142 | | - Text("pt") |
| 132 | + HStack { |
| 133 | + TextField(text: .init(get: { |
| 134 | + "\(Int(settings.suggestionCodeFontSize))" |
| 135 | + }, set: { |
| 136 | + settings.suggestionCodeFontSize = Double(Int($0) ?? 0) |
| 137 | + })) { |
| 138 | + Text("Font size of suggestion code") |
143 | 139 | } |
144 | | - Divider() |
| 140 | + .textFieldStyle(.roundedBorder) |
| 141 | + |
| 142 | + Text("pt") |
145 | 143 | } |
146 | 144 | } |
147 | 145 | } |
|
0 commit comments