Improves helder
This commit is contained in:
@@ -7,7 +7,6 @@ public struct PassOnPanel: View {
|
||||
let insert: (String) -> Void
|
||||
let cancel: () -> Void
|
||||
@State private var note = ""
|
||||
@FocusState private var focused: Bool
|
||||
|
||||
public init(request: PassOnRequest, insert: @escaping (String) -> Void, cancel: @escaping () -> Void) {
|
||||
self.request = request
|
||||
@@ -42,14 +41,8 @@ public struct PassOnPanel: View {
|
||||
Spacer()
|
||||
EscChip()
|
||||
}
|
||||
TextField("", text: $note, prompt: Text("Add a note (optional)…").foregroundStyle(Palette.text4))
|
||||
.textFieldStyle(.plain)
|
||||
.typeRole(TypeRole(.monoRegular, 13))
|
||||
.foregroundStyle(Palette.text1)
|
||||
.focused($focused)
|
||||
.onSubmit { insert(composed) }
|
||||
.onExitCommand(perform: cancel)
|
||||
.padding(.horizontal, 10)
|
||||
OverlayCommandField(text: $note, placeholder: "Add a note (optional)…", font: TypeRole(.monoRegular, 13).nsFont,
|
||||
initialSelection: nil, horizontalInset: 10, onKey: handle)
|
||||
.frame(height: 38)
|
||||
.background(Palette.editor, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
|
||||
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).stroke(Palette.amber, lineWidth: Metrics.accentRule))
|
||||
@@ -68,7 +61,15 @@ public struct PassOnPanel: View {
|
||||
.background(Palette.panel, in: RoundedRectangle(cornerRadius: Metrics.radiusMedium))
|
||||
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusMedium).stroke(Palette.raised, lineWidth: Metrics.hairline))
|
||||
.shadow(color: Palette.menuShadow, radius: Metrics.menuShadowRadius, y: Metrics.menuShadowY)
|
||||
.onAppear { focused = true }
|
||||
}
|
||||
|
||||
private func handle(_ key: OverlayKey) -> Bool {
|
||||
switch key {
|
||||
case .enter: insert(composed)
|
||||
case .escape: cancel()
|
||||
default: return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
||||
Reference in New Issue
Block a user