diff --git a/Packages/ComposeUI/Sources/ComposeUI/ComposeInput.swift b/Packages/ComposeUI/Sources/ComposeUI/ComposeInput.swift index 4759ba26..586dde94 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/ComposeInput.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/ComposeInput.swift @@ -77,14 +77,21 @@ struct FocusedInputModifier: ViewModifier { // This property wrapper abstracts over them both. @propertyWrapper struct FocusedInput: DynamicProperty { - @Environment(\.toolbarInjectedFocusedInputBox) private var box @FocusedValue(\.composeInput) private var input + #if !targetEnvironment(macCatalyst) && !os(visionOS) + @Environment(\.toolbarInjectedFocusedInputBox) private var box @StateObject private var updater = Updater() + #endif var wrappedValue: (any ComposeInput)? { + #if !targetEnvironment(macCatalyst) && !os(visionOS) box?.wrappedValue ?? input ?? nil + #else + input ?? nil + #endif } + #if !targetEnvironment(macCatalyst) && !os(visionOS) func update() { updater.update(box: box) } @@ -98,4 +105,5 @@ struct FocusedInput: DynamicProperty { } } } + #endif } diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeToolbarView.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeToolbarView.swift index 619c416a..32895e88 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeToolbarView.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeToolbarView.swift @@ -42,7 +42,7 @@ struct ComposeToolbarView: View { VisibilityButton(draft: draft, instanceFeatures: mastodonController.instanceFeatures) LocalOnlyButton(enabled: $draft.localOnly, mastodonController: mastodonController) - + InsertEmojiButton() FormatButtons() diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeView.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeView.swift index 36da180f..7c43f992 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeView.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/ComposeView.swift @@ -55,7 +55,9 @@ public struct ComposeView: View { ) .environment(\.composeUIConfig, config) .environment(\.currentAccount, currentAccount) + #if !targetEnvironment(macCatalyst) && !os(visionOS) .injectInputAccessoryHost(state: state, mastodonController: mastodonController, focusedField: $focusedField) + #endif .onReceive(NotificationCenter.default.publisher(for: .NSManagedObjectContextObjectsDidChange, object: DraftsPersistentContainer.shared.viewContext), perform: self.managedObjectsDidChange) } @@ -160,17 +162,23 @@ private struct ComposeViewBody: View { // When we're using the input accessory toolbar, hide the overlay toolbar so that, // on iPad, we don't get two toolbars showing. + #if targetEnvironment(macCatalyst) || os(visionOS) + let showOverlayToolbar = true + #else let showOverlayToolbar = if #available(iOS 16.0, *) { focusedField == nil } else { true } + #endif if config.showToolbar, showOverlayToolbar { toolbarView .frame(maxHeight: .infinity, alignment: .bottom) + #if !targetEnvironment(macCatalyst) && !os(visionOS) .modifier(IgnoreKeyboardSafeAreaIfUsingInputAccessory()) + #endif .transition(.move(edge: .bottom)) .animation(.snappy, value: config.showToolbar) } @@ -307,6 +315,7 @@ private struct ToolbarSafeAreaInsetModifier: ViewModifier { } #endif +#if !targetEnvironment(macCatalyst) && !os(visionOS) private struct IgnoreKeyboardSafeAreaIfUsingInputAccessory: ViewModifier { func body(content: Content) -> some View { if #available(iOS 16.0, *) { @@ -419,6 +428,7 @@ private struct InputAccessoryToolbarView: View { .tint(accentColor.color.map(Color.init(uiColor:))) } } +#endif //#Preview { // ComposeView() diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift index cfed3e43..d2761bd1 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/DraftContentEditor.swift @@ -92,7 +92,6 @@ private struct LanguageButtonStyle: ButtonStyle { } } -@available(iOS, obsoleted: 16.0) private struct LanguageButtonStyleAnimationModifier: ViewModifier { let isPressed: Bool diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift index f09c59a8..babd858a 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/EmojiTextField.swift @@ -64,11 +64,11 @@ struct EmojiTextField: UIViewRepresentable { #if !os(visionOS) uiView.backgroundColor = colorScheme == .dark ? UIColor(fillColor) : .secondarySystemBackground - #endif if uiView.inputAccessoryView !== inputAccessoryToolbarHost { uiView.inputAccessoryView = inputAccessoryToolbarHost } + #endif } func makeCoordinator() -> Coordinator { diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/NewMainTextView.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/NewMainTextView.swift index ffc9cad5..9f577659 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/NewMainTextView.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/NewMainTextView.swift @@ -95,9 +95,11 @@ private struct NewMainTextViewRepresentable: UIViewRepresentable { // uiView.backgroundColor = colorScheme == .dark ? UIColor(fillColor) : .secondarySystemBackground // #endif + #if !os(visionOS) if uiView.inputAccessoryView !== inputAccessoryToolbarHost { uiView.inputAccessoryView = inputAccessoryToolbarHost } + #endif // Trying to set this with the @FocusState binding in onAppear results in the // keyboard not appearing until after the sheet presentation animation completes :/ diff --git a/Packages/TuskerComponents/Sources/TuskerComponents/MenuPicker.swift b/Packages/TuskerComponents/Sources/TuskerComponents/MenuPicker.swift index 2b185f55..24b78c55 100644 --- a/Packages/TuskerComponents/Sources/TuskerComponents/MenuPicker.swift +++ b/Packages/TuskerComponents/Sources/TuskerComponents/MenuPicker.swift @@ -59,7 +59,9 @@ public struct MenuPicker: UIViewRepresentable { #if targetEnvironment(macCatalyst) config.macIdiomStyle = .bordered #endif + #if !os(visionOS) config.contentInsets = .zero + #endif return config }