diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentRowController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentRowController.swift index 16273c85d7..ff11ef043a 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentRowController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentRowController.swift @@ -136,7 +136,7 @@ class AttachmentRowController: ViewController { .overlay { thumbnailFocusedOverlay } - .frame(width: 80, height: 80) + .frame(width: thumbnailSize, height: thumbnailSize) .onTapGesture { textEditorFocused = false // if we just focus the attachment immediately, the text editor doesn't actually unfocus @@ -162,7 +162,7 @@ class AttachmentRowController: ViewController { switch controller.descriptionMode { case .allowEntry: - InlineAttachmentDescriptionView(attachment: attachment, minHeight: 80) + InlineAttachmentDescriptionView(attachment: attachment, minHeight: thumbnailSize) .matchedGeometrySource(id: AttachmentDescriptionTextViewID(attachment), presentationID: attachment.id) .focused($textEditorFocused) @@ -192,6 +192,14 @@ class AttachmentRowController: ViewController { #endif } + private var thumbnailSize: CGFloat { + #if os(visionOS) + 120 + #else + 80 + #endif + } + @ViewBuilder private var thumbnailFocusedOverlay: some View { Image(systemName: "arrow.up.backward.and.arrow.down.forward") diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift index fdf4104dcc..bb31f3c9de 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift @@ -334,6 +334,11 @@ public final class ComposeController: ViewController { .toolbar { ToolbarItem(placement: .cancellationAction) { cancelButton } ToolbarItem(placement: .confirmationAction) { postButton } + #if os(visionOS) + ToolbarItem(placement: .bottomOrnament) { + ControllerView(controller: { controller.toolbarController }) + } + #endif } .background(GeometryReader { proxy in Color.clear @@ -342,11 +347,6 @@ public final class ComposeController: ViewController { globalFrameOutsideList = newValue } }) - #if os(visionOS) - .ornament(attachmentAnchor: .scene(.bottom)) { - ControllerView(controller: { controller.toolbarController }) - } - #endif .sheet(isPresented: $controller.isShowingDraftsList) { ControllerView(controller: { DraftsController(parent: controller, isPresented: $controller.isShowingDraftsList) }) } diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift index 5861c98763..a81227eb33 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift @@ -53,7 +53,6 @@ class ToolbarController: ViewController { var body: some View { #if os(visionOS) buttons - .glassBackgroundEffect(in: .rect(cornerRadius: 50)) #else ScrollView(.horizontal, showsIndicators: false) { buttons diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/AttachmentDescriptionTextView.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/AttachmentDescriptionTextView.swift index 5f1bbf0958..44313e198c 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/AttachmentDescriptionTextView.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/AttachmentDescriptionTextView.swift @@ -22,13 +22,21 @@ struct InlineAttachmentDescriptionView: View { self.minHeight = minHeight } + private var placeholderOffset: CGSize { + #if os(visionOS) + CGSize(width: 8, height: 8) + #else + CGSize(width: 4, height: 8) + #endif + } + var body: some View { ZStack(alignment: .topLeading) { if attachment.attachmentDescription.isEmpty { placeholder .font(.body) .foregroundColor(.secondary) - .offset(x: 4, y: 8) + .offset(placeholderOffset) } WrappedTextView( @@ -84,6 +92,10 @@ private struct WrappedTextView: UIViewRepresentable { view.font = .preferredFont(forTextStyle: .body) view.adjustsFontForContentSizeCategory = true view.textContainer.lineBreakMode = .byWordWrapping + #if os(visionOS) + view.borderStyle = .roundedRect + view.textContainerInset = UIEdgeInsets(top: 8, left: 4, bottom: 8, right: 4) + #endif return view } diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift index dd02ef8c89..cbb9906c2f 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift @@ -57,7 +57,9 @@ struct EmojiTextField: UIViewRepresentable { context.coordinator.maxLength = maxLength context.coordinator.focusNextView = focusNextView + #if !os(visionOS) uiView.backgroundColor = colorScheme == .dark ? UIColor(controller.config.fillColor) : .secondarySystemBackground + #endif if becomeFirstResponder?.wrappedValue == true { DispatchQueue.main.async { diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/MainTextView.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/MainTextView.swift index 2070e2df33..23fe44e31d 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/MainTextView.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/MainTextView.swift @@ -31,11 +31,19 @@ struct MainTextView: View { #endif } + private var textViewBackgroundColor: UIColor? { + #if os(visionOS) + nil + #else + colorScheme == .dark ? UIColor(config.fillColor) : .secondarySystemBackground + #endif + } + var body: some View { ZStack(alignment: .topLeading) { MainWrappedTextViewRepresentable( text: $draft.text, - backgroundColor: colorScheme == .dark ? UIColor(config.fillColor) : .secondarySystemBackground, + backgroundColor: textViewBackgroundColor, becomeFirstResponder: $controller.mainComposeTextViewBecomeFirstResponder, updateSelection: $updateSelection, textDidChange: textDidChange @@ -76,7 +84,7 @@ fileprivate struct MainWrappedTextViewRepresentable: UIViewRepresentable { typealias UIViewType = UITextView @Binding var text: String - let backgroundColor: UIColor + let backgroundColor: UIColor? @Binding var becomeFirstResponder: Bool @Binding var updateSelection: ((UITextView) -> Void)? let textDidChange: (UITextView) -> Void