mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
revert the tab overlay clip measurement
Tracking the content position per frame made the inactive-tab colour split chase the layout instead of only following the indicator, so the icons jittered on a swipe. Go back to the stable tab-relative offset.
This commit is contained in:
@@ -90,7 +90,6 @@ import androidx.compose.ui.layout.boundsInParent
|
|||||||
import androidx.compose.ui.layout.layout
|
import androidx.compose.ui.layout.layout
|
||||||
import androidx.compose.ui.layout.onGloballyPositioned
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
import androidx.compose.ui.layout.onSizeChanged
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.layout.positionInRoot
|
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||||
import androidx.compose.ui.unit.Constraints
|
import androidx.compose.ui.unit.Constraints
|
||||||
@@ -772,23 +771,18 @@ private fun TabButton(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val selectedContent = artwork?.scheme?.onPrimary ?: MaterialTheme.colorScheme.background
|
val selectedContent = artwork?.scheme?.onPrimary ?: MaterialTheme.colorScheme.background
|
||||||
|
val paddingStart = with(LocalDensity.current) { 8.dp.toPx() }
|
||||||
var tabLeft by remember { mutableFloatStateOf(0f) }
|
var tabLeft by remember { mutableFloatStateOf(0f) }
|
||||||
var tabRootX by remember { mutableFloatStateOf(0f) }
|
val clipStart = indicatorLeft?.minus(tabLeft + paddingStart)
|
||||||
var contentRootX by remember { mutableFloatStateOf(0f) }
|
val clipEnd = indicatorRight?.minus(tabLeft + paddingStart)
|
||||||
val contentLeft = tabLeft + (contentRootX - tabRootX)
|
|
||||||
val clipStart = indicatorLeft?.minus(contentLeft)
|
|
||||||
val clipEnd = indicatorRight?.minus(contentLeft)
|
|
||||||
Box(
|
Box(
|
||||||
modifier =
|
modifier =
|
||||||
modifier
|
modifier
|
||||||
.onGloballyPositioned {
|
.onGloballyPositioned { tabLeft = it.boundsInParent().left }
|
||||||
tabLeft = it.boundsInParent().left
|
.clickable(onClick = onClick)
|
||||||
tabRootX = it.positionInRoot().x
|
|
||||||
}.clickable(onClick = onClick)
|
|
||||||
.minimumInteractiveComponentSize()
|
.minimumInteractiveComponentSize()
|
||||||
.padding(start = 8.dp, end = 12.dp, top = TAB_VERTICAL_PADDING, bottom = TAB_VERTICAL_PADDING),
|
.padding(start = 8.dp, end = 12.dp, top = TAB_VERTICAL_PADDING, bottom = TAB_VERTICAL_PADDING),
|
||||||
) {
|
) {
|
||||||
Box(Modifier.onGloballyPositioned { contentRootX = it.positionInRoot().x }) {
|
|
||||||
if (clipStart != null && clipEnd != null) {
|
if (clipStart != null && clipEnd != null) {
|
||||||
Box(
|
Box(
|
||||||
modifier =
|
modifier =
|
||||||
@@ -821,7 +815,6 @@ private fun TabButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun TabContent(
|
private fun TabContent(
|
||||||
|
|||||||
Reference in New Issue
Block a user