mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-18 07:51:46 +00:00
fix: android not registering hold to change profile
This commit is contained in:
parent
da217c96b7
commit
bcf1e65903
1 changed files with 16 additions and 4 deletions
|
|
@ -56,7 +56,6 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
|||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.LayoutCoordinates
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.layout.boundsInWindow
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
|
|
@ -76,6 +75,8 @@ import kotlinx.coroutines.launch
|
|||
import nuvio.composeapp.generated.resources.*
|
||||
import org.jetbrains.compose.resources.getString
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
@Composable
|
||||
fun ProfileSwitcherTab(
|
||||
|
|
@ -124,9 +125,9 @@ fun ProfileSwitcherTab(
|
|||
|
||||
fun updateDragTarget(localPosition: Offset) {
|
||||
val trigger = triggerCoordinates ?: return
|
||||
val windowPosition = trigger.localToWindow(localPosition)
|
||||
val screenPosition = trigger.localToScreen(localPosition)
|
||||
val nextTargetProfileIndex = profileBubbleBounds.entries
|
||||
.firstOrNull { (_, bounds) -> bounds.contains(windowPosition) }
|
||||
.firstOrNull { (_, bounds) -> bounds.contains(screenPosition) }
|
||||
?.key
|
||||
if (nextTargetProfileIndex != null && nextTargetProfileIndex != dragTargetProfileIndex) {
|
||||
performProfileHoverHaptic()
|
||||
|
|
@ -450,7 +451,7 @@ private fun PopupProfileBubble(
|
|||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.onGloballyPositioned { coordinates ->
|
||||
onBoundsChanged(coordinates.boundsInWindow())
|
||||
onBoundsChanged(coordinates.boundsOnScreen())
|
||||
}
|
||||
.graphicsLayer {
|
||||
alpha = itemAlpha.value
|
||||
|
|
@ -565,6 +566,17 @@ private fun PopupProfileBubble(
|
|||
}
|
||||
}
|
||||
|
||||
private fun LayoutCoordinates.boundsOnScreen(): Rect {
|
||||
val topLeft = localToScreen(Offset.Zero)
|
||||
val bottomRight = localToScreen(Offset(size.width.toFloat(), size.height.toFloat()))
|
||||
return Rect(
|
||||
left = min(topLeft.x, bottomRight.x),
|
||||
top = min(topLeft.y, bottomRight.y),
|
||||
right = max(topLeft.x, bottomRight.x),
|
||||
bottom = max(topLeft.y, bottomRight.y),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Compact inline PIN entry shown inside the popup when a PIN-protected
|
||||
* profile is tapped.
|
||||
|
|
|
|||
Loading…
Reference in a new issue