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 infiniteWidthConstraints = constraints.copy(maxWidth = Int.MAX_VALUE) | |
var mainText = subcompose(MarqueeLayers.MainText) { | |
createText(Modifier) | |
}.first().measure(infiniteWidthConstraints) |
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
LaunchedEffect(textLayoutInfoState.value) { | |
// textLayoutInfoState is only calculated if the text overflows | |
// its parent, if it doesn't, there's no need for the animation | |
val textLayoutInfo = textLayoutInfoState.value ?: return@LaunchedEffect | |
if (textLayoutInfo.textWidth <= textLayoutInfo.containerWidth) return@LaunchedEffect | |
// 7500 * 200 / 100 = 15s -- 2x container width | |
// 7500 * 500 / 250 = 15s -- 2x container width | |
// 7500 * 300 / 100 = 22.5s -- 3x container width | |
// 7500 * 110 / 100 = 8.25s -- 1.1x container width |
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
var offset by remember { mutableStateOf(0) } | |
val textLayoutInfoState = remember { mutableStateOf<TextLayoutInfo?>(null) } |
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 createText = @Composable { localModifier: Modifier -> | |
Text( | |
text = text, | |
textAlign = textAlign, | |
modifier = localModifier, | |
color = color, | |
fontSize = fontSize, | |
fontStyle = fontStyle, | |
fontWeight = fontWeight, | |
fontFamily = fontFamily, |
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
fun MarqueeText( | |
text: String, | |
modifier: Modifier = Modifier, | |
gradientEdgeColor: Color = Color.White, | |
color: Color = Color.Unspecified, | |
fontSize: TextUnit = TextUnit.Unspecified, | |
fontStyle: FontStyle? = null, | |
fontWeight: FontWeight? = null, | |
fontFamily: FontFamily? = null, | |
letterSpacing: TextUnit = TextUnit.Unspecified, |
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 verticalScroll = rememberScrollState() | |
val horizontalScroll = rememberScrollState() | |
Row( | |
modifier = Modifier.horizontalScroll(horizontalScroll) | |
) { | |
... // Oct/22, Sep/22, ... | |
} | |
Column( |
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
class SemiOvalShape : Shape by GenericShape(builder = { size, _ -> | |
lineTo(size.width, 0f) | |
relativeLineTo(0f, size.height * 0.8f) | |
cubicTo( | |
x1 = size.width * .7f, | |
y1 = size.height, | |
x2 = size.width * .3f, | |
y2 = size.height, | |
x3 = 0f, | |
y3 = size.height * 0.8f |
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 HomeHeader( | |
... | |
) { | |
Box { | |
val density = LocalDensity.current | |
// How big the curved section of the box is | |
val backgroundBottomPadding = 96.dp | |
// How much spacing you have between the content inside your box and the content placed below it | |
val bottomSpacer = 16.dp |