OGAM
OGAM copied to clipboard
Add selectable text in chat responses
Summary
Update the chat output to handle selecting and copying individual parts of the text.
Problem / Motivation
Right now the only option is to long press the AI's output and copy the entire response. It would be beneficial to be able to select targeted lines or words for copying.
Proposed Solution
Implement UITextView using the below method suggested by the LLM:
import SwiftUI import UIKit
struct SelectableTextView: UIViewRepresentable { let text: String
func makeUIView(context: Context) -> UITextView {
let textView = UITextView()
textView.backgroundColor = .clear
textView.isEditable = false
textView.isSelectable = true
textView.isScrollEnabled = false // Allows the bubble to resize naturally
textView.textContainerInset = .zero
textView.textContainer.lineFragmentPadding = 0
textView.font = UIFont.preferredFont(forTextStyle: .body)
// Ensure the view doesn't hog space in a List/VStack
textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
return textView
}
func updateUIView(_ uiView: UITextView, context: Context) {
uiView.text = text
}
}
Platform
- [ ] Android
- [X] iOS
- [ ] Both
Reasonable, putting this to my backlog.