composed Modifier changes (#9631)
Referring at the examples and other internal usages, the resulting stateful Modifier should be separated from all the previous Modifier chain.
This commit is contained in:
parent
6808fbbb21
commit
25b0458930
@ -245,7 +245,7 @@ private fun Modifier.commonClickable(
|
|||||||
) = composed {
|
) = composed {
|
||||||
val haptic = LocalHapticFeedback.current
|
val haptic = LocalHapticFeedback.current
|
||||||
|
|
||||||
this.combinedClickable(
|
Modifier.combinedClickable(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
onLongClick()
|
onLongClick()
|
||||||
|
@ -113,7 +113,7 @@ internal fun Modifier.highlightBackground(highlighted: Boolean): Modifier = comp
|
|||||||
tween(200)
|
tween(200)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
then(Modifier.background(color = highlight))
|
Modifier.background(color = highlight)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val TrailingWidgetBuffer = 16.dp
|
internal val TrailingWidgetBuffer = 16.dp
|
||||||
|
@ -29,20 +29,21 @@ import tachiyomi.presentation.core.components.Pill
|
|||||||
private fun Modifier.tabIndicatorOffset(
|
private fun Modifier.tabIndicatorOffset(
|
||||||
currentTabPosition: TabPosition,
|
currentTabPosition: TabPosition,
|
||||||
currentPageOffsetFraction: Float,
|
currentPageOffsetFraction: Float,
|
||||||
) = composed {
|
) = fillMaxWidth()
|
||||||
val currentTabWidth by animateDpAsState(
|
.wrapContentSize(Alignment.BottomStart)
|
||||||
targetValue = currentTabPosition.width,
|
.composed {
|
||||||
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
val currentTabWidth by animateDpAsState(
|
||||||
)
|
targetValue = currentTabPosition.width,
|
||||||
val offset by animateDpAsState(
|
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
||||||
targetValue = currentTabPosition.left + (currentTabWidth * currentPageOffsetFraction),
|
)
|
||||||
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
val offset by animateDpAsState(
|
||||||
)
|
targetValue = currentTabPosition.left + (currentTabWidth * currentPageOffsetFraction),
|
||||||
fillMaxWidth()
|
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
||||||
.wrapContentSize(Alignment.BottomStart)
|
)
|
||||||
.offset { IntOffset(x = offset.roundToPx(), y = 0) }
|
Modifier
|
||||||
.width(currentTabWidth)
|
.offset { IntOffset(x = offset.roundToPx(), y = 0) }
|
||||||
}
|
.width(currentTabWidth)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TabIndicator(
|
fun TabIndicator(
|
||||||
|
@ -25,13 +25,13 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent
|
|||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import tachiyomi.presentation.core.components.material.SecondaryItemAlpha
|
import tachiyomi.presentation.core.components.material.SecondaryItemAlpha
|
||||||
|
|
||||||
fun Modifier.selectedBackground(isSelected: Boolean): Modifier = composed {
|
fun Modifier.selectedBackground(isSelected: Boolean): Modifier = if (isSelected) {
|
||||||
if (isSelected) {
|
composed {
|
||||||
val alpha = if (isSystemInDarkTheme()) 0.16f else 0.22f
|
val alpha = if (isSystemInDarkTheme()) 0.16f else 0.22f
|
||||||
background(MaterialTheme.colorScheme.secondary.copy(alpha = alpha))
|
Modifier.background(MaterialTheme.colorScheme.secondary.copy(alpha = alpha))
|
||||||
} else {
|
|
||||||
this
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Modifier.secondaryItemAlpha(): Modifier = this.alpha(SecondaryItemAlpha)
|
fun Modifier.secondaryItemAlpha(): Modifier = this.alpha(SecondaryItemAlpha)
|
||||||
@ -40,7 +40,7 @@ fun Modifier.clickableNoIndication(
|
|||||||
onLongClick: (() -> Unit)? = null,
|
onLongClick: (() -> Unit)? = null,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
): Modifier = composed {
|
): Modifier = composed {
|
||||||
this.combinedClickable(
|
Modifier.combinedClickable(
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
indication = null,
|
indication = null,
|
||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
|
Loading…
Reference in New Issue
Block a user