Composables
Docs Login
Tally

Recent Days

Jetpack Compose Component

Download
package com.composables.tally.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
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.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.unit.dp
import com.composables.tally.theme.Theme

@Composable
fun RecentDays(days: List<Boolean>, color: Color, modifier: Modifier = Modifier) {
    Row(
        modifier.clearAndSetSemantics {
            contentDescription = "${days.count { it }} of the last ${days.size} days done"
        },
        horizontalArrangement = Arrangement.spacedBy(4.dp),
    ) {
        days.forEach { done ->
            Box(
                Modifier.size(14.dp)
                    .clip(Theme.shapes.fullyRounded)
                    .background(if (done) color else Theme.colors.surfaceVariant)
            )
        }
    }
}

More components from Tally

by Alex Styl

Search screens and components

Screen flows

Screens

UI Elements