import React, { useState, useEffect, createContext, useContext } from 'react';
import { View, Text } from 'react-native';
import { ThemeProvider, useT, T, Screen, Scroll, Header, Card, Group, Row, Button, IconButton, Segmented, Checkbox, Pill, Stat, Ring, Bars, Spark, TabBar, Tabs, Icon, Spacer, SectionTitle, alpha } from './ui/kit';
const ACCENT = '#FF6B5C';
const THEME = { dark: { bg: '#100C0C', card: '#1B1515', card2: '#271E1E', line: '#2C2222' }, light: { bg: '#FBF3F1', card: '#FFFFFF', card2: '#F3E4E1' } };
const MODES = [{ label: 'Focus', value: 25 }, { label: 'Short', value: 5 }, { label: 'Long', value: 15 }];
const TASKS_INIT = [
{ id: 1, title: 'Write the launch post', est: 3, done: 1, tag: 'Writing' },
{ id: 2, title: 'Review pull requests', est: 2, done: 2, tag: 'Code' },
{ id: 3, title: 'Plan Q3 roadmap', est: 4, done: 0, tag: 'Strategy' },
{ id: 4, title: 'Inbox to zero', est: 1, done: 0, tag: 'Admin' },
];
const WEEK = [95, 140, 60, 180, 125, 40, 0];
const DAYS = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
const Store = createContext(null);
function TimerScreen() {
const t = useT();
const { tasks, toggle } = useContext(Store);
const [mode, setMode] = useState(25);
const [left, setLeft] = useState(25 * 60);
const [running, setRunning] = useState(false);
useEffect(() => { setLeft(mode * 60); setRunning(false); }, [mode]);
useEffect(() => {
if (!running) return;
const id = setInterval(() => setLeft((s) => (s > 0 ? s - 1 : 0)), 1000);
return () => clearInterval(id);
}, [running]);
const total = mode * 60;
const mm = Math.floor(left / 60), ss = left % 60;
const current = tasks.find((x) => !x.checked) || tasks[0];
return (
} />
{mm}:{ss < 10 ? '0' + ss : ss}
{running ? 'stay with it' : mode === 25 ? 'ready to focus' : 'take a break'}
{[0, 1, 2, 3].map((i) => )}
{ setLeft(total); setRunning(false); }} size={54} />
setLeft(0)} size={54} />
toggle(current.id)} />
{current.title}
{current.done} of {current.est} sessions ยท {current.tag}
);
}
function TasksScreen() {
const t = useT();
const { tasks, toggle } = useContext(Store);
const open = tasks.filter((x) => !x.checked), done = tasks.filter((x) => x.checked);
return (
{}} />} />
{open.map((x) => (
toggle(x.id)} />} title={x.title} subtitle={x.est + ' sessions planned'} right={} />
))}
{done.length ? : null}
{done.length ? (
{done.map((x) => (
toggle(x.id)} />} title={x.title} titleStyle={{ color: t.text3, textDecorationLine: 'line-through' }} subtitle="Done today" />
))}
) : null}
);
}
function StatsScreen() {
const t = useT();
return (
Interruptions per session
0.8 down from 2.1
);
}
export default function App() {
const [tab, setTab] = useState('timer');
const [tasks, setTasks] = useState(TASKS_INIT);
const toggle = (id) => setTasks((xs) => xs.map((x) => (x.id === id ? Object.assign({}, x, { checked: !x.checked }) : x)));
return (
, tasks: , stats: }} />
);
}