-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathCodeHighlightThemePicker.swift
More file actions
71 lines (59 loc) · 1.66 KB
/
CodeHighlightThemePicker.swift
File metadata and controls
71 lines (59 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import Foundation
import Preferences
import SwiftUI
public struct CodeHighlightThemePicker: View {
public enum Scenario {
case suggestion
case promptToCode
case chat
}
let scenario: Scenario
public init(scenario: Scenario) {
self.scenario = scenario
}
public var body: some View {
switch scenario {
case .suggestion:
SuggestionThemePicker()
case .promptToCode:
PromptToCodeThemePicker()
case .chat:
ChatThemePicker()
}
}
struct SuggestionThemePicker: View {
@AppStorage(\.syncSuggestionHighlightTheme) var sync: Bool
var body: some View {
SyncToggle(sync: $sync)
}
}
struct PromptToCodeThemePicker: View {
@AppStorage(\.syncPromptToCodeHighlightTheme) var sync: Bool
var body: some View {
SyncToggle(sync: $sync)
}
}
struct ChatThemePicker: View {
@AppStorage(\.syncChatCodeHighlightTheme) var sync: Bool
var body: some View {
SyncToggle(sync: $sync)
}
}
struct SyncToggle: View {
@Binding var sync: Bool
var body: some View {
VStack(alignment: .leading) {
Toggle(isOn: $sync) {
Text("Sync color scheme with Xcode")
}
Text("To refresh the theme, you must activate the extension service app once.")
.font(.footnote)
.foregroundColor(.secondary)
}
}
}
}
#Preview {
@State var sync = false
return CodeHighlightThemePicker.SyncToggle(sync: $sync)
}