fix: 贴子正文无法触发点击事件
This commit is contained in:
parent
d86f0d9c41
commit
a758639eb1
|
|
@ -302,9 +302,9 @@ fun PbContentText(
|
||||||
awaitEachGesture {
|
awaitEachGesture {
|
||||||
val change = awaitFirstDown()
|
val change = awaitFirstDown()
|
||||||
val annotation =
|
val annotation =
|
||||||
layoutResult.value?.getOffsetForPosition(change.position)?.let {
|
layoutResult.value?.getOffsetForPosition(change.position)?.let { offset ->
|
||||||
text.getStringAnnotations(start = it, end = it)
|
text.getStringAnnotations(start = offset, end = offset)
|
||||||
.firstOrNull()
|
.firstOrNull { it.tag == "url" || it.tag == "user" }
|
||||||
}
|
}
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
if (change.pressed != change.previousPressed) change.consume()
|
if (change.pressed != change.previousPressed) change.consume()
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ object EmoticonUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalTextApi::class)
|
||||||
val AnnotatedString.emoticonString: AnnotatedString
|
val AnnotatedString.emoticonString: AnnotatedString
|
||||||
get() {
|
get() {
|
||||||
if (hasStringAnnotations("Emoticon", 0, length)) {
|
if (hasStringAnnotations("Emoticon", 0, length)) {
|
||||||
|
|
@ -154,7 +155,9 @@ object EmoticonUtil {
|
||||||
val regexPattern = Pattern.compile(getRegex(EMOTICON_ALL_TYPE))
|
val regexPattern = Pattern.compile(getRegex(EMOTICON_ALL_TYPE))
|
||||||
val matcher = regexPattern.matcher(this.text)
|
val matcher = regexPattern.matcher(this.text)
|
||||||
return buildAnnotatedString {
|
return buildAnnotatedString {
|
||||||
append(this@emoticonString)
|
withAnnotation("Emoticon", "true") {
|
||||||
|
append(this@emoticonString)
|
||||||
|
}
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
val start = matcher.start()
|
val start = matcher.start()
|
||||||
val end = matcher.end()
|
val end = matcher.end()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue