63 lines
1.9 KiB
Swift
63 lines
1.9 KiB
Swift
import SwiftUI
|
|
|
|
struct SybilPromptField: View {
|
|
var placeholder: String = "Enter Prompt"
|
|
@Binding var text: String
|
|
@FocusState.Binding var focused: Bool
|
|
var selection: Binding<TextSelection?>? = nil
|
|
var axis: Axis = .vertical
|
|
var submit: () -> Void
|
|
|
|
var body: some View {
|
|
Group {
|
|
if let selection {
|
|
TextField(placeholder, text: $text, selection: selection, axis: axis)
|
|
} else {
|
|
TextField(placeholder, text: $text, axis: axis)
|
|
}
|
|
}
|
|
.focused($focused)
|
|
.font(.sybil(.body))
|
|
.textInputAutocapitalization(.sentences)
|
|
.autocorrectionDisabled(false)
|
|
.lineLimit(1 ... 6)
|
|
.submitLabel(.send)
|
|
.onSubmit(submit)
|
|
.submitOnMacReturn(submit)
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 10)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 12)
|
|
.fill(SybilTheme.composerGradient)
|
|
.opacity(0.98)
|
|
)
|
|
.foregroundStyle(SybilTheme.text)
|
|
}
|
|
}
|
|
|
|
struct SybilPromptSendButton: View {
|
|
var systemImage: String = "arrow.up"
|
|
var canSend: Bool
|
|
var submit: () -> Void
|
|
|
|
var body: some View {
|
|
Button(action: submit) {
|
|
Image(systemName: systemImage)
|
|
.font(.system(size: 17, weight: .semibold))
|
|
.frame(width: 40, height: 40)
|
|
.background(
|
|
Circle()
|
|
.fill(
|
|
canSend
|
|
? AnyShapeStyle(SybilTheme.primaryGradient)
|
|
: AnyShapeStyle(SybilTheme.surface)
|
|
)
|
|
)
|
|
.foregroundStyle(canSend ? SybilTheme.text : SybilTheme.textMuted)
|
|
}
|
|
.buttonStyle(.plain)
|
|
.disabled(!canSend)
|
|
.accessibilityLabel("Send message")
|
|
}
|
|
}
|