Skip to content
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
@@ -1,7 +1,10 @@
package tw.firemaples.onscreenocr.floatings.compose.base

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.unit.Dp
Expand Down Expand Up @@ -30,3 +33,14 @@ fun Dp.dpToPx() = with(LocalDensity.current) { this@dpToPx.toPx() }

@Composable
fun Int.pxToDp() = with(LocalDensity.current) { this@pxToDp.toDp() }

fun Modifier.clickableWithoutRipple(
interactionSource: MutableInteractionSource,
onClick: () -> Unit
) = then(
Modifier.clickable(
interactionSource = interactionSource,
indication = null,
onClick = { onClick() }
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.graphics.Rect
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -51,6 +52,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import tw.firemaples.onscreenocr.R
import tw.firemaples.onscreenocr.floatings.compose.base.clickableWithoutRipple
import tw.firemaples.onscreenocr.floatings.compose.base.dpToPx
import tw.firemaples.onscreenocr.floatings.compose.base.pxToDp
import tw.firemaples.onscreenocr.floatings.compose.wigets.WordSelectionText
Expand All @@ -64,6 +66,7 @@ fun ResultViewContent(
requestRootLocationOnScreen: () -> Rect,
) {
val state by viewModel.state.collectAsState()
val emptyInteractionSource = remember { MutableInteractionSource() }

LaunchedEffect(Unit) {
val rootLocation = requestRootLocationOnScreen.invoke()
Expand All @@ -77,7 +80,10 @@ fun ResultViewContent(
modifier = Modifier
.fillMaxSize()
.background(colorResource(id = R.color.dialogOutside))
.clickable(onClick = viewModel::onDialogOutsideClicked),
.clickableWithoutRipple(
interactionSource = emptyInteractionSource,
onClick = viewModel::onDialogOutsideClicked,
),
) {
state.highlightArea.forEach {
TextHighlightBox(
Expand Down