mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-25 18:38:23 +01:00
Migrate deprecated progress indicator components (#10142)
This commit is contained in:
parent
f9fb034330
commit
9ec0f73e87
@ -39,7 +39,7 @@ class ReaderProgressIndicator @JvmOverloads constructor(
|
|||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
TachiyomiTheme {
|
TachiyomiTheme {
|
||||||
CombinedCircularProgressIndicator(progress = progress)
|
CombinedCircularProgressIndicator(progress = { progress })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,16 +37,15 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
* By always rotating we give the feedback to the user that the application isn't 'stuck'.
|
* By always rotating we give the feedback to the user that the application isn't 'stuck'.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun CombinedCircularProgressIndicator(progress: Float) {
|
fun CombinedCircularProgressIndicator(
|
||||||
val animatedProgress by animateFloatAsState(
|
progress: () -> Float,
|
||||||
targetValue = progress,
|
modifier: Modifier = Modifier,
|
||||||
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
|
) {
|
||||||
label = "progress",
|
|
||||||
)
|
|
||||||
AnimatedContent(
|
AnimatedContent(
|
||||||
targetState = progress == 0f,
|
targetState = progress() == 0f,
|
||||||
transitionSpec = { fadeIn() togetherWith fadeOut() },
|
transitionSpec = { fadeIn() togetherWith fadeOut() },
|
||||||
label = "progressState",
|
label = "progressState",
|
||||||
|
modifier = modifier,
|
||||||
) { indeterminate ->
|
) { indeterminate ->
|
||||||
if (indeterminate) {
|
if (indeterminate) {
|
||||||
// Indeterminate
|
// Indeterminate
|
||||||
@ -63,8 +62,13 @@ fun CombinedCircularProgressIndicator(progress: Float) {
|
|||||||
),
|
),
|
||||||
label = "rotation",
|
label = "rotation",
|
||||||
)
|
)
|
||||||
|
val animatedProgress by animateFloatAsState(
|
||||||
|
targetValue = progress(),
|
||||||
|
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
|
||||||
|
label = "progress",
|
||||||
|
)
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
progress = animatedProgress,
|
progress = { animatedProgress },
|
||||||
modifier = Modifier.rotate(rotation),
|
modifier = Modifier.rotate(rotation),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -101,7 +105,7 @@ private fun CombinedCircularProgressIndicatorPreview() {
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(it),
|
.padding(it),
|
||||||
) {
|
) {
|
||||||
CombinedCircularProgressIndicator(progress = progress)
|
CombinedCircularProgressIndicator(progress = { progress })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user