Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Sources/ConversationKit/Views/MessageComposerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import SwiftUI
extension EnvironmentValues {
@Entry var onSubmitAction: () -> Void = {}
@Entry var disableAttachments: Bool = false
@Entry var attachmentActions: AnyView = AnyView(EmptyView())
@Entry var attachmentActions: AnyView? = nil
}

extension View {
Expand Down Expand Up @@ -55,7 +55,7 @@ public struct MessageComposerView<AttachmentType: Attachment>: View {
if #available(iOS 26.0, *) {
GlassEffectContainer {
HStack(alignment: .bottom) {
if !disableAttachments {
if !disableAttachments, let attachmentActions {
Menu {
attachmentActions
} label: {
Expand Down Expand Up @@ -99,7 +99,7 @@ public struct MessageComposerView<AttachmentType: Attachment>: View {
} else {
// provide compatible attachment actions and glass effect for iOS 18 and below
HStack(alignment: .bottom) {
if !disableAttachments {
if !disableAttachments, let attachmentActions {
Menu {
attachmentActions
} label: {
Expand Down Expand Up @@ -172,5 +172,17 @@ extension MessageComposerView where AttachmentType == EmptyAttachment {
]

MessageComposerView(message: $message, attachments: $attachments)
.attachmentActions {
Button(action: { }) {
Label("Photos", systemImage: "photo.on.rectangle.angled")
}
}
.padding()
}

#Preview("Without Attachments") {
@Previewable @State var message = "Hello, world!"

MessageComposerView(message: $message)

}