curated2: !29
This commit is contained in:
commit
67871fe66d
19 files changed
+86
-3
No files matched your search
@@ -15,6 +15,7 @@ import ErrorBoundary from './components/ErrorBoundary.jsx'
|
||||
import Modals from './components/Modals.jsx'
|
||||
import Toast from './components/Toast.jsx'
|
||||
import RestTimer from './components/RestTimer.jsx'
|
||||
import TimerFlash from './components/TimerFlash.jsx'
|
||||
import Login from './views/Login.jsx'
|
||||
import MobileOnboarding from './views/MobileOnboarding.jsx'
|
||||
import Home from './views/Home.jsx'
|
||||
@@ -103,6 +104,7 @@ function Shell() {
|
||||
<RestTimer />
|
||||
<Modals />
|
||||
<Toast />
|
||||
<TimerFlash />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { useUI } from '../store/useUI.js'
|
||||
|
||||
// A new key restarts the CSS sequence even when two timers finish close together.
|
||||
// The layer never catches taps and ends transparent, so it can safely stay mounted.
|
||||
export default function TimerFlash() {
|
||||
const id = useUI(s => s.timerFlashId)
|
||||
return id ? <div key={id} className="timer-flash" aria-hidden="true" /> : null
|
||||
}
|
||||
@@ -757,6 +757,19 @@ h4.sec{
|
||||
.glyph-cell:active{transform:scale(.92)}
|
||||
.glyph-cell.on{background:var(--acc);color:var(--on-acc)}
|
||||
|
||||
/* --- opt-in timer completion flash ---
|
||||
Four deliberate pulses over 2.4s stay below three flashes per second. Transparent
|
||||
gaps keep the black and white pulses visually distinct. */
|
||||
.timer-flash{
|
||||
position:fixed;inset:0;z-index:1000;pointer-events:none;opacity:0;
|
||||
animation:timer-flash-four 2.4s linear both;
|
||||
}
|
||||
@keyframes timer-flash-four{
|
||||
0%,20%,28%,48%,56%,76%,84%,100%{opacity:0}
|
||||
4%,16%,60%,72%{background:#000;opacity:1}
|
||||
32%,44%,88%,96%{background:#fff;opacity:1}
|
||||
}
|
||||
|
||||
/* --- big weight readout --- */
|
||||
.bwstep{display:flex;align-items:center;justify-content:center;gap:18px;margin:14px 0 6px}
|
||||
.bw-pm{
|
||||
|
||||
@@ -300,6 +300,7 @@ export default {
|
||||
'Weight unit': 'Gewichtseinheit',
|
||||
'Rest timer': 'Pausen-Timer',
|
||||
'Sounds': 'Töne',
|
||||
'Flash screen when timer ends': 'Bildschirm bei Timer-Ende blinken lassen',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Hinweis: Der Einheitenwechsel ändert nur die Beschriftung — eingetragene Zahlen werden nicht umgerechnet.',
|
||||
'Data': 'Daten',
|
||||
'Export backup (JSON)': 'Backup exportieren (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'Unidad de peso',
|
||||
'Rest timer': 'Temporizador de descanso',
|
||||
'Sounds': 'Sonidos',
|
||||
'Flash screen when timer ends': 'Hacer parpadear la pantalla al finalizar el temporizador',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: cambiar la unidad solo cambia la etiqueta — los números registrados no se convierten.',
|
||||
'Data': 'Datos',
|
||||
'Export backup (JSON)': 'Exportar copia (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'Unité de poids',
|
||||
'Rest timer': 'Minuteur de repos',
|
||||
'Sounds': 'Sons',
|
||||
'Flash screen when timer ends': 'Faire clignoter l’écran à la fin du minuteur',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Note : changer d’unité ne change que l’étiquette — les nombres enregistrés ne sont pas convertis.',
|
||||
'Data': 'Données',
|
||||
'Export backup (JSON)': 'Exporter une sauvegarde (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'वज़न की इकाई',
|
||||
'Rest timer': 'आराम टाइमर',
|
||||
'Sounds': 'ध्वनियाँ',
|
||||
'Flash screen when timer ends': 'टाइमर खत्म होने पर स्क्रीन फ्लैश करें',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'नोट: इकाई बदलने से केवल लेबल बदलता है — दर्ज संख्याएँ परिवर्तित नहीं होतीं।',
|
||||
'Data': 'डेटा',
|
||||
'Export backup (JSON)': 'बैकअप निर्यात करें (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'Unità di peso',
|
||||
'Rest timer': 'Timer di riposo',
|
||||
'Sounds': 'Suoni',
|
||||
'Flash screen when timer ends': 'Fai lampeggiare lo schermo alla fine del timer',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: cambiare unità cambia solo l’etichetta — i numeri registrati non vengono convertiti.',
|
||||
'Data': 'Dati',
|
||||
'Export backup (JSON)': 'Esporta backup (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': '무게 단위',
|
||||
'Rest timer': '휴식 타이머',
|
||||
'Sounds': '소리',
|
||||
'Flash screen when timer ends': '타이머 종료 시 화면 깜박임',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': '참고: 단위 변경은 표기만 바꿉니다 — 기록된 숫자는 환산되지 않아요.',
|
||||
'Data': '데이터',
|
||||
'Export backup (JSON)': '백업 내보내기 (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'Jednostka wagi',
|
||||
'Rest timer': 'Minutnik przerwy',
|
||||
'Sounds': 'Dźwięki',
|
||||
'Flash screen when timer ends': 'Migaj ekranem po zakończeniu minutnika',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Uwaga: zmiana jednostki zmienia tylko etykietę — zapisane liczby nie są przeliczane.',
|
||||
'Data': 'Dane',
|
||||
'Export backup (JSON)': 'Eksportuj kopię (JSON)',
|
||||
|
||||
@@ -93,6 +93,7 @@ export const PT_BR_OVERRIDES = {
|
||||
'Create passkey profile': 'Criar perfil com chave de acesso',
|
||||
'synced with your profile': 'sincronizado com seu perfil',
|
||||
'The screen stays on while a workout is running, so you don’t have to unlock your phone between sets.': 'A tela permanece ligada durante o treino, para você não precisar desbloquear o celular entre as séries.',
|
||||
'Flash screen when timer ends': 'Piscar a tela quando o temporizador terminar',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Observação: trocar a unidade altera somente o rótulo — os valores registrados não são convertidos.',
|
||||
'Export backup (JSON)': 'Exportar backup (JSON)',
|
||||
'Import backup': 'Importar backup',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'Unidade de peso',
|
||||
'Rest timer': 'Temporizador de descanso',
|
||||
'Sounds': 'Sons',
|
||||
'Flash screen when timer ends': 'Piscar o ecrã quando o temporizador terminar',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Nota: mudar a unidade só muda o rótulo — os números registados não são convertidos.',
|
||||
'Data': 'Dados',
|
||||
'Export backup (JSON)': 'Exportar cópia (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'Единица веса',
|
||||
'Rest timer': 'Таймер отдыха',
|
||||
'Sounds': 'Звуки',
|
||||
'Flash screen when timer ends': 'Мигать экраном по окончании таймера',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Примечание: смена единиц меняет только подпись — записанные числа не пересчитываются.',
|
||||
'Data': 'Данные',
|
||||
'Export backup (JSON)': 'Экспорт резервной копии (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': 'Ağırlık birimi',
|
||||
'Rest timer': 'Dinlenme sayacı',
|
||||
'Sounds': 'Sesler',
|
||||
'Flash screen when timer ends': 'Zamanlayıcı bitince ekranı yanıp söndür',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': 'Not: birim değiştirmek sadece etiketi değiştirir — kayıtlı sayılar dönüştürülmez.',
|
||||
'Data': 'Veriler',
|
||||
'Export backup (JSON)': 'Yedeği dışa aktar (JSON)',
|
||||
|
||||
@@ -286,6 +286,7 @@ export default {
|
||||
'Weight unit': '重量单位',
|
||||
'Rest timer': '休息计时',
|
||||
'Sounds': '声音',
|
||||
'Flash screen when timer ends': '计时结束时闪烁屏幕',
|
||||
'Note: switching units only changes the label — logged numbers are not converted.': '注意:切换单位只改变标签——已记录的数字不会换算。',
|
||||
'Data': '数据',
|
||||
'Export backup (JSON)': '导出备份(JSON)',
|
||||
|
||||
@@ -9,7 +9,7 @@ import { loadRemote, chooseLocal, forgetRemote, connect } from '../lib/remote.js
|
||||
|
||||
const KEY = 'gym_state_v1'
|
||||
export const DEF = {
|
||||
unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, keepAwake: true, lang: 'en',
|
||||
unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, timerFlash: false, keepAwake: true, lang: 'en',
|
||||
theme: 'dark', accent: 'lime', body: 'male', targetW: null,
|
||||
bodyweight: [], routines: [], week: {}, dayPlan: {},
|
||||
exWeights: {}, workouts: [], active: null, customEx: [], gifSize: 'full',
|
||||
|
||||
@@ -59,6 +59,12 @@ export const useUI = create((set, get) => ({
|
||||
timer: null, // rest countdown between sets — { left, total, endsAt, forIdx }
|
||||
// forIdx: index of the active entry whose set started the rest (undefined when unknown)
|
||||
work: null, // work countdown DURING a timed set (issue #16) — { left, total, endsAt, label }
|
||||
timerFlashId: 0, // changing the id remounts the four-pulse visual alert
|
||||
|
||||
flashTimer() {
|
||||
if (!useStore.getState().S.timerFlash) return
|
||||
set(s => ({ timerFlashId: s.timerFlashId + 1 }))
|
||||
},
|
||||
|
||||
openSheet(render, { kind = 'sheet', locked = false } = {}) {
|
||||
const id = uid()
|
||||
@@ -92,7 +98,7 @@ export const useUI = create((set, get) => ({
|
||||
const snd = useStore.getState().S.sound
|
||||
if (left <= 0) {
|
||||
beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)
|
||||
vibrate([200, 100, 200]); maybeRestNotification(); get().toast(t('Rest over — next set!')); get().stopRest(); return
|
||||
vibrate([200, 100, 200]); get().flashTimer(); maybeRestNotification(); get().toast(t('Rest over — next set!')); get().stopRest(); return
|
||||
}
|
||||
if (left <= 3) beep(snd, 660, 0.1)
|
||||
set({ timer: { ...tm, left } })
|
||||
@@ -147,7 +153,7 @@ export const useUI = create((set, get) => ({
|
||||
const snd = useStore.getState().S.sound
|
||||
if (left <= 0) {
|
||||
beep(snd, 880, 0.15); beep(snd, 880, 0.15, 0.25); beep(snd, 1320, 0.4, 0.5)
|
||||
vibrate([200, 100, 200])
|
||||
vibrate([200, 100, 200]); get().flashTimer()
|
||||
const done = workDone
|
||||
get().stopWork()
|
||||
if (done) done(wk.total)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// useUI pulls in api.js, which reads navigator.userAgent at module scope.
|
||||
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest'
|
||||
import { useUI } from './useUI.js'
|
||||
import { useStore } from './useStore.js'
|
||||
|
||||
// "Off" has to hold at the timer itself, not at the four places that start one — the same
|
||||
// reason the rest-after-a-set rule is a shared condition rather than four copies.
|
||||
@@ -26,3 +27,41 @@ describe('rest timer set to Off', () => {
|
||||
expect(useUI.getState().timer.total).toBe(90)
|
||||
})
|
||||
})
|
||||
|
||||
describe('opt-in timer screen flash', () => {
|
||||
let originalSettings
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers()
|
||||
originalSettings = useStore.getState().S
|
||||
useStore.setState({ S: { ...originalSettings, sound: false, timerFlash: false } })
|
||||
useUI.setState({ timer: null, work: null, timerFlashId: 0 })
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
useUI.getState().stopRest()
|
||||
useUI.getState().stopWork()
|
||||
useStore.setState({ S: originalSettings })
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it('stays off unless enabled in Settings', () => {
|
||||
useUI.getState().startRest(1)
|
||||
vi.advanceTimersByTime(1000)
|
||||
expect(useUI.getState().timerFlashId).toBe(0)
|
||||
})
|
||||
|
||||
it('flashes when the rest timer finishes', () => {
|
||||
useStore.setState({ S: { ...useStore.getState().S, timerFlash: true } })
|
||||
useUI.getState().startRest(1)
|
||||
vi.advanceTimersByTime(1000)
|
||||
expect(useUI.getState().timerFlashId).toBe(1)
|
||||
})
|
||||
|
||||
it('flashes when a timed exercise finishes', () => {
|
||||
useStore.setState({ S: { ...useStore.getState().S, timerFlash: true } })
|
||||
useUI.getState().startWork(1, 'Plank', vi.fn())
|
||||
vi.advanceTimersByTime(1000)
|
||||
expect(useUI.getState().timerFlashId).toBe(1)
|
||||
})
|
||||
})
|
||||
@@ -148,6 +148,9 @@ export default function Settings() {
|
||||
<Row icon="bell" iconTint="var(--pink)" title={t('Sounds')}>
|
||||
<Switch checked={!!S.sound} onChange={v => update(s => { s.sound = v })} />
|
||||
</Row>
|
||||
<Row icon="sun" iconTint="var(--yellow)" title={t('Flash screen when timer ends')}>
|
||||
<Switch checked={!!S.timerFlash} onChange={v => update(s => { s.timerFlash = v })} />
|
||||
</Row>
|
||||
{/* Two names for the same judgement, so the column asks in the scale you already think in.
|
||||
The (i) sits before the control — you read it on the way to the choice, not after it. */}
|
||||
<Row icon="target" iconTint="var(--purple)" title={t('Effort per set')}>
|
||||
|
||||
Reference in new issue
Block a user