Skip to content

Commit 2a20302

Browse files
committed
Add a right click menu to widget
1 parent ceefdc5 commit 2a20302

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Core/Sources/SuggestionWidget/WidgetView.swift

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ struct WidgetView: View {
7171
withAnimation(.easeInOut(duration: 0.2)) {
7272
isHovering = yes
7373
}
74+
}.contextMenu {
75+
WidgetContextMenu()
7476
}
7577
}
7678

@@ -87,6 +89,51 @@ struct WidgetView: View {
8789
}
8890
}
8991

92+
struct WidgetContextMenu: View {
93+
@AppStorage(\.useGlobalChat) var useGlobalChat
94+
@AppStorage(\.realtimeSuggestionToggle) var realtimeSuggestionToggle
95+
@AppStorage(\.acceptSuggestionWithAccessibilityAPI) var acceptSuggestionWithAccessibilityAPI
96+
97+
var body: some View {
98+
Group {
99+
Button(action: {
100+
useGlobalChat.toggle()
101+
}) {
102+
Text("Use Global Chat")
103+
if useGlobalChat {
104+
Image(systemName: "checkmark")
105+
}
106+
}
107+
108+
Button(action: {
109+
realtimeSuggestionToggle.toggle()
110+
}) {
111+
Text("Realtime Suggestion")
112+
if realtimeSuggestionToggle {
113+
Image(systemName: "checkmark")
114+
}
115+
}
116+
117+
Button(action: {
118+
acceptSuggestionWithAccessibilityAPI.toggle()
119+
}, label: {
120+
Text("Accept Suggestion with Accessibility API")
121+
if acceptSuggestionWithAccessibilityAPI {
122+
Image(systemName: "checkmark")
123+
}
124+
})
125+
126+
Divider()
127+
128+
Button(action: {
129+
exit(0)
130+
}) {
131+
Text("Quit")
132+
}
133+
}
134+
}
135+
}
136+
90137
struct WidgetView_Preview: PreviewProvider {
91138
static var previews: some View {
92139
VStack {

0 commit comments

Comments
 (0)