🤵♂️
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(greyAnimate,yellowAnimate,redAnimate,greenAnimate,redAnimate) { | |
launch { | |
greenAnimate.animateTo( | |
targetValue = 1f, | |
animationSpec = tween(durationMillis = 3000, easing = LinearEasing)) | |
yellowAnimate.animateTo( | |
targetValue = 1f, | |
animationSpec = tween(durationMillis = 3000, easing = LinearEasing)) | |
redAnimate.animateTo( |
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
package com.example.composelearning.graphics | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.AnimationVector1D | |
import androidx.compose.animation.core.tween | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.clickable | |
import androidx.compose.foundation.gestures.detectTapGestures | |
import androidx.compose.foundation.layout.BoxWithConstraints |
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
@ExperimentalMaterialApi | |
@Composable | |
fun Tutorial2_13Screen() { | |
val viewModel = MyViewModel() | |
TutorialContent(viewModel) | |
} | |
@ExperimentalMaterialApi | |
@Composable | |
private fun TutorialContent(viewModel: MyViewModel) { |
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
package com.example.composelearning.lists | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.FloatSpringSpec | |
import androidx.compose.animation.core.Spring | |
import androidx.compose.animation.core.calculateTargetValue | |
import androidx.compose.animation.splineBasedDecay | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.gestures.awaitFirstDown | |
import androidx.compose.foundation.gestures.horizontalDrag |
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
@Stable | |
interface CircularRowState { | |
val horizontalOffset: Float | |
val firstVisibleItem: Int | |
val lastVisibleItem: Int | |
val scaleX: Float | |
val scaleY: Float | |
val alphaValue: Float | |
suspend fun snapTo(value: Float) |
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 canvasWidth = size.width.toDp() | |
// calculate the progress for each color | |
val progressGreen = 40 | |
val greenSize = (canvasWidth * progressGreen) / 100 | |
val progressYellow = 20 | |
val yellowSize = (canvasWidth * progressYellow) / 100 | |
val progressRed = 15 | |
val redSize = (canvasWidth * progressRed) / 100 | |
val progressGray = 5 | |
val graySize = (canvasWidth * progressGray) / 100 |
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(greyAnimate,yellowAnimate,redAnimate,greenAnimate,redAnimate) { | |
launch { | |
greenAnimate.animateTo( | |
targetValue = 1f, | |
animationSpec = tween(durationMillis = 3000, easing = LinearEasing)) | |
yellowAnimate.animateTo( | |
targetValue = 1f, | |
animationSpec = tween(durationMillis = 3000, easing = LinearEasing)) | |
redAnimate.animateTo( | |
targetValue = 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
drawRect( | |
color = Color(0xFFFEC93E), | |
topLeft = Offset(greenSize.toPx(), 0f), | |
size = Size(yellowSize.toPx(), 8.dp.toPx()) | |
) | |
//draw red progress with offset = yellow progress + green progress | |
drawRect( | |
color = Color(0xFFED5554), | |
topLeft = Offset(greenSize.toPx() + yellowSize.toPx(), 0f), |
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 MultiColorProgressCanvas() { | |
Canvas( | |
modifier = Modifier | |
.height(16.dp) | |
.fillMaxSize() | |
) { | |
} |
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 MultiColorProgressCanvas() { | |
Canvas( | |
modifier = Modifier | |
.fillMaxSize() | |
.padding(16.dp) | |
) { | |
//draw shapes here | |
// get canvas width in dp |
NewerOlder