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
4 changes: 3 additions & 1 deletion app/src/main/assets/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@
"New look": "Novo visual",
"Next": "Próximo",
"Next day": "Próximo dia",
"Next meal idea · {0}": "Ideia para a próxima refeição · {0}",
"Next period around {0} (in {1} day{2}), from your usual {3}-day cycle.": "Próxima menstruação por volta de {0} (em {1} dia{2}), com base no seu ciclo habitual de {3} dias.",
"Next: end date": "Próximo: data de término",
"Night covered by the ring": "Noite registrada pelo anel",
Expand Down Expand Up @@ -1559,7 +1560,7 @@
"Score {0} out of 100": "Pontuação {0} de 100",
"Scores are PulseLoop estimates from ring data compared with the user's own baseline, not medical measurements.": "As pontuações são estimativas do PulseLoop a partir dos dados do anel comparados com a linha de base do próprio usuário, não medidas médicas.",
"Screens in bed": "Telas na cama",
"Screens that have moved to it so far: Today, Vitals, Sleep, Activity, Symptom Radar.": "Telas que já usam o novo visual: Hoje, Vitais, Sono, Atividade, Radar de sintomas.",
"Screens that have moved to it so far: Today, Vitals, Sleep, Activity, Nutrition, My Health, Readiness, Symptom Radar.": "Telas que já usam o novo visual: Hoje, Vitais, Sono, Atividade, Nutrição, Minha saúde, Prontidão, Radar de sintomas.",
"Searching…": "Procurando…",
"See Raw Packets above.": "Veja Pacotes brutos acima.",
"See Ring Events above.": "Veja Eventos do anel acima.",
Expand Down Expand Up @@ -2231,6 +2232,7 @@
"{0} inactive {1} since {2}:00": "{0} {1} sem se mexer desde as {2}:00",
"{0} is paired": "{0} foi pareada",
"{0} is retiring this model on {1}.": "{0} vai descontinuar este modelo em {1}.",
"{0} kcal": "{0} kcal",
"{0} kcal · P {1} · C {2} · F {3}": "{0} kcal · P {1} · C {2} · G {3}",
"{0} lab markers to review": "{0} marcadores de exame para revisar",
"{0} left this week": "Restam {0} esta semana",
Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/com/pulseloop/ui/calm/Look.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.pulseloop.ui.calm

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.pulseloop.ui.theme.PulseColors

/**
* The surface and text roles of whichever look is on, for pieces shared by converted and
* unconverted screens (a section, a fact row, the My Health entry card). Reading [NewLook.on]
* here, not at each call site, keeps the two looks from drifting apart inside one component.
* Delete with the old look: every getter then returns its Calm value.
*/
object Look {
val calm: Boolean get() = NewLook.on
val page: Color get() = if (calm) CalmColors.page else PulseColors.background
val card: Color get() = if (calm) CalmColors.card else PulseColors.card
val border: Color get() = if (calm) CalmColors.border else PulseColors.borderSubtle
val text: Color get() = if (calm) CalmColors.text else PulseColors.textPrimary
val textSecondary: Color get() = if (calm) CalmColors.textSecondary else PulseColors.textSecondary
val textMuted: Color get() = if (calm) CalmColors.textMuted else PulseColors.textMuted
val radius: Dp get() = if (calm) CalmShape.radius else 8.dp
}

