|
| 1 | +import SwiftUI |
| 2 | + |
| 3 | +struct PromptToCodeSettingsView: View { |
| 4 | + final class Settings: ObservableObject { |
| 5 | + @AppStorage(\.hideCommonPrecedingSpacesInSuggestion) |
| 6 | + var hideCommonPrecedingSpacesInSuggestion |
| 7 | + @AppStorage(\.suggestionCodeFontSize) |
| 8 | + var suggestionCodeFontSize |
| 9 | + @AppStorage(\.acceptSuggestionWithAccessibilityAPI) |
| 10 | + var acceptSuggestionWithAccessibilityAPI |
| 11 | + init() {} |
| 12 | + } |
| 13 | + |
| 14 | + @StateObject var settings = Settings() |
| 15 | + |
| 16 | + var body: some View { |
| 17 | + VStack(alignment: .center) { |
| 18 | + Text("Mirroring Settings of Suggestions") |
| 19 | + .foregroundColor(.white) |
| 20 | + .padding(.vertical, 2) |
| 21 | + .padding(.horizontal, 8) |
| 22 | + .background( |
| 23 | + Color.accentColor, |
| 24 | + in: RoundedRectangle(cornerRadius: 20) |
| 25 | + ) |
| 26 | + |
| 27 | + Form { |
| 28 | + Toggle(isOn: $settings.hideCommonPrecedingSpacesInSuggestion) { |
| 29 | + Text("Hide Common Preceding Spaces") |
| 30 | + }.disabled(true) |
| 31 | + |
| 32 | + HStack { |
| 33 | + TextField(text: .init(get: { |
| 34 | + "\(Int(settings.suggestionCodeFontSize))" |
| 35 | + }, set: { |
| 36 | + settings.suggestionCodeFontSize = Double(Int($0) ?? 0) |
| 37 | + })) { |
| 38 | + Text("Font size of suggestion code") |
| 39 | + } |
| 40 | + .textFieldStyle(.roundedBorder) |
| 41 | + |
| 42 | + Text("pt") |
| 43 | + }.disabled(true) |
| 44 | + |
| 45 | + Toggle(isOn: $settings.acceptSuggestionWithAccessibilityAPI) { |
| 46 | + Text("Use accessibility API to accept suggestion in widget") |
| 47 | + }.disabled(true) |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +struct PromptToCodeSettingsView_Previews: PreviewProvider { |
| 54 | + static var previews: some View { |
| 55 | + PromptToCodeSettingsView() |
| 56 | + } |
| 57 | +} |
| 58 | + |
0 commit comments