-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
NewCommandMouseView.swift
66 lines (62 loc) · 1.8 KB
/
NewCommandMouseView.swift
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
import Bonzai
import SwiftUI
struct NewCommandMouseView: View {
@Binding var payload: NewCommandPayload
@Binding var validation: NewCommandValidation
@State var selection: MouseCommand.Kind = .click(.focused(.center))
var body: some View {
Text("Mouse Command")
.font(.system(.body, design: .rounded,weight: .semibold))
.allowsTightening(true)
.lineLimit(1)
.foregroundColor(Color.secondary)
.frame(height: 12)
.frame(maxWidth: .infinity, alignment: .leading)
.overlay(alignment: .trailing) {
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(Color(nsColor: .systemYellow))
.betaFeature("Mouse Commands is currently in beta. If you have any feedback, please reach out to us.") {
Text("BETA")
.foregroundStyle(Color.black)
.font(.caption2)
.frame(maxWidth: .infinity)
}
.frame(width: 32)
}
HStack {
MouseIconView(size: 24)
Menu(content: {
ForEach(MouseCommand.Kind.allCases) { kind in
Button(action: {
selection = kind
}, label: {
Text(kind.displayValue)
})
}
}, label: {
Text(selection.displayValue)
})
.onChange(of: selection, perform: { value in
payload = .mouse(kind: selection)
})
.onAppear {
validation = .valid
payload = .mouse(kind: selection)
}
.menuStyle(.regular)
}
}
}
struct NewCommandMouseView_Previews: PreviewProvider {
static var previews: some View {
NewCommandView(
workflowId: UUID().uuidString,
commandId: nil,
title: "New command",
selection: .mouse,
payload: .placeholder,
onDismiss: {},
onSave: { _, _ in })
.designTime()
}
}