forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpvoteButton.swift
More file actions
33 lines (30 loc) · 1.06 KB
/
UpvoteButton.swift
File metadata and controls
33 lines (30 loc) · 1.06 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
import AppKit
import SwiftUI
import ConversationServiceProvider
public struct UpvoteButton: View {
public var upvote: (ConversationRating) -> Void
@State var isSelected = false
public init(upvote: @escaping (ConversationRating) -> Void) {
self.upvote = upvote
}
public var body: some View {
Button(action: {
isSelected = !isSelected
isSelected ? upvote(.helpful) : upvote(.unrated)
}) {
Image(systemName: isSelected ? "hand.thumbsup.fill" : "hand.thumbsup")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 14, height: 14)
// .frame(width: 20, height: 20, alignment: .center)
.foregroundColor(.secondary)
// .background(
// .regularMaterial,
// in: RoundedRectangle(cornerRadius: 4, style: .circular)
// )
.padding(4)
.help("Helpful")
}
.buttonStyle(HoverButtonStyle(padding: 0))
}
}