import React, { useState, createContext, useContext } from 'react';
import { View, Text, Pressable } from 'react-native';
import { ThemeProvider, useT, T, Screen, Scroll, Header, NavBar, Card, Group, Row, Button, Segmented, Chip, Pill, Checkbox, Stat, Ring, Bars, Spark, Progress, TabBar, Tabs, Stack, Icon, Spacer, SectionTitle, Gradient, alpha } from './ui/kit';
const ACCENT = '#14B8A6';
const THEME = { dark: { bg: '#060F0E', card: '#0F1C1A', card2: '#172A27', line: '#1A2E2B', text2: '#8FB0AB', text3: '#557270' }, light: { bg: '#EDF6F5', card: '#FFFFFF', card2: '#DAEBE8' } };
const GOALS_INIT = [
{ id: 1, title: 'Run a half marathon', area: 'Health', icon: 'Footprints', c: '#14B8A6', due: 'Oct 2026', progress: 0.62, steps: [['Build to 15 km long run', true], ['Sign up for the Lisbon Half', true], ['Four runs a week for 8 weeks', false], ['Race day', false]], why: 'To prove the knee is back and to spend Sunday mornings outside.' },
{ id: 2, title: 'Ship the side project', area: 'Work', icon: 'Rocket', c: '#6366F1', due: 'Jul 2026', progress: 0.4, steps: [['Landing page', true], ['Core feature', false], ['Ten beta users', false], ['Launch post', false]], why: 'A small thing of my own that people use.' },
{ id: 3, title: 'Read 30 books', area: 'Mind', icon: 'BookOpen', c: '#E8B04B', due: 'Dec 2026', progress: 0.6, steps: [['10 books', true], ['20 books', false], ['30 books', false]], why: 'Fewer feeds, more pages.' },
{ id: 4, title: 'Save $10k', area: 'Money', icon: 'PiggyBank', c: '#FF6B9D', due: 'Dec 2026', progress: 0.54, steps: [['Automate $300 a week', true], ['$5k', true], ['$10k', false]], why: 'Room to say no.' },
{ id: 5, title: 'Learn to surf', area: 'Play', icon: 'Waves', c: '#38BDF8', due: 'Sep 2026', progress: 0.2, steps: [['Five lessons', true], ['Stand up on a green wave', false], ['Own board', false]], why: 'Because it looks like joy.' },
];
const Store = createContext(null);
function GoalsScreen({ nav }) {
const t = useT();
const { goals } = useContext(Store);
const avg = goals.reduce((a, g) => a + g.progress, 0) / goals.length;
const [area, setArea] = useState('All');
const list = goals.filter((g) => area === 'All' || g.area === area);
return (
{Math.round(avg * 100)}%} />
{['All', 'Health', 'Work', 'Mind', 'Money', 'Play'].map((a) => setArea(a)} />)}
{list.map((g) => (
nav.push('goal', { id: g.id })}>
{g.title}
{g.area} · by {g.due} · {g.steps.filter((s) => s[1]).length}/{g.steps.length} milestones
{Math.round(g.progress * 100)}%
))}
);
}
function WeekScreen() {
const t = useT();
const { goals } = useContext(Store);
const [checks, setChecks] = useState({ 0: true, 1: true });
const actions = [['Long run 16 km', 1], ['Write the core feature spec', 2], ['Finish Klara and the Sun', 3], ['Transfer $300', 4], ['Book Saturday lesson', 5], ['Easy run 8 km', 1]];
const n = Object.values(checks).filter(Boolean).length;
return (
} />
{actions.map((a, i) => {
const g = goals.find((x) => x.id === a[1]);
return setChecks((c) => Object.assign({}, c, { [i]: !c[i] }))} />} title={a[0]} subtitle={g.title} titleStyle={checks[i] ? { color: t.text3, textDecorationLine: 'line-through' } : null} right={} />;
})}
);
}
function ReviewScreen() {
const t = useT();
return (
Sunday review
What moved this week?
Three questions, five minutes. Your last 6 reviews are below.
v * 100)} height={100} />
{}} />
{}} />
{}} />
);
}
function GoalDetail({ nav, params }) {
const t = useT();
const { goals, toggleStep } = useContext(Store);
const g = goals.find((x) => x.id === params.id) || goals[0];
return (
} />
{Math.round(g.progress * 100)}%
{g.title}
by {g.due}
Why this matters
{g.why}
{g.steps.map((s, i) => toggleStep(g.id, i)} />} title={s[0]} titleStyle={s[1] ? { color: t.text3, textDecorationLine: 'line-through' } : null} onPress={() => toggleStep(g.id, i)} />)}
);
}
function Root({ nav }) {
const [tab, setTab] = useState('goals');
return (
, week: , review: }} />
);
}
const SCREENS = { root: Root, goal: GoalDetail };
export default function App() {
const [goals, setGoals] = useState(GOALS_INIT);
const toggleStep = (id, i) => setGoals((gs) => gs.map((g) => {
if (g.id !== id) return g;
const steps = g.steps.map((s, j) => (j === i ? [s[0], !s[1]] : s));
return Object.assign({}, g, { steps, progress: steps.filter((s) => s[1]).length / steps.length });
}));
return (
);
}