mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-26 02:24:31 +01:00
Gradient Animated
This commit is contained in:
parent
7725bc8602
commit
758fe62254
@ -19,6 +19,7 @@ package com.shabinder.common.uikit.utils
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.animation.core.TweenSpec
|
import androidx.compose.animation.core.TweenSpec
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@ -68,11 +69,17 @@ fun Modifier.verticalGradientScrim(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var height by remember { mutableStateOf(fixedHeight ?: 1f) }
|
var height by remember { mutableStateOf(fixedHeight ?: 1f) }
|
||||||
val brush = remember(color, numStops, startYPercentage, endYPercentage, height) {
|
val scrimHeight by animateFloatAsState(
|
||||||
|
// Whenever the target value changes, new animation
|
||||||
|
// will start to the new target value
|
||||||
|
targetValue = height,
|
||||||
|
animationSpec = tween(durationMillis = 1500)
|
||||||
|
)
|
||||||
|
val brush = remember(color, numStops, startYPercentage, endYPercentage, scrimHeight) {
|
||||||
Brush.verticalGradient(
|
Brush.verticalGradient(
|
||||||
colors = colors,
|
colors = colors,
|
||||||
startY = height * startYPercentage,
|
startY = scrimHeight * startYPercentage,
|
||||||
endY = height * endYPercentage
|
endY = scrimHeight * endYPercentage
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user