import React, { useState, useEffect } from 'react';
import { View, Text, Pressable } from 'react-native';
import { ThemeProvider, useT, T, Screen, Scroll, Header, NavBar, Card, Group, Row, Button, Segmented, Chip, Pill, Stat, Bars, Spark, Progress, TabBar, Tabs, Stack, Icon, Spacer, SectionTitle, Gradient, alpha } from './ui/kit';
const ACCENT = '#FB923C';
const THEME = { dark: { bg: '#0F0A06', card: '#1B140E', card2: '#291E15', line: '#2E231A', text2: '#B4A090', text3: '#75655A' }, light: { bg: '#FBF3EC', card: '#FFFFFF', card2: '#F3E2D4' } };
const RUNS = [
{ id: 1, name: 'Morning intervals', when: 'Today', km: 5.2, time: '26:32', pace: '5:06', kcal: 312, splits: [5.2, 5.07, 4.97, 5.14, 4.86], elev: 42 },
{ id: 2, name: 'Easy river loop', when: 'Sun', km: 8.1, time: '44:50', pace: '5:32', kcal: 480, splits: [5.6, 5.5, 5.5, 5.4, 5.6, 5.5, 5.4, 5.3], elev: 18 },
{ id: 3, name: 'Long run', when: 'Fri', km: 15.0, time: '1:22:10', pace: '5:28', kcal: 890, splits: [5.5, 5.4, 5.5, 5.4, 5.3, 5.5, 5.4, 5.6, 5.4, 5.3, 5.5, 5.4, 5.3, 5.2, 5.1], elev: 120 },
{ id: 4, name: 'Tempo', when: 'Wed', km: 6.0, time: '28:48', pace: '4:48', kcal: 360, splits: [5.1, 4.8, 4.7, 4.7, 4.8, 4.7], elev: 30 },
];
const WEEKKM = [6, 0, 8.1, 0, 15, 8.1, 5.2];
const DAYS = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
const paceOf = (m) => Math.floor(m) + ':' + (Math.round((m % 1) * 60) < 10 ? '0' : '') + Math.round((m % 1) * 60);
function RunScreen({ nav }) {
const t = useT();
const [state, setState] = useState('ready');
const [sec, setSec] = useState(0);
useEffect(() => { if (state !== 'running') return; const id = setInterval(() => setSec((s) => s + 1), 1000); return () => clearInterval(id); }, [state]);
const km = sec * 0.0032;
const mm = Math.floor(sec / 60), ss = sec % 60;
return (
} />
{[[60, 70], [140, 40], [250, 62], [300, 130], [120, 150]].map((p, i) => )}
{km.toFixed(2)}
kilometres
{mm}:{ss < 10 ? '0' + ss : ss}time
{km > 0.05 ? paceOf(sec / 60 / km) : '--:--'}pace /km
{state === 'running' ? 152 : 68}bpm
{state === 'ready' ? : null}
{state === 'running' ? : null}
{state === 'paused' ? : null}
{state !== 'ready' ? : null}
{RUNS.slice(0, 3).map((r) => nav.push('run', { id: r.id })} />)}
);
}
function StatsScreen({ nav }) {
const t = useT();
const [range, setRange] = useState('week');
const total = WEEKKM.reduce((a, b) => a + b, 0);
return (
Average pace, 10 weeks
5:18 30 s faster
-v)} height={90} style={{ marginTop: 8 }} />
nav.push('run', { id: 3 })} />
);
}
function PlanScreen() {
const t = useT();
const plan = [['Mon', 'Rest', '', t.text3], ['Tue', 'Intervals', '6 × 800 m', ACCENT], ['Wed', 'Easy', '6 km', '#22C55E'], ['Thu', 'Tempo', '5 km at 4:50', '#A78BFA'], ['Fri', 'Rest', '', t.text3], ['Sat', 'Long run', '16 km', '#38BDF8'], ['Sun', 'Recovery', '5 km easy', '#22C55E']];
return (
} />
Training block9 of 18 weeks
Goal 1:52:00 · predicted 1:54:30 at current fitness
{plan.map((p) => {p[0]}} title={p[1]} subtitle={p[2]} right={p[0] === 'Tue' ? : } />)}
);
}
function RunDetail({ nav, params }) {
const t = useT();
const r = RUNS.find((x) => x.id === params.id) || RUNS[0];
const best = Math.min(...r.splits);
return (
} />
{r.splits.map((s, i) => (
km {i + 1}
{paceOf(s)}
))}
);
}
function Root({ nav }) {
const [tab, setTab] = useState('run');
return (
, stats: , plan: }} />
);
}
const SCREENS = { root: Root, run: RunDetail };
export default function App() {
return (
);
}