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
3 changes: 2 additions & 1 deletion app/src/main/assets/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@
"Data Types": "Tipos de dados",
"Data backup": "Backup de dados",
"Data behind this score": "Dados por trás desta pontuação",
"Data source": "Fonte de dados",
"Data stays on device": "Os dados ficam no dispositivo",
"Database": "Banco de dados",
"Day": "Dia",
Expand Down Expand Up @@ -1566,7 +1567,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, 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.",
"Screens that have moved to it so far: Today, Vitals, Sleep, Activity, Nutrition, My Health, Readiness, Symptom Radar, Settings.": "Telas que já usam o novo visual: Hoje, Vitais, Sono, Atividade, Nutrição, Minha saúde, Prontidão, Radar de sintomas, Configurações.",
"Searching…": "Procurando…",
"See Raw Packets above.": "Veja Pacotes brutos acima.",
"See Ring Events above.": "Veja Eventos do anel acima.",
Expand Down
57 changes: 37 additions & 20 deletions app/src/main/java/com/pulseloop/ui/components/DeviceHeroCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import com.pulseloop.ring.RingBLEClient
import com.pulseloop.ring.RingConnectionState
import com.pulseloop.ring.RingDeviceType
import com.pulseloop.ui.theme.PulseColors
import com.pulseloop.ui.calm.Look
import com.pulseloop.ui.calm.lookCard
import com.pulseloop.wearables.WearableModel

