This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun Toolbar(scroll: ScrollState, headerHeightPx: Float, toolbarHeightPx: Float) { | |
val toolbarBottom = headerHeightPx - toolbarHeightPx | |
val showToolbar by remember { | |
derivedStateOf { scroll.value >= toolbarBottom } | |
} | |
AnimatedVisibility( | |
visible = showToolbar, | |
enter = fadeIn(animationSpec = tween(300)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val titleXFirstInterpolatedPoint = lerp( | |
titlePaddingStart, | |
(titlePaddingEnd - titleExtraStartPadding) * 5 / 4, | |
collapseFraction | |
) | |
val titleXSecondInterpolatedPoint = lerp( | |
(titlePaddingEnd - titleExtraStartPadding) * 5 / 4, | |
titlePaddingEnd - titleExtraStartPadding, | |
collapseFraction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val titleExtraStartPadding = titleWidthPx.toDp() * (1 - scaleXY.value) / 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun Title(scroll: ScrollState, headerHeightPx: Float, toolbarHeightPx: Float) { | |
var titleHeightPx by remember { mutableStateOf(0f) } | |
val titleHeightDp = with(LocalDensity.current) { titleHeightPx.toDp() } | |
Text( | |
text = "New York", | |
fontSize = 30.sp, | |
fontWeight = FontWeight.Bold, | |
modifier = Modifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private const val titleFontScaleStart = 1f | |
private const val titleFontScaleEnd = 0.66f | |
@Composable | |
private fun Title(scroll: ScrollState, headerHeightPx: Float, toolbarHeightPx: Float) { | |
val collapseRange: Float = (headerHeightPx - toolbarHeightPx) | |
val collapseFraction: Float = (scroll.value / collapseRange).coerceIn(0f, 1f) | |
val scaleXY = lerp( | |
titleFontScaleStart.dp, | |
titleFontScaleEnd.dp, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
. | |
Text( | |
text = "New York", | |
fontSize = 30.sp, | |
fontWeight = FontWeight.Bold, | |
modifier = Modifier | |
.graphicsLayer { | |
val collapseRange: Float = (headerHeightPx - toolbarHeightPx) | |
val collapseFraction: Float = (scroll.value / collapseRange).coerceIn(0f, 1f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
. | |
Text( | |
text = "New York", | |
fontSize = 30.sp, | |
fontWeight = FontWeight.Bold, | |
modifier = Modifier | |
.graphicsLayer { | |
translationY = titleY.toPx() | |
translationX = titleX.toPx() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val titleY = lerp( | |
titleYFirstInterpolatedPoint, | |
titleYSecondInterpolatedPoint, | |
collapseFraction | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val titleX = lerp( | |
titleXFirstInterpolatedPoint, | |
titleXSecondInterpolatedPoint, | |
collapseFraction | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val titleXSecondInterpolatedPoint = lerp( | |
titlePaddingEnd * 5 / 4, | |
titlePaddingEnd, | |
collapseFraction | |
) |
NewerOlder