Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1127,3 +1127,18 @@ clutter came from ignoring one of them:
Settings row (Drinks used to be one).
- **A goal saved anywhere goes through `GoalSync.afterManualSave`** — it is what stops the field
following the coach, sends the step goal to the ring and republishes the widget.

## Motion: one transition, a small vocabulary

- **Every navigation destination goes through `DitherTransitionBox`** (`theme/DitherTransition.kt`),
via `screen(...)` / `paddedComposable(...)` in `PulseLoopApp`. A new route registered with a bare
`composable(...)` skips the wipe and pops in. The wipe draws *both* screens from one Bayer mask
(incoming keeps the swept cells, outgoing keeps the rest), because the navigator puts the
outgoing screen on top for a back press; a reveal drawn only on the incoming screen would be
hidden there. NavHost's own fade (0.99 alpha) exists only to keep both screens composed for
`DURATION_MS`. Fairy mode uses a smooth gradient, like every other dither.
- **In-screen motion uses `theme/Motion.kt`**: `sweepIn` for rings, gauges and bars (fill from empty
on first show, glide between values) and `pressScale` for tappable cards. Collapsible sections
expand with `AnimatedVisibility`. Prefer these over one-off specs, so the app moves one way.
- All of it runs on Compose's clock, which honours the system "Remove animations" setting; don't
drive motion from a hand-rolled `delay` loop that would ignore it.
30 changes: 23 additions & 7 deletions app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.pulseloop.ui.theme.DitherTransitionBox
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.pulseloop.AppServices
Expand Down Expand Up @@ -388,7 +389,13 @@ fun PulseLoopApp() {
Scaffold(
containerColor = com.pulseloop.ui.theme.PulseColors.background,
floatingActionButton = {
if (showLogFab) {
// Pops in on the tabs that have it and out on the ones that don't, rather than
// blinking with the screen change.
androidx.compose.animation.AnimatedVisibility(
visible = showLogFab,
enter = androidx.compose.animation.scaleIn() + androidx.compose.animation.fadeIn(),
exit = androidx.compose.animation.scaleOut() + androidx.compose.animation.fadeOut(),
) {
ExtendedFloatingActionButton(
onClick = { LaunchRequests.openLog.value = com.pulseloop.ui.screens.LogStep.MENU },
icon = { Icon(Icons.Filled.Add, contentDescription = null) },
Expand Down Expand Up @@ -585,17 +592,26 @@ fun PulseLoopApp() {
route: String,
content: @Composable (androidx.navigation.NavBackStackEntry) -> Unit,
) = composable(route) { entry ->
Box(Modifier.fillMaxSize().padding(padding)) { content(entry) }
DitherTransitionBox { Box(Modifier.fillMaxSize().padding(padding)) { content(entry) } }
}
// Every destination takes part in the dither wipe (theme/DitherTransition.kt).
fun androidx.navigation.NavGraphBuilder.screen(
route: String,
content: @Composable (androidx.navigation.NavBackStackEntry) -> Unit,
) = composable(route) { entry -> DitherTransitionBox { content(entry) } }
NavHost(
navController = navController,
startDestination = "today",
modifier = Modifier.hazeSource(hazeState),
enterTransition = { com.pulseloop.ui.theme.DitherTransition.enter },
exitTransition = { com.pulseloop.ui.theme.DitherTransition.exit },
popEnterTransition = { com.pulseloop.ui.theme.DitherTransition.enter },
popExitTransition = { com.pulseloop.ui.theme.DitherTransition.exit },
) {
composable("today") { TodayScreen(navController, todayVM, coordinator, vitalsVM, sleepVM, topBarPadding = topPad, bottomBarPadding = tabPad) }
composable("vitals") { VitalsScreen(navController = navController, viewModel = vitalsVM, coordinator = coordinator, topBarPadding = topPad, bottomBarPadding = tabPad) }
composable("sleep") { SleepScreen(navController = navController, viewModel = sleepVM, onOpen = { coordinator.syncSleepNow() }, topBarPadding = topPad, bottomBarPadding = tabPad) }
composable("activity") { ActivityScreen(navController = navController, viewModel = activityVM, liveWorkout = liveWorkout, topBarPadding = topPad, bottomBarPadding = tabPad) }
screen("today") { TodayScreen(navController, todayVM, coordinator, vitalsVM, sleepVM, topBarPadding = topPad, bottomBarPadding = tabPad) }
screen("vitals") { VitalsScreen(navController = navController, viewModel = vitalsVM, coordinator = coordinator, topBarPadding = topPad, bottomBarPadding = tabPad) }
screen("sleep") { SleepScreen(navController = navController, viewModel = sleepVM, onOpen = { coordinator.syncSleepNow() }, topBarPadding = topPad, bottomBarPadding = tabPad) }
screen("activity") { ActivityScreen(navController = navController, viewModel = activityVM, liveWorkout = liveWorkout, topBarPadding = topPad, bottomBarPadding = tabPad) }
paddedComposable("activity_detail/{id}") { backStackEntry ->
val id = backStackEntry.arguments?.getString("id") ?: return@paddedComposable
WorkoutSummaryScreen(sessionId = id, onBack = { navController.popBackStack() })
Expand All @@ -612,7 +628,7 @@ fun PulseLoopApp() {
}
// Coach draws full-bleed under the glass top/bottom bars (like the other tabs), so
// the chat frosts under its header and the composer can clear the keyboard itself.
composable("coach") {
screen("coach") {
CoachScreen(
navController = navController,
viewModel = coachVM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ fun ActivityRings(
val name = labels.getOrNull(i) ?: trf("ring {0}", i + 1)
if (ring.value == null) trf("{0} unavailable", name) else "$name ${(ring.progress * 100).toInt()}%"
}.joinToString(", ")
// Each ring fills from empty on first show, then glides to new totals.
val shown = rings.map { com.pulseloop.ui.theme.sweepIn(it.progress.toFloat()) }
Canvas(modifier.size(size).clearAndSetSemantics { contentDescription = description }) {
val strokePx = strokeWidth.toPx()
val spacingPx = ringSpacing.toPx()
Expand Down Expand Up @@ -90,7 +92,7 @@ fun ActivityRings(
style = stroke,
)
// Progress arc from 12 o'clock, clockwise.
val sweep = (360.0 * ring.progress).toFloat()
val sweep = 360f * shown[index]
if (sweep > 0f) {
drawArc(
color = ring.color,
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/pulseloop/ui/components/TodayTiles.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pulseloop.ui.components

import com.pulseloop.ui.theme.pressScale
import com.pulseloop.ui.i18n.trf

import com.pulseloop.ui.i18n.tr
Expand Down Expand Up @@ -108,16 +109,18 @@ fun TodayTile(
content: @Composable ColumnScope.() -> Unit,
) {
val shape = RoundedCornerShape(TodayTileMetrics.corner)
val press = remember { androidx.compose.foundation.interaction.MutableInteractionSource() }
Column(
modifier = modifier
.pressScale(press)
// A floor, not a fixed height — see [TodayTileMetrics.minHeight]. The grid row measures
// its tiles with IntrinsicSize.Min and stretches both to match, so this grows to fit
// whatever the tile actually contains instead of clipping it.
.heightIn(min = TodayTileMetrics.minHeight)
.clip(shape)
.background(PulseColors.card)
.border(1.dp, PulseColors.borderSubtle, shape)
.then(if (onTap != null) Modifier.clickable(onClick = onTap) else Modifier)
.then(if (onTap != null) Modifier.clickable(interactionSource = press, indication = androidx.compose.foundation.LocalIndication.current, onClick = onTap) else Modifier)
.padding(12.dp),
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ fun VitalRingGauge(
return ((v - domain.start) / span).coerceIn(0.0, 1.0)
}

// The marker sweeps up from the bottom of the scale on first show, then glides between readings.
val shownValue = com.pulseloop.ui.theme.sweepIn(value.toFloat(), from = domain.start.toFloat()).toDouble()
// One spoken summary for the whole gauge (value, unit, status), plus its position on the scale.
val description = listOfNotNull(centerValue, centerUnit, centerStatus, subtitle).joinToString(" ")
Box(
Expand Down Expand Up @@ -152,7 +154,7 @@ fun VitalRingGauge(
zones.lastOrNull()?.let { drawRoundTip(tipCenter(1.0), 1.0, strokePx, it.colorToken.toColor().copy(alpha = 0.32f)) }

// Value arc from the start up to the current value (rounded leading tip looks intentional).
val valueFraction = fraction(value)
val valueFraction = fraction(shownValue)
if (valueFraction > 0) {
drawArc(
color = valueColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private fun ProgressRing(
stroke: androidx.compose.ui.unit.Dp = 9.dp,
center: @Composable () -> Unit,
) {
val progress = if (max <= 0) 0f else (value / max).coerceIn(0.0, 1.0).toFloat()
val progress = com.pulseloop.ui.theme.sweepIn(if (max <= 0) 0f else (value / max).coerceIn(0.0, 1.0).toFloat())
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(size)) {
androidx.compose.foundation.Canvas(Modifier.fillMaxSize()) {
val strokePx = stroke.toPx()
Expand Down
66 changes: 41 additions & 25 deletions app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.animation.togetherWith
import com.pulseloop.data.PulseLoopDatabase
import com.pulseloop.data.entity.DrinkEntryEntity
import com.pulseloop.service.DrinkPrefs
Expand Down Expand Up @@ -77,32 +78,47 @@ fun LogSheet(
Modifier.fillMaxWidth().verticalScroll(rememberScrollState()).padding(horizontal = 16.dp).padding(bottom = 32.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
when (step) {
LogStep.MENU -> {
Text(tr("Log"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
SheetOption(tr("Meal"), tr("Photo, barcode or by hand"), Icons.Filled.Restaurant) { step = LogStep.MEAL }
SheetOption(tr("Drink"), tr("One tap for the usual ones"), Icons.Filled.LocalBar) { step = LogStep.DRINK }
SheetOption(tr("Medication or supplement"), tr("Mark today's doses"), Icons.Filled.Medication, onMeds)
SheetOption(tr("Period"), tr("Started or ended today, or a past one"), Icons.Filled.WaterDrop, onPeriod)
SheetOption(tr("Tag your day"), tr("Alcohol, stress, a late meal…"), Icons.Filled.LocalOffer) { step = LogStep.TAGS }
SheetOption(tr("Workout"), tr("Start one now"), Icons.Filled.DirectionsRun, onWorkout)
}
LogStep.MEAL -> {
Text(tr("Log a meal"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
SheetOption(tr("Photo"), tr("Snap your plate; the AI estimates it"), Icons.Filled.CameraAlt) { onMeal("photo") }
SheetOption(tr("Barcode"), tr("Scan a packaged food"), Icons.Filled.QrCodeScanner) { onMeal("barcode") }
SheetOption(tr("Add by hand"), tr("Type the name and calories"), Icons.Filled.Add) { onMeal("add") }
// Each step slides in from the side it was reached from, so the sheet reads as one
// place with pages rather than a panel that blinks.
androidx.compose.animation.AnimatedContent(
targetState = step,
transitionSpec = {
val forward = targetState != LogStep.MENU
(androidx.compose.animation.fadeIn(androidx.compose.animation.core.tween(220)) +
androidx.compose.animation.slideInHorizontally(androidx.compose.animation.core.tween(220)) { w -> if (forward) w / 6 else -w / 6 }) togetherWith
androidx.compose.animation.fadeOut(androidx.compose.animation.core.tween(150))
},
label = "logStep",
) { shownStep ->
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
when (shownStep) {
LogStep.MENU -> {
Text(tr("Log"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
SheetOption(tr("Meal"), tr("Photo, barcode or by hand"), Icons.Filled.Restaurant) { step = LogStep.MEAL }
SheetOption(tr("Drink"), tr("One tap for the usual ones"), Icons.Filled.LocalBar) { step = LogStep.DRINK }
SheetOption(tr("Medication or supplement"), tr("Mark today's doses"), Icons.Filled.Medication, onMeds)
SheetOption(tr("Period"), tr("Started or ended today, or a past one"), Icons.Filled.WaterDrop, onPeriod)
SheetOption(tr("Tag your day"), tr("Alcohol, stress, a late meal…"), Icons.Filled.LocalOffer) { step = LogStep.TAGS }
SheetOption(tr("Workout"), tr("Start one now"), Icons.Filled.DirectionsRun, onWorkout)
}
LogStep.MEAL -> {
Text(tr("Log a meal"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
SheetOption(tr("Photo"), tr("Snap your plate; the AI estimates it"), Icons.Filled.CameraAlt) { onMeal("photo") }
SheetOption(tr("Barcode"), tr("Scan a packaged food"), Icons.Filled.QrCodeScanner) { onMeal("barcode") }
SheetOption(tr("Add by hand"), tr("Type the name and calories"), Icons.Filled.Add) { onMeal("add") }
}
LogStep.DRINK -> QuickDrinks(db, onMoreDrinks)
LogStep.TAGS -> JournalTagsCard(db, java.time.LocalDate.now(), tr("Tag your day"), allowYesterday = true) {
Text(
tr("See what affects you"),
fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent,
modifier = Modifier
.heightIn(min = 48.dp)
.clickable(role = Role.Button, onClick = onSeeEffects)
.wrapContentHeight(Alignment.CenterVertically),
)
}
}
LogStep.DRINK -> QuickDrinks(db, onMoreDrinks)
LogStep.TAGS -> JournalTagsCard(db, java.time.LocalDate.now(), tr("Tag your day"), allowYesterday = true) {
Text(
tr("See what affects you"),
fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = PulseColors.accent,
modifier = Modifier
.heightIn(min = 48.dp)
.clickable(role = Role.Button, onClick = onSeeEffects)
.wrapContentHeight(Alignment.CenterVertically),
)
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -112,9 +113,16 @@ internal fun Section(
Text(title, fontSize = 15.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
if (!open) Text(summary!!, fontSize = 12.sp, color = PulseColors.textMuted, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
Text(if (open) "⌃" else "⌄", fontSize = 18.sp, color = PulseColors.textMuted)
val turn by androidx.compose.animation.core.animateFloatAsState(if (open) 180f else 0f, label = "chevron")
Text("⌄", fontSize = 18.sp, color = PulseColors.textMuted, modifier = Modifier.graphicsLayer { rotationZ = turn })
}
androidx.compose.animation.AnimatedVisibility(
visible = open,
enter = androidx.compose.animation.expandVertically() + androidx.compose.animation.fadeIn(),
exit = androidx.compose.animation.shrinkVertically() + androidx.compose.animation.fadeOut(),
) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { content() }
}
if (open) content()
} else {
Text(title.uppercase(), fontSize = 11.sp, letterSpacing = 1.6.sp, color = PulseColors.textMuted)
content()
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/pulseloop/ui/screens/ReadinessUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ fun ScoreRing(
centerText: String = value?.toString() ?: "—",
centerSize: Int = 22,
) {
// Fills from empty on first show and counts the number up with it.
val shown = com.pulseloop.ui.theme.sweepIn((value ?: 0).coerceIn(0, 100).toFloat())
val text = if (value != null && centerText == value.toString()) shown.roundToInt().toString() else centerText
Box(
Modifier.size(size).clearAndSetSemantics {
// One spoken value instead of a bare number; an empty ring says so.
Expand All @@ -109,16 +112,16 @@ fun ScoreRing(
color = PulseColors.borderStrong, startAngle = 135f, sweepAngle = 270f, useCenter = false,
topLeft = Offset(inset, inset), size = arcSize, style = Stroke(w, cap = StrokeCap.Round),
)
if (value != null && value > 0) {
if (value != null && shown > 0f) {
drawArc(
color = color, startAngle = 135f, sweepAngle = 270f * (value.coerceIn(0, 100) / 100f),
color = color, startAngle = 135f, sweepAngle = 270f * (shown / 100f),
useCenter = false, topLeft = Offset(inset, inset), size = arcSize,
style = Stroke(w, cap = StrokeCap.Round),
)
}
}
Text(
centerText, fontSize = centerSize.sp, fontWeight = FontWeight.SemiBold,
text, fontSize = centerSize.sp, fontWeight = FontWeight.SemiBold,
color = if (value != null) PulseColors.textPrimary else PulseColors.textMuted,
)
}
Expand Down
Loading
Loading