/**
Expand Down Expand Up @@ -69,14 +71,13 @@ fun DeviceHeroCard(
idle = bleState.idleSince != null,
)

val calm = Look.calm
Column(
Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(8.dp))
.background(PulseColors.card)
.border(1.dp, PulseColors.borderSubtle, RoundedCornerShape(8.dp))
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
.lookCard()
.padding(if (calm) 20.dp else 16.dp),
verticalArrangement = Arrangement.spacedBy(if (calm) 12.dp else 8.dp),
) {
Row(
Modifier
Expand All @@ -98,7 +99,7 @@ fun DeviceHeroCard(
status.title,
fontSize = 20.sp,
fontWeight = FontWeight.SemiBold,
color = PulseColors.textPrimary,
color = Look.text,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Expand All @@ -113,7 +114,7 @@ fun DeviceHeroCard(
Text(
syncText,
fontSize = 12.sp,
color = PulseColors.textSecondary,
color = Look.textSecondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Expand All @@ -136,7 +137,8 @@ fun DeviceHeroCard(
Row(
Modifier
.clip(CircleShape)
.dither(batteryTone, 0.12f)
// The new look keeps the level's colour on the icon and number only.
.then(if (calm) Modifier.background(com.pulseloop.ui.calm.CalmColors.cardRaised) else Modifier.dither(batteryTone, 0.12f))
.padding(horizontal = 8.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
Expand All @@ -163,7 +165,32 @@ fun DeviceHeroCard(
// Disconnect lives. Setup/reconnect remain available here only when not connected, and
// automatic recovery offers Disconnect so the user can stop it (issue #124).
if (!connected) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
val onAction = {
when (status.action) {
DeviceHeroStatus.Action.CONNECT -> onConnect()
DeviceHeroStatus.Action.SET_UP -> onSetUp()
// Reached while RECONNECTING: stops automatic recovery through
// the same sticky userDisconnect path as the Settings button.
DeviceHeroStatus.Action.DISCONNECT -> onDisconnect()
// Already inert: actionEnabled is false while a connect is in flight.
DeviceHeroStatus.Action.PENDING -> {}
}
}
if (calm) {
// The new look: the calm outlined button across the card (the screen's own action;
// the one filled mint stays the Actions button), not a dithered pill in the corner.
PulseButton(
PulseButtonStyle.Outlined,
onClick = onAction,
enabled = status.actionEnabled,
modifier = Modifier.fillMaxWidth(),
shape = RoundedCornerShape(com.pulseloop.ui.calm.CalmShape.radius),
border = androidx.compose.foundation.BorderStroke(1.dp, Look.border),
colors = androidx.compose.material3.ButtonDefaults.outlinedButtonColors(
contentColor = Look.text, disabledContentColor = Look.textMuted,
),
) { Text(status.actionTitle, fontSize = 16.sp, fontWeight = FontWeight.SemiBold) }
} else Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
Text(
status.actionTitle,
fontSize = 14.sp,
Expand All @@ -173,17 +200,7 @@ fun DeviceHeroCard(
.heightIn(min = 48.dp)
.clip(CircleShape)
.then(if (status.actionEnabled) Modifier.dither(PulseColors.accent, 0.18f) else Modifier.background(PulseColors.elevated))
.clickable(enabled = status.actionEnabled, role = Role.Button) {
when (status.action) {
DeviceHeroStatus.Action.CONNECT -> onConnect()
DeviceHeroStatus.Action.SET_UP -> onSetUp()
// Reached while RECONNECTING: stops automatic recovery through
// the same sticky userDisconnect path as the Settings button.
DeviceHeroStatus.Action.DISCONNECT -> onDisconnect()
// Already inert: actionEnabled is false while a connect is in flight.
DeviceHeroStatus.Action.PENDING -> {}
}
}
.clickable(enabled = status.actionEnabled, role = Role.Button, onClick = onAction)
.padding(horizontal = 12.dp)
.wrapContentHeight(),
)
Expand Down
64 changes: 40 additions & 24 deletions app/src/main/java/com/pulseloop/ui/components/SettingsComponents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.pulseloop.ui.theme.PulseColors
import com.pulseloop.ui.calm.CalmColors
import com.pulseloop.ui.calm.Look
import com.pulseloop.ui.calm.lookCard

/**
* Ported from SettingsComponents.swift (iOS #49).
Expand All @@ -53,28 +56,37 @@ data class SettingsRowItem(
@Composable
fun SettingsSection(title: String, rows: List<SettingsRowItem>) {
if (rows.isEmpty()) return
val calm = Look.calm
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
// The design system's one tracked caps label (PulseType.eyebrow), not a hand-rolled one.
Text(
title.uppercase(),
style = com.pulseloop.ui.theme.PulseType.eyebrow,
color = PulseColors.textSecondary,
modifier = Modifier.padding(start = 16.dp),
)
if (calm) {
// The new look: a sentence-case group name, and none at all when the group's one row
// already says it ("Notifications" over "Notifications" said it twice).
if (!(rows.size == 1 && rows[0].title == title)) {
Text(
title,
fontSize = 14.sp,
fontWeight = FontWeight.SemiBold,
color = Look.textSecondary,
modifier = Modifier.padding(start = 4.dp),
)
}
} else {
// The design system's one tracked caps label (PulseType.eyebrow), not a hand-rolled one.
Text(
title.uppercase(),
style = com.pulseloop.ui.theme.PulseType.eyebrow,
color = PulseColors.textSecondary,
modifier = Modifier.padding(start = 16.dp),
)
}

Column(
Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(8.dp))
.background(PulseColors.card)
.border(1.dp, PulseColors.borderSubtle, RoundedCornerShape(8.dp)),
) {
Column(Modifier.fillMaxWidth().lookCard()) {
rows.forEachIndexed { index, row ->
SettingsRow(row)
if (index < rows.size - 1) {
HorizontalDivider(
color = PulseColors.borderSubtle,
thickness = 0.5.dp,
color = Look.border,
thickness = if (calm) 1.dp else 0.5.dp,
modifier = Modifier.padding(start = 64.dp), // align with the row's text column
)
}
Expand All @@ -83,46 +95,50 @@ fun SettingsSection(title: String, rows: List<SettingsRowItem>) {
}
}

/** A single row: tinted icon in a rounded box, title, optional trailing value, chevron. */
/**
* A single row: icon tile, title, optional trailing value, chevron. The old look tints each tile
* in its own colour; the new look draws one quiet raised tile, since the colours carried no meaning.
*/
@Composable
fun SettingsRow(item: SettingsRowItem) {
val interactionSource = remember { MutableInteractionSource() }
val pressed by interactionSource.collectIsPressedAsState()
val calm = Look.calm

Row(
Modifier
.fillMaxWidth()
.background(if (pressed) PulseColors.elevated else Color.Transparent)
.background(if (pressed) (if (calm) CalmColors.cardRaised else PulseColors.elevated) else Color.Transparent)
.clickable(interactionSource = interactionSource, indication = null, role = Role.Button, onClick = item.action)
.heightIn(min = 52.dp)
.heightIn(min = if (calm) 56.dp else 52.dp)
.padding(horizontal = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
Box(
Modifier
.size(32.dp)
.clip(RoundedCornerShape(4.dp))
.dither(item.tint, 0.14f),
.clip(RoundedCornerShape(if (calm) 8.dp else 4.dp))
.then(if (calm) Modifier.background(CalmColors.cardRaised) else Modifier.dither(item.tint, 0.14f)),
contentAlignment = Alignment.Center,
) {
Icon(item.icon, contentDescription = null, Modifier.size(20.dp), tint = item.tint)
Icon(item.icon, contentDescription = null, Modifier.size(20.dp), tint = if (calm) Look.textSecondary else item.tint)
}

// The title takes the free width (it used to be unweighted beside a weighted Spacer, so a
// long translated title and a long trailing value — a model slug — fought for the row).
Text(
item.title,
fontSize = 16.sp,
color = PulseColors.textPrimary,
color = Look.text,
modifier = Modifier.weight(1f),
)

item.trailingValue?.let { trailing ->
Text(
trailing,
fontSize = 14.sp,
color = PulseColors.textSecondary,
color = Look.textSecondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.widthIn(max = 140.dp),
Expand Down
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, Nutrition, My Health, Readiness, 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, Settings."), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
Switch(checked = com.pulseloop.ui.calm.NewLook.on, onCheckedChange = null)
}
Expand Down
26 changes: 15 additions & 11 deletions app/src/main/java/com/pulseloop/ui/screens/HealthConnectSourceUi.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 @@ -249,22 +250,25 @@ fun HealthConnectSourceHeroCard(onOpen: () -> Unit) {
val context = LocalContext.current
val pkg = HealthConnectSource.sourcePackage(context) ?: return
val last = HealthConnectSource.lastImportAt(context)
// Same frame as the ring's hero card (8dp radius, hairline, chevron), so the hub reads the same
// Same frame as the ring's hero card (radius, hairline, chevron), so the hub reads the same
// whichever source feeds it.
val calm = com.pulseloop.ui.calm.Look.calm
val lastLine = last?.let { trf("Last import {0}", localDateTime(context, it)) } ?: tr("Waiting for the first import")
Row(
Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).background(PulseColors.card)
.border(1.dp, PulseColors.borderSubtle, RoundedCornerShape(8.dp))
.clickable(role = Role.Button, onClick = onOpen).padding(16.dp),
Modifier.fillMaxWidth().lookCard()
.clickable(role = Role.Button, onClick = onOpen).padding(if (calm) 20.dp else 16.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) {
Text(tr("DATA SOURCE"), style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary)
Text(trf("{0} via Health Connect", HealthConnectSource.label(context, pkg)), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
Text(
last?.let { trf("Last import {0}", localDateTime(context, it)) }
?: tr("Waiting for the first import"),
fontSize = 14.sp, color = PulseColors.textSecondary,
)
if (calm) {
// No caps kicker over the name: the name leads, and the line under it says what it is.
Text(trf("{0} via Health Connect", HealthConnectSource.label(context, pkg)), fontSize = 20.sp, fontWeight = FontWeight.SemiBold, color = com.pulseloop.ui.calm.Look.text)
Text(tr("Data source") + " · " + lastLine, fontSize = 14.sp, color = com.pulseloop.ui.calm.Look.textSecondary)
} else {
Text(tr("DATA SOURCE"), style = com.pulseloop.ui.theme.PulseType.eyebrow, color = PulseColors.textSecondary)
Text(trf("{0} via Health Connect", HealthConnectSource.label(context, pkg)), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary)
Text(lastLine, fontSize = 14.sp, color = PulseColors.textSecondary)
}
}
com.pulseloop.ui.components.Chevron()
}
Expand Down
22 changes: 14 additions & 8 deletions app/src/main/java/com/pulseloop/ui/screens/SettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.pulseloop.ui.components.DeviceHeroCard
import com.pulseloop.ui.components.SettingsRowItem
import com.pulseloop.ui.components.SettingsSection
import com.pulseloop.ui.theme.PulseColors
import com.pulseloop.ui.calm.lookCard
import kotlinx.coroutines.flow.map

/**
Expand Down Expand Up @@ -99,11 +100,17 @@ fun SettingsScreen(

// Settings is pushed from the header's gear, so it wears the shared pushed-screen bar
// (centred title + back) like its own sub-screens, instead of a bare headline.
Column(Modifier.fillMaxSize()) {
com.pulseloop.ui.components.PulseTopBar(title = tr("Settings"), onBack = { navController?.popBackStack() })
// The new look (docs/new-look-plan.md, "Settings"): calm bar, page, gutter, 720dp cap, Inter.
val calm = com.pulseloop.ui.calm.NewLook.on
com.pulseloop.ui.calm.CalmTypography(enabled = calm) {
Column(Modifier.fillMaxSize().then(if (calm) Modifier.background(com.pulseloop.ui.calm.CalmColors.page) else Modifier)) {
if (calm) com.pulseloop.ui.calm.CalmTopBar(tr("Settings"), onBack = { navController?.popBackStack() })
else com.pulseloop.ui.components.PulseTopBar(title = tr("Settings"), onBack = { navController?.popBackStack() })
Column(
Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(16.dp),
verticalArrangement = Arrangement.spacedBy(24.dp),
Modifier.fillMaxSize().verticalScroll(rememberScrollState())
.then(if (calm) Modifier.wrapContentWidth().widthIn(max = 720.dp).fillMaxWidth() else Modifier)
.padding(horizontal = if (calm) com.pulseloop.ui.calm.CalmShape.gutter else 16.dp, vertical = if (calm) 8.dp else 16.dp),
verticalArrangement = Arrangement.spacedBy(if (calm) 28.dp else 24.dp),
) {

val hcSource by remember { com.pulseloop.health.source.HealthConnectSource.activeSource(context) }.collectAsState()
Expand All @@ -115,10 +122,8 @@ fun SettingsScreen(
Box(
Modifier
.fillMaxWidth()
.height(160.dp)
.clip(RoundedCornerShape(8.dp))
.background(PulseColors.card)
.border(1.dp, PulseColors.borderSubtle, RoundedCornerShape(8.dp)),
.height(if (calm) 176.dp else 160.dp)
.lookCard(),
)
} else DeviceHeroCard(
bleState = bleState,
Expand Down Expand Up @@ -247,4 +252,5 @@ fun SettingsScreen(
Spacer(Modifier.height(32.dp))
}
}
}
}
Loading
Loading