Skip to content

Instantly share code, notes, and snippets.

View raghunandankavi2010's full-sized avatar
🤵‍♂️
Android dev looking to learn new technologies and always open for a new job.

Raghunandan Kavi raghunandankavi2010

🤵‍♂️
Android dev looking to learn new technologies and always open for a new job.
View GitHub Profile
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(
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
@raghunandankavi2010
raghunandankavi2010 / Swipetodismiss.kt
Created May 14, 2023 10:46
Swipe to dismiss in Lazy Column
@ExperimentalMaterialApi
@Composable
fun Tutorial2_13Screen() {
val viewModel = MyViewModel()
TutorialContent(viewModel)
}
@ExperimentalMaterialApi
@Composable
private fun TutorialContent(viewModel: MyViewModel) {
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
@raghunandankavi2010
raghunandankavi2010 / CircularRowList
Created July 25, 2022 05:55
Circular Row List with scale and alpha using custom Layout
@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)
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
@raghunandankavi2010
raghunandankavi2010 / Animation.kt
Created June 27, 2022 16:36
Animating Progess
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,
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),
@raghunandankavi2010
raghunandankavi2010 / Canva.kt
Created June 27, 2022 14:56
Compose MultiColor
@Composable
fun MultiColorProgressCanvas() {
Canvas(
modifier = Modifier
.height(16.dp)
.fillMaxSize()
) {
}
@raghunandankavi2010
raghunandankavi2010 / CustomProgress.kt
Last active June 22, 2022 10:00
CustomProgress with multi color
@Composable
fun MultiColorProgressCanvas() {
Canvas(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
) {
//draw shapes here
// get canvas width in dp