import React, { useState, createContext, useContext } from 'react';
import { View, Text } from 'react-native';
import { ThemeProvider, useT, T, Screen, Scroll, Header, NavBar, Card, Group, Row, Button, Chip, Pill, Checkbox, Toggle, Ring, Bars, Spark, Stat, Avatar, TabBar, Tabs, Stack, Icon, Spacer, SectionTitle } from './ui/kit';
const ACCENT = '#7C5CFF';
const THEME = { dark: { bg: '#0B0B10', card: '#15151C', card2: '#1F1F28', line: '#24242E' }, light: { bg: '#F4F3FA' } };
const HABITS = [
{ id: 1, name: 'Morning stretch', icon: 'Sunrise', color: '#FF9F43', streak: 14, time: '7:00', days: [1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1] },
{ id: 2, name: 'Read 20 pages', icon: 'BookOpen', color: '#4DA3FF', streak: 9, time: '21:30', days: [1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1] },
{ id: 3, name: 'Deep work block', icon: 'Target', color: '#7C5CFF', streak: 21, time: '9:00', days: [1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] },
{ id: 4, name: 'Walk outside', icon: 'Footprints', color: '#30D158', streak: 5, time: '12:30', days: [0,1,1,0,1,0,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,0,1,1,1,1,1,1] },
{ id: 5, name: 'No screens after 10', icon: 'MoonStar', color: '#F2C94C', streak: 3, time: '22:00', days: [1,0,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,1] },
];
const WEEK = [3, 5, 4, 5, 2, 5, 3];
const DAYS = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
const Done = createContext([{}, () => {}]);
function TodayScreen({ nav }) {
const t = useT();
const [done, setDone] = useContext(Done);
const completed = HABITS.filter((h) => done[h.id]).length;
const pct = completed / HABITS.length;
return (
} />
nav.push('week')}>
{Math.round(pct * 100)}%
{completed} of {HABITS.length}
{completed === HABITS.length ? 'All done. Rest well.' : (HABITS.length - completed) + ' to go'}
You are on a 12 day streak. Finish today to keep it alive.
{}} />
{HABITS.map((h) => (
nav.push('habit', { id: h.id })}
right={ setDone((d) => Object.assign({}, d, { [h.id]: !d[h.id] }))} />}
/>
))}
);
}
function StatsScreen() {
const t = useT();
const [range, setRange] = useState('week');
return (
setRange('week')} />
setRange('month')} />
setRange('year')} />
Last 30 days
Trending up
{HABITS.slice().sort((a, b) => b.streak - a.streak).map((h) => (
))}
);
}
function HabitsScreen({ nav }) {
const t = useT();
const [remind, setRemind] = useState({ 1: true, 2: true, 3: true, 4: false, 5: true });
return (
{}} />} />
{HABITS.map((h) => (
nav.push('habit', { id: h.id })} right={ setRemind((r) => Object.assign({}, r, { [h.id]: v }))} />} />
))}
{}} />} />
{}} />
{}} />
);
}
function HabitDetail({ nav, params }) {
const t = useT();
const [done, setDone] = useContext(Done);
const h = HABITS.find((x) => x.id === params.id) || HABITS[0];
const rate = h.days.filter(Boolean).length / h.days.length;
const isDone = !!done[h.id];
return (
} />
{Math.round(rate * 100)}%
completed over the last 28 days
{h.days.map((d, i) => (
{d ? : null}
))}
);
}
function WeekDetail({ nav }) {
const t = useT();
return (
Completed habits
27 of 35
{HABITS.map((h) => (
))}
);
}
function Root({ nav }) {
const [tab, setTab] = useState('today');
return (
, stats: , habits: }} />
);
}
const SCREENS = { root: Root, habit: HabitDetail, week: WeekDetail };
export default function App() {
const state = useState({ 3: true });
return (
);
}