Skip to content

Commit

Permalink
remove unused param from EstimatedProgressIndicatorState
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Mar 4, 2025
1 parent 8b107e1 commit 740ceb2
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,28 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import me.him188.ani.utils.coroutines.SingleTaskExecutor

@Composable
fun rememberEstimatedProgressIndicatorState(
normalHeight: Dp = 4.dp,
initialProgress: Float = 0f,
initialVisible: Boolean = false,
) = rememberSaveable(saver = EstimatedProgressIndicatorState.Saver) {
EstimatedProgressIndicatorState(normalHeight, initialProgress, initialVisible)
EstimatedProgressIndicatorState(initialProgress, initialVisible)
}

@Stable
class EstimatedProgressIndicatorState private constructor(
private val normalHeight: Dp = 4.dp,
initialProgress: Float = 0f,
initialHeightScale: Float = 0f,
) {
constructor(
normalHeight: Dp = 4.dp,
initialProgress: Float = 0f,
initialVisible: Boolean = false,
) : this(normalHeight, initialProgress, initialHeightScale = if (initialVisible) 1f else 0f)
) : this(initialProgress, initialHeightScale = if (initialVisible) 1f else 0f)

var progress by mutableFloatStateOf(initialProgress)
private set
Expand Down Expand Up @@ -119,11 +115,10 @@ class EstimatedProgressIndicatorState private constructor(

companion object {
val Saver = Saver<EstimatedProgressIndicatorState, Any>(
save = { listOf(it.normalHeight.value, it.heightScale, it.progress) },
save = { listOf(it.heightScale, it.progress) },
restore = {
it as List<*>
EstimatedProgressIndicatorState(
normalHeight = (it[0] as Float).dp,
initialProgress = it[2] as Float,
initialHeightScale = it[1] as Float,
)
Expand Down

0 comments on commit 740ceb2

Please sign in to comment.