@@ -51,8 +51,8 @@ import androidx.compose.ui.unit.IntOffset
5151import androidx.compose.ui.unit.dp
5252import androidx.compose.ui.unit.times
5353import top.yukonga.miuix.kmp.squircle.squircleBackground
54+ import top.yukonga.miuix.kmp.squircle.squircleBorder
5455import top.yukonga.miuix.kmp.squircle.squircleClip
55- import top.yukonga.miuix.kmp.squircle.squircleSurface
5656import top.yukonga.miuix.kmp.theme.MiuixTheme
5757import kotlin.math.roundToInt
5858
@@ -112,19 +112,9 @@ fun TabRow(
112112 val density = LocalDensity .current
113113 val tabWidthPx = with (density) { config.tabWidth.toPx() }
114114 val spacingPx = with (density) { itemSpacing.toPx() }
115- val indicatorOffset = remember { Animatable (0f ) }
116115 val availableWidth = this .maxWidth
117116 var lastSettledSelectedTabIndex by remember(config.listState) { mutableIntStateOf(- 1 ) }
118117
119- LaunchedEffect (selectedTabIndex, tabWidthPx, spacingPx) {
120- val target = selectedTabIndex * (tabWidthPx + spacingPx)
121- if (lastSettledSelectedTabIndex < 0 || lastSettledSelectedTabIndex == selectedTabIndex) {
122- indicatorOffset.snapTo(target)
123- } else {
124- indicatorOffset.animateTo(target, tween(200 , easing = LinearEasing ))
125- }
126- }
127-
128118 LaunchedEffect (selectedTabIndex, availableWidth, config.listState, config.tabWidth) {
129119 val centerOffset = (availableWidth - config.tabWidth) / 2
130120 val offsetPx = with (density) { - centerOffset.toPx() }.roundToInt()
@@ -148,7 +138,7 @@ fun TabRow(
148138 Box (Modifier .fillMaxSize()) {
149139 Box (
150140 Modifier
151- .offset { IntOffset ((indicatorOffset.value - scrollOffset).roundToInt(), 0 ) }
141+ .offset { IntOffset (((selectedTabIndex * (tabWidthPx + spacingPx)) - scrollOffset).roundToInt(), 0 ) }
152142 .width(config.tabWidth)
153143 .fillMaxHeight()
154144 .squircleBackground(color = colors.backgroundColor(true ), cornerRadius = config.cornerRadius),
@@ -277,7 +267,7 @@ fun TabRowWithContour(
277267 Box (
278268 modifier = Modifier
279269 .fillMaxSize()
280- .squircleSurface (color = colors.backgroundColor(false ), cornerRadius = outerCornerRadius)
270+ .squircleBackground (color = colors.backgroundColor(false ), cornerRadius = outerCornerRadius)
281271 .padding(contourPadding),
282272 ) {
283273 Box (
@@ -330,11 +320,18 @@ private fun TabItem(
330320 interactionSource : MutableInteractionSource ? = null,
331321 indication : Indication ? = null,
332322) {
323+ val outlineColor = MiuixTheme .colorScheme.outline
333324 Box (
334325 modifier = Modifier
335326 .fillMaxHeight()
336327 .width(width)
337- .squircleClip(cornerRadius)
328+ .squircleBorder(
329+ width = { if (isSelected) 0 .dp else 1 .dp },
330+ color = { outlineColor },
331+ cornerRadius = cornerRadius,
332+ )
333+ // Clip only when an indication is supplied, to skip squircleClip's offscreen layer by default.
334+ .then(if (indication != null ) Modifier .squircleClip(cornerRadius) else Modifier )
338335 .selectable(
339336 selected = isSelected,
340337 onClick = onClick,
@@ -381,7 +378,8 @@ private fun TabItemWithContour(
381378 modifier = Modifier
382379 .fillMaxHeight()
383380 .width(width)
384- .squircleClip(cornerRadius)
381+ // Clip only when an indication is supplied, to skip squircleClip's offscreen layer by default.
382+ .then(if (indication != null ) Modifier .squircleClip(cornerRadius) else Modifier )
385383 .selectable(
386384 selected = isSelected,
387385 onClick = onClick,
0 commit comments