All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.github.lyxnx.compose.pine.ProgressBar.kt Maven / Gradle / Ivy

package io.github.lyxnx.compose.pine

import androidx.annotation.FloatRange
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

/**
 * A Pine Theme progress bar
 *
 * A progress bar displays the progress of an action and as such does not have an indeterminate state - use the
 * indeterminate overload of [ProgressCircle] instead.
 *
 * @param fraction the fractional amount the progress bar is filled (will be coerced into 0..1)
 * @param modifier modifier to apply to the progress bar
 * @param trackColor color of the progress track
 * @param barColor color of the progress bar
 */
@Composable
public fun ProgressBar(
    @FloatRange(from = 0.0, to = 1.0) fraction: Float,
    modifier: Modifier = Modifier,
    trackColor: Color = PineTheme.colors.grey200,
    barColor: Color = PineTheme.colors.primary500
) {
    Box(
        modifier = modifier
            .fillMaxWidth()
            .height(4.dp)
            .clip(CircleShape)
            .background(trackColor)
    ) {
        Box(
            Modifier
                .fillMaxWidth(fraction.coerceIn(0f, 1f))
                .fillMaxHeight()
                .clip(CircleShape)
                .background(barColor)
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy