feat(swift-ios): paste images from the composer's native menu #7607
Mergedmackinleysmith(GitHub profile, opens in a new tab)merged 7 commits into
t3code/rebuild-mobile-app-swift fromrefs/pull/7607/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/swift-ios/Features/Chat/FeatureComposerTextInput.swift line 186Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +161,21 @@161+ pasteConfiguration = acceptsImages162+ ? UIPasteConfiguration(163+ acceptableTypeIdentifiers: [164+ UTType.image.identifier,165+ UTType.text.identifier,166+ ]167+ )168+ : nil169+ }170+ }171+ var onPasteImages: (([NSItemProvider]) -> Void)?172+ var onDismissKeyboard: (() -> Void)?173+ private var wantsFirstResponderOnAttach = false174+175+ /// Programmatic focus can arrive before the view joins a window (a host176+ /// refocusing right as the composer expands); retry once attached.177+ func becomeFirstResponderWhenAttached() {178+ if window != nil {179+ becomeFirstResponder()180+ } else {181+ wantsFirstResponderOnAttach = true
- apps/swift-ios/Features/Chat/FeatureComposerTextInput.swift line 99Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +76,21 @@76+ : min(selectedRange.length, text.utf16.count - location)77+ textView.selectedRange = NSRange(location: location, length: length)78+ textView.scrollRangeToVisible(textView.selectedRange)79+ }80+ }81+ if shouldApplySelection, let selectionRequest {82+ let location = min(selectionRequest.location, textView.text.utf16.count)83+ textView.selectedRange = NSRange(location: location, length: 0)84+ textView.scrollRangeToVisible(textView.selectedRange)85+ context.coordinator.lastAppliedSelectionRequestID = selectionRequest.id86+ }87+ updateAccessibility(textView)88+89+ if context.coordinator.lastAppliedFocus != focused {90+ context.coordinator.lastAppliedFocus = focused91+ if focused, !textView.isFirstResponder {92+ textView.becomeFirstResponderWhenAttached()93+ } else if !focused, textView.isFirstResponder {94+ textView.resignFirstResponder()95+ }96+ }
- apps/swift-ios/Features/Chat/FeatureComposerTextInput.swift line 49Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +30,21 @@30+ textView.acceptsImages = acceptsImages31+ textView.onPasteImages = onPasteImages32+ textView.onDismissKeyboard = onDismissKeyboard33+ if onDismissKeyboard != nil {34+ textView.installDismissPanRecognizer()35+ }36+ textView.backgroundColor = .clear37+ textView.textColor = T3Colors.uiTextPrimary38+ textView.tintColor = T3Colors.uiAccent39+ textView.font = UIFont.preferredFont(forTextStyle: .body)40+ textView.adjustsFontForContentSizeCategory = true41+ // Match the metrics of the SwiftUI text field this view replaced so42+ // the swap is invisible: the surrounding paddings stay in SwiftUI.43+ textView.textContainerInset = .zero44+ textView.textContainer.lineFragmentPadding = 045+ textView.isScrollEnabled = true46+ // Deliberately not `keyboardDismissMode = .interactive`: the capped47+ // input sits directly above the keyboard, so scrolling up through a48+ // long draft drags into the keyboard's frame and yanks it around.49+ // Dismissal belongs to the pan recognizer below, which only fires50+ // for a drag that begins with the draft at its top.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
f997c85b-d1e8-4b97-9566-3256e4f25472You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share