56 lines
1.7 KiB
Swift
56 lines
1.7 KiB
Swift
import SwiftUI
|
|
import PhotosUI
|
|
|
|
struct MessageInputView: View {
|
|
@Binding var text: String
|
|
let isSending: Bool
|
|
let onSend: () -> Void
|
|
|
|
@State private var showAttachMenu = false
|
|
@State private var selectedPhoto: PhotosPickerItem?
|
|
|
|
var body: some View {
|
|
HStack(spacing: 8) {
|
|
// Attach button
|
|
Menu {
|
|
Button(action: {}) {
|
|
Label("Photo", systemImage: "photo")
|
|
}
|
|
Button(action: {}) {
|
|
Label("File", systemImage: "doc")
|
|
}
|
|
} label: {
|
|
Image(systemName: "plus.circle.fill")
|
|
.font(.title2)
|
|
.foregroundStyle(.blue)
|
|
}
|
|
|
|
// Text field
|
|
TextField("Message", text: $text, axis: .vertical)
|
|
.textFieldStyle(.roundedBorder)
|
|
.lineLimit(1...5)
|
|
.onSubmit {
|
|
if !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
|
onSend()
|
|
}
|
|
}
|
|
|
|
// Send button
|
|
Button(action: onSend) {
|
|
if isSending {
|
|
ProgressView()
|
|
.scaleEffect(0.8)
|
|
} else {
|
|
Image(systemName: "arrow.up.circle.fill")
|
|
.font(.title2)
|
|
.foregroundStyle(.blue)
|
|
}
|
|
}
|
|
.disabled(text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || isSending)
|
|
}
|
|
.padding(.horizontal)
|
|
.padding(.vertical, 8)
|
|
.background(.ultraThinMaterial)
|
|
}
|
|
}
|