/**
* A card in whichever look is on: the radius, the surface and its hairline. [oldBorder] keeps an
* old-look card that never had a hairline exactly as it was; the new look always draws one.
*/
fun Modifier.lookCard(oldBorder: Boolean = true): Modifier {
val shape = RoundedCornerShape(Look.radius)
val base = this.clip(shape).background(Look.card)
return if (Look.calm || oldBorder) base.border(1.dp, Look.border, shape) else base
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/pulseloop/ui/screens/DebugScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fun DebugScreen(viewModel: DiagnosticsViewModel, onBack: () -> Unit = {}) {
) {
Column(Modifier.weight(1f)) {
Text(tr("Try the new look"), style = MaterialTheme.typography.bodyMedium)
Text(tr("Screens that have moved to it so far: Today, Vitals, Sleep, Activity, Symptom Radar."), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
Text(tr("Screens that have moved to it so far: Today, Vitals, Sleep, Activity, Nutrition, My Health, Readiness, Symptom Radar."), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
Switch(checked = com.pulseloop.ui.calm.NewLook.on, onCheckedChange = null)
}
Expand Down
64 changes: 36 additions & 28 deletions app/src/main/java/com/pulseloop/ui/screens/MyHealthUi.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pulseloop.ui.screens

import com.pulseloop.ui.calm.lookCard
import com.pulseloop.ui.i18n.trf
import com.pulseloop.ui.components.PulseButtonStyle
import com.pulseloop.ui.components.PulseButton
Expand Down Expand Up @@ -103,7 +104,8 @@ internal fun Section(
var open by androidx.compose.runtime.saveable.rememberSaveable(title) { mutableStateOf(summary == null) }
val collapsible = summary != null
Column(
Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card).padding(16.dp),
Modifier.fillMaxWidth().then(Modifier.lookCard(oldBorder = false))
.padding(if (com.pulseloop.ui.calm.Look.calm) 20.dp else 16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
content = {
if (collapsible) {
Expand All @@ -114,8 +116,8 @@ internal fun Section(
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(title, style = com.pulseloop.ui.theme.PulseType.title, color = PulseColors.textPrimary)
if (!open) Text(summary!!, fontSize = 12.sp, color = PulseColors.textMuted, maxLines = 2, overflow = TextOverflow.Ellipsis)
Text(title, style = if (com.pulseloop.ui.calm.Look.calm) com.pulseloop.ui.calm.CalmType.title else com.pulseloop.ui.theme.PulseType.title, color = com.pulseloop.ui.calm.Look.text)
if (!open) Text(summary!!, fontSize = if (com.pulseloop.ui.calm.Look.calm) 14.sp else 12.sp, color = com.pulseloop.ui.calm.Look.textMuted, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
val turn by androidx.compose.animation.core.animateFloatAsState(
if (open) 180f else 0f,
Expand All @@ -138,19 +140,21 @@ internal fun Section(
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { content() }
}
} else {
Text(title.uppercase(), style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary)
// In the new look the section's name is its heading, in sentence case.
if (com.pulseloop.ui.calm.Look.calm) Text(title, style = com.pulseloop.ui.calm.CalmType.title, color = com.pulseloop.ui.calm.Look.text)
else Text(title.uppercase(), style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary)
content()
}
},
)
}

@Composable
internal fun Fact(label: String, value: String, note: String? = null, color: Color = PulseColors.textPrimary) {
internal fun Fact(label: String, value: String, note: String? = null, color: Color = com.pulseloop.ui.calm.Look.text) {
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.Top) {
Column(Modifier.weight(1f)) {
Text(label, fontSize = 14.sp, color = PulseColors.textSecondary)
note?.let { Text(it, fontSize = 12.sp, color = PulseColors.textMuted) }
Text(label, fontSize = 14.sp, color = com.pulseloop.ui.calm.Look.textSecondary)
note?.let { Text(it, fontSize = 12.sp, color = com.pulseloop.ui.calm.Look.textMuted) }
}
// Bounded: a translated value ("Moderada · 3h 20m") must not squeeze the label column.
Text(value, fontSize = 16.sp, fontWeight = FontWeight.Bold, color = color, textAlign = TextAlign.End, modifier = Modifier.widthIn(max = 160.dp))
Expand Down Expand Up @@ -201,12 +205,12 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: ()
}
var restUntil by remember { mutableStateOf(RestMode.until(context)) }

Column(Modifier.fillMaxSize().background(PulseColors.background)) {
val calm = com.pulseloop.ui.calm.NewLook.on
// The new look (docs/new-look-plan.md, "My Health"): calm bar, page, gutter, 720dp cap, Inter.
com.pulseloop.ui.calm.CalmTypography(enabled = calm) {
Column(Modifier.fillMaxSize().background(com.pulseloop.ui.calm.Look.page)) {
val shareScope = rememberCoroutineScope()
com.pulseloop.ui.components.PulseTopBar(
title = tr("My Health"),
onBack = onBack,
actions = {
val shareAction: @Composable RowScope.() -> Unit = {
IconButton(
onClick = {
shareScope.launch {
Expand All @@ -222,13 +226,14 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: ()
}
}
},
) { Icon(androidx.compose.material.icons.Icons.Filled.Share, tr("Share my week"), tint = PulseColors.textSecondary) }
},
)
) { Icon(androidx.compose.material.icons.Icons.Filled.Share, tr("Share my week"), tint = com.pulseloop.ui.calm.Look.textSecondary) }
}
if (calm) com.pulseloop.ui.calm.CalmTopBar(tr("My Health"), onBack, shareAction)
else com.pulseloop.ui.components.PulseTopBar(title = tr("My Health"), onBack = onBack, actions = shareAction)
// Lazy: each section composes as it scrolls in, instead of every chart and DB read at once.
androidx.compose.foundation.lazy.LazyColumn(
Modifier.fillMaxSize(),
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp),
if (calm) Modifier.fillMaxSize().wrapContentWidth().widthIn(max = 720.dp).fillMaxWidth() else Modifier.fillMaxSize(),
contentPadding = PaddingValues(horizontal = if (calm) com.pulseloop.ui.calm.CalmShape.gutter else 16.dp, vertical = 8.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
val s = snap
Expand Down Expand Up @@ -263,7 +268,7 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: ()
s.areas.forEach { a ->
Row(verticalAlignment = Alignment.CenterVertically) {
Column(Modifier.weight(1f)) {
Text(a.title, style = com.pulseloop.ui.theme.PulseType.title, color = PulseColors.textPrimary)
Text(a.title, style = if (com.pulseloop.ui.calm.Look.calm) com.pulseloop.ui.calm.CalmType.title else com.pulseloop.ui.theme.PulseType.title, color = com.pulseloop.ui.calm.Look.text)
Text(a.detail, fontSize = 12.sp, color = PulseColors.textSecondary)
}
Text(a.rating.label, fontSize = 14.sp, fontWeight = FontWeight.Bold, color = ratingColor(a.rating), textAlign = TextAlign.End, maxLines = 2, modifier = Modifier.widthIn(max = 120.dp))
Expand All @@ -281,13 +286,14 @@ fun MyHealthScreen(onBack: () -> Unit, onBreathe: () -> Unit, onWhatChanged: ()
item {
Text(
tr("Estimates from your ring compared with your own recent normal, not medical measurements."),
fontSize = 14.sp, color = PulseColors.textSecondary,
fontSize = 14.sp, color = com.pulseloop.ui.calm.Look.textSecondary,
)
}
item { Spacer(Modifier.height(24.dp)) }
}
}
}
}
}

/** A row that opens a deeper My Health screen. */
Expand All @@ -301,14 +307,16 @@ private fun RadarEntryRow(r: SymptomRadar.Result?, restUntil: java.time.LocalDat
else -> r.level.label
} + if (restUntil != null) " · " + tr("Rest Mode on") else ""
Row(
Modifier.fillMaxWidth().heightIn(min = 56.dp).clickable(role = androidx.compose.ui.semantics.Role.Button, onClick = onOpen).padding(vertical = 8.dp),
Modifier.fillMaxWidth().heightIn(min = 56.dp).lookCard()
.clickable(role = androidx.compose.ui.semantics.Role.Button, onClick = onOpen).padding(20.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(tr("Symptom Radar"), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
Text(line, fontSize = 14.sp, color = PulseColors.textSecondary)
// Only shown in the new look (MyHealthScreen), so it speaks it.
Text(tr("Symptom Radar"), style = com.pulseloop.ui.calm.CalmType.title, color = com.pulseloop.ui.calm.CalmColors.text)
Text(line, style = com.pulseloop.ui.calm.CalmType.bodySmall, color = com.pulseloop.ui.calm.CalmColors.textSecondary)
}
com.pulseloop.ui.components.Chevron()
com.pulseloop.ui.components.Chevron(tint = com.pulseloop.ui.calm.CalmColors.textSecondary)
}
}

Expand Down Expand Up @@ -638,15 +646,15 @@ private const val INHALE_MS = 4_000L
@Composable
fun MyHealthEntryCard(title: String, subtitle: String, onClick: () -> Unit) {
Row(
Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card)
.clickable(role = Role.Button, onClick = onClick).padding(16.dp),
Modifier.fillMaxWidth().then(Modifier.lookCard(oldBorder = false))
.clickable(role = Role.Button, onClick = onClick).padding(if (com.pulseloop.ui.calm.Look.calm) 20.dp else 16.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(title, fontSize = 16.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
Text(subtitle, fontSize = 12.sp, color = PulseColors.textMuted)
Text(title, fontSize = 16.sp, fontWeight = if (com.pulseloop.ui.calm.Look.calm) FontWeight.SemiBold else FontWeight.Bold, color = com.pulseloop.ui.calm.Look.text)
Text(subtitle, fontSize = if (com.pulseloop.ui.calm.Look.calm) 14.sp else 12.sp, color = com.pulseloop.ui.calm.Look.textMuted)
}
com.pulseloop.ui.components.Chevron()
com.pulseloop.ui.components.Chevron(tint = com.pulseloop.ui.calm.Look.textMuted)
}
}

Expand Down
Loading
Loading