forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDownvoteButton.swift
More file actions
28 lines (25 loc) · 864 Bytes
/
DownvoteButton.swift
File metadata and controls
28 lines (25 loc) · 864 Bytes
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
import AppKit
import SwiftUI
import ConversationServiceProvider
public struct DownvoteButton: View {
public var downvote: (ConversationRating) -> Void
@State var isSelected = false
public init(downvote: @escaping (ConversationRating) -> Void) {
self.downvote = downvote
}
public var body: some View {
Button(action: {
isSelected = !isSelected
isSelected ? downvote(.unhelpful) : downvote(.unrated)
}) {
Image(systemName: isSelected ? "hand.thumbsdown.fill" : "hand.thumbsdown")
.resizable()
.scaledToFit()
.scaledPadding(2)
.scaledFrame(width: 16, height: 16)
.foregroundColor(.secondary)
.help("Unhelpful")
}
.buttonStyle(HoverButtonStyle(padding: 0))
}
}