This commit is contained in:
Hailey
2024-01-12 23:30:13 -08:00
parent fdf75927f6
commit 2435a25257
@@ -1,4 +1,3 @@
import Foundation
import ExpoModulesCore import ExpoModulesCore
class ExpoSelectableTextView: ExpoView { class ExpoSelectableTextView: ExpoView {
@@ -49,7 +48,7 @@ class ExpoSelectableTextView: ExpoView {
override func layoutSubviews() -> Void { override func layoutSubviews() -> Void {
// Set the textView's frame on layout // Set the textView's frame on layout
setSize() self.setSize()
} }
@IBAction func callOnPress(_ sender: UITapGestureRecognizer) -> Void { @IBAction func callOnPress(_ sender: UITapGestureRecognizer) -> Void {
@@ -72,7 +71,7 @@ class ExpoSelectableTextView: ExpoView {
let size = CGSize(width: maxWidth, height: sizeThatFits.height) let size = CGSize(width: maxWidth, height: sizeThatFits.height)
textView.frame.size = size textView.frame.size = size
onTextLayout([ self.onTextLayout([
"height": sizeThatFits.height, "height": sizeThatFits.height,
"width": maxWidth "width": maxWidth
]) ])
@@ -81,7 +80,7 @@ class ExpoSelectableTextView: ExpoView {
func setText() -> Void { func setText() -> Void {
let finalAttributedString = NSMutableAttributedString() let finalAttributedString = NSMutableAttributedString()
segments.forEach { segment in self.segments.forEach { segment in
// Set some generic attributes that don't need ranges // Set some generic attributes that don't need ranges
let attributes: [NSAttributedString.Key:Any] = [ let attributes: [NSAttributedString.Key:Any] = [
.font: UIFont.systemFont(ofSize: segment.style?.fontSize ?? self.style?.fontSize ?? 12.0, weight: segment.style?.fontWeight?.toFontWeight() ?? self.style?.fontWeight?.toFontWeight() ?? .regular), .font: UIFont.systemFont(ofSize: segment.style?.fontSize ?? self.style?.fontSize ?? 12.0, weight: segment.style?.fontWeight?.toFontWeight() ?? self.style?.fontWeight?.toFontWeight() ?? .regular),
@@ -133,7 +132,7 @@ class ExpoSelectableTextView: ExpoView {
var foundSegment: TextSegment? var foundSegment: TextSegment?
// Check each segment // Check each segment
segments.forEach { segment in self.segments.forEach { segment in
let range = text.range(of: segment.text) let range = text.range(of: segment.text)
// Figure out the bounds // Figure out the bounds
if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound { if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound {