Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove unnecessary while (true) inside BasicRichText pointerInput #378

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal suspend fun PointerInputScope.detectTapGestures(
onLongPress: ((Offset) -> Unit)? = null,
onTap: ((Offset) -> Unit)? = null,
consumeDown: (Offset) -> Boolean,
) = coroutineScope {
) {
awaitEachGesture {
val down = awaitFirstDown()
if (!consumeDown(down.position)) return@awaitEachGesture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,20 @@ public fun BasicRichText(
modifier = modifier
.drawRichSpanStyle(state)
.pointerHoverIcon(pointerIcon.value)
.pointerInput(Unit) {
.pointerInput(state) {
awaitEachGesture {
while (true) {
val event = awaitPointerEvent()
val position = event.changes.first().position
val isLink = state.isLink(position)
val event = awaitPointerEvent()
val position = event.changes.first().position
val isLink = state.isLink(position)

pointerIcon.value =
if (isLink)
PointerIcon.Hand
else
PointerIcon.Default
}
pointerIcon.value =
if (isLink)
PointerIcon.Hand
else
PointerIcon.Default
}
}
.pointerInput(Unit) {
.pointerInput(state) {
detectTapGestures(
onTap = { offset ->
state.getLinkByOffset(offset)?.let { url ->
Expand Down
Loading