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 Modifier.confetti( | |
// all your parameters to set up the modifier | |
) = composed { // the composed function gives you a composition on each composable where this modifier is used | |
// remeber any state you need here | |
var confettiState by remember { | |
mutableStateOf( | |
ConfettiState( | |
// parameters to setup the state | |
) | |
) |
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
Box(modifier = Modifier | |
.background(Color.Black) | |
.fillMaxSize() | |
.confetti() | |
) { | |
Text("Hello World", color = Color.Red) | |
} |
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 | |
fun GlitterBox( | |
rainbow: List<Color> = SkittlesRainbow, | |
fleckCount: Int = 2, | |
visible: Boolean = true | |
) { | |
var size by remember { mutableStateOf(Size.Zero) } | |
var source by remember { mutableStateOf(Offset(200f, 200f)) } | |
var glitterState by remember { |
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 | |
fun HeartPulse(modifier: Modifier = Modifier) { | |
val infiniteTransition = rememberInfiniteTransition() | |
val heartSize by infiniteTransition.animateFloat( | |
initialValue = 0.5f, | |
targetValue = 1.5f, | |
animationSpec = infiniteRepeatable( | |
animation = tween(1000, easing = FastOutSlowInEasing), | |
repeatMode = RepeatMode.Reverse |
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 | |
fun Heart(modifier: Modifier = Modifier, color: Color = Color.Red, size: Dp = 100.dp) { | |
Surface( | |
shape = HeartShape, | |
color = color, | |
modifier = modifier | |
.height(size) | |
.width(size) | |
) { |
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
// Thank You https://mahendranv.github.io/posts/compose-shapes-gists/ | |
val HeartShape = GenericShape { size, _ -> | |
val h = size.height | |
val w = size.width | |
lineTo(0.5f*w, 0.25f*h) | |
cubicTo(0.5f*w, 0.225f*h, 0.458333333333333f*w, 0.125f*h, 0.291666666666667f*w, 0.125f*h) | |
cubicTo(0.0416666666666667f*w, 0.125f*h, 0.0416666666666667f*w, 0.4f*h, 0.0416666666666667f*w, 0.4f*h) | |
cubicTo(0.0416666666666667f*w, 0.583333333333333f*h, 0.208333333333333f*w, 0.766666666666667f*h, 0.5f*w, 0.916666666666667f*h) | |
cubicTo(0.791666666666667f*w, 0.766666666666667f*h, 0.958333333333333f*w, 0.583333333333333f*h, 0.958333333333333f*w, 0.4f*h) | |
cubicTo(0.958333333333333f*w, 0.4f*h, 0.958333333333333f*w, 0.125f*h, 0.708333333333333f*w, 0.125f*h) |
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 | |
fun rainbowState( | |
rainbow: List<Color> = SkittlesRainbow, | |
duration: Int = 3000 | |
): State<Color> { | |
val infiniteTransition = rememberInfiniteTransition() | |
val interval = duration / rainbow.size | |
return infiniteTransition.animateColor( | |
initialValue = rainbow[0], | |
targetValue = rainbow.last(), |
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 | |
fun LifeSaver(rainbow: List<Color> = SkittlesRainbow) { | |
val color by rainbowState(rainbow = rainbow, duration = 2000) | |
val highlight by rainbowState(PastelRainbow, 2000) | |
val infiniteTransition = rememberInfiniteTransition() | |
val arcAngle1 by infiniteTransition.animateFloat( | |
initialValue = 0F, | |
targetValue = 180F, | |
animationSpec = infiniteRepeatable( | |
animation = tween(5000, easing = LinearEasing), |
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 | |
fun CursorVisible(content: @Composable () -> Unit) { | |
val boxSize = 100.dp | |
val boxPx = with(LocalDensity.current) { boxSize.toPx() } | |
var offset by remember { mutableStateOf(Offset(0f, 0f)) } | |
var visible by remember { mutableStateOf(false) } | |
Box(modifier = Modifier | |
.fillMaxSize() | |
.pointerInput(Unit) { | |
detectTapGestures { |
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
apply plugin: 'jacoco' | |
jacoco { | |
toolVersion = "0.8.2" | |
// Custom reports directory can be specfied like this: | |
// reportsDir = file("$buildDir/customJacocoReportDir") | |
} | |
project.afterEvaluate { |
NewerOlder