forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStyles.swift
More file actions
64 lines (58 loc) · 2.15 KB
/
Styles.swift
File metadata and controls
64 lines (58 loc) · 2.15 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
import SwiftUI
struct CopilotButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding(.vertical, 4)
.padding(.horizontal, 8)
.foregroundColor(.white)
.background(
RoundedRectangle(cornerRadius: 4, style: .continuous)
.fill(
configuration.isPressed
? Color("ButtonBackgroundColorPressed")
: Color("ButtonBackgroundColorDefault")
)
.animation(.easeOut(duration: 0.1), value: configuration.isPressed)
)
.overlay {
RoundedRectangle(cornerRadius: 4, style: .continuous)
.stroke(Color.white.opacity(0.2), style: .init(lineWidth: 1))
}
}
}
extension ButtonStyle where Self == CopilotButtonStyle {
static var copilot: CopilotButtonStyle { CopilotButtonStyle() }
}
struct CopilotTextFieldStyle: TextFieldStyle {
func _body(configuration: TextField<_Label>) -> some View {
configuration
.colorScheme(.dark)
.textFieldStyle(.plain)
.foregroundColor(.white)
.padding(.vertical, 4)
.padding(.horizontal, 8)
.background(
RoundedRectangle(cornerRadius: 4, style: .continuous)
.fill(.white.opacity(0.2))
)
.overlay {
RoundedRectangle(cornerRadius: 4, style: .continuous)
.stroke(.white.opacity(0.2), style: .init(lineWidth: 1))
}
}
}
extension TextFieldStyle where Self == CopilotTextFieldStyle {
static var copilot: CopilotTextFieldStyle { CopilotTextFieldStyle() }
}
struct CopilotStyle_Previews: PreviewProvider {
static var previews: some View {
VStack(alignment: .leading, spacing: 8) {
Button("Button") {}
.buttonStyle(.copilot)
TextField("title", text: .constant("Placeholder"))
.textFieldStyle(.copilot)
}
.padding(.all, 8)
.background(Color.black)
}
}