simplify getPressed

This commit is contained in:
Hailey
2024-01-15 18:48:36 -08:00
parent d92584bad7
commit 87d44e4b57
@@ -123,20 +123,15 @@ class ExpoUITextView: ExpoView {
)
let text = textView.attributedText.string
var foundChild: ExpoUITextViewChild?
// Check each segment
self.textChildren.forEach { child in
return textChildren.first(where: { child in
let range = text.range(of: child.text ?? "")
// Figure out the bounds
if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound {
if charIndex >= lowerBound.utf16Offset(in: text), charIndex <= upperBound.utf16Offset(in: text) {
foundChild = child
}
}
}
return foundChild
if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound {
return charIndex >= lowerBound.utf16Offset(in: text) && charIndex <= upperBound.utf16Offset(in: text)
}
return false
})
}
// Get the children. Always use getTextChildren() so that we ensure the correct order of views