Something went wrong. Try again.
Effortlessly glide through your todos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206import { useAuth } from '@clerk/expo';import { router } from 'expo-router';import { SymbolView } from 'expo-symbols';import { Pressable, StyleSheet, Text, View } from 'react-native';
import { AccountButton } from '@/auth/auth-controls';import { useIsClerkConfigured } from '@/auth/clerk';import { Fonts, Spacing } from '@/constants/theme';import { useGraceDaysLeft, useSubscriptionState } from '@/data/sync/entitlement';import { platformSymbol } from '@/design/symbols';import { useTheme } from '@/hooks/use-theme';import { selectionHaptic } from '@/lib/haptics';
const ROUNDED = Fonts?.rounded;
type Palette = ReturnType<typeof useTheme>;
/** * Header entry into the profile surface (streak grid + account / sync pitch). * * - Signed-in → account button (name + avatar) * - Signed-out / free → compact "You" pill * - Clerk off → still "You" so local-only users can open streak history * * Profile is always available; the paid sync pitch lives *inside* profile so * checking your streak quietly surfaces the subscription, without a hard * paywall gate on this button. */export function SyncEntry({ shadowColor }: { shadowColor: string }) { return <ProfileEntry shadowColor={shadowColor} />;}
export function ProfileEntry({ shadowColor }: { shadowColor: string }) { const configured = useIsClerkConfigured(); if (!configured) return <YouPill shadowColor={shadowColor} />; return <ProfileEntryInner shadowColor={shadowColor} />;}
function ProfileEntryInner({ shadowColor }: { shadowColor: string }) { const { isLoaded, isSignedIn } = useAuth();
if (!isLoaded) return null; if (isSignedIn) return <AccountButton shadowColor={shadowColor} />; return <YouPill shadowColor={shadowColor} />;}
function YouPill({ shadowColor }: { shadowColor: string }) { const palette = useTheme();
return ( <Pressable accessibilityRole="button" accessibilityLabel="You — streak and account" onPressIn={selectionHaptic} onPress={() => router.push('/profile')} style={({ pressed }) => [ styles.youPill, { backgroundColor: palette.surface, borderColor: palette.border, boxShadow: `3px 3px 0 ${shadowColor}`, transform: [{ translateX: pressed ? 1 : 0 }, { translateY: pressed ? 1 : 0 }], }, ]}> <SymbolView name={platformSymbol('person.crop.circle')} size={14} tintColor={palette.text} weight="bold" fallback={null} /> <Text style={[styles.youText, { color: palette.text }]}>You</Text> </Pressable> );}
/** * The Action-screen sync notice for the grace and billing-retry states. A flat, * bordered panel — deliberately NOT a status pill and NOT a hard-shadow task card * (the hard offset shadow is reserved for tactile, actionable task objects; account * messaging sits in a calmer register). Renders nothing when sync is healthy. */export function SyncNotice({ palette }: { palette: Palette }) { const state = useSubscriptionState(); const days = useGraceDaysLeft(); if (state !== 'grace' && state !== 'billing') return null;
const billing = state === 'billing'; const heading = billing ? 'Payment issue' : 'Sync paused'; const body = billing ? 'Update your payment method to keep syncing across your devices.' : `Open Glide on your other devices within ${days} ${days === 1 ? 'day' : 'days'} to pull your latest tasks — after that the cloud copy is removed.`; const action = billing ? 'Update payment' : 'Resubscribe';
return ( <View style={[ styles.notice, { backgroundColor: billing ? palette.resistanceSoft : palette.surface, borderColor: palette.border }, ]}> <SymbolView name={platformSymbol(billing ? 'exclamationmark.triangle.fill' : 'icloud.slash')} size={20} tintColor={billing ? palette.resistance : palette.textSecondary} weight="bold" fallback={null} /> <View style={styles.noticeBody}> <Text style={[styles.noticeHeading, { color: palette.text }]}>{heading}</Text> <Text style={[styles.noticeText, { color: palette.textSecondary }]}>{body}</Text> <Pressable accessibilityRole="button" accessibilityLabel={action} hitSlop={8} onPressIn={selectionHaptic} onPress={() => router.push('/paywall')}> <Text style={[styles.noticeAction, { color: billing ? palette.resistance : palette.accent }]}>{action}</Text> </Pressable> </View> </View> );}
/** * New Task caption: a muted inline note that a written task stays on-device while * sync is paused. Shown only when sync was had-and-lost (grace / billing) — never * for never-paid users, for whom local-only is simply how the app works. */export function LocalOnlyNote() { const palette = useTheme(); const state = useSubscriptionState(); if (state !== 'grace' && state !== 'billing') return null;
return ( <View style={styles.caption}> <SymbolView name={platformSymbol('icloud.slash')} size={13} tintColor={palette.textMuted} weight="semibold" fallback={null} /> <Text style={[styles.captionText, { color: palette.textMuted }]}>Saved on this device — not synced</Text> </View> );}
const styles = StyleSheet.create({ youPill: { minHeight: 34, flexDirection: 'row', alignItems: 'center', gap: 6, borderWidth: 2.5, borderRadius: 999, paddingHorizontal: 14, paddingVertical: 6, }, youText: { fontFamily: ROUNDED, fontSize: 13, fontWeight: '800', }, notice: { flexDirection: 'row', alignItems: 'flex-start', gap: Spacing.three, borderWidth: 2, borderRadius: 16, padding: Spacing.three, }, noticeBody: { flex: 1, gap: 5, }, noticeHeading: { fontFamily: ROUNDED, fontSize: 16, fontWeight: '800', }, noticeText: { fontFamily: ROUNDED, fontSize: 13.5, lineHeight: 19, fontWeight: '600', }, noticeAction: { fontFamily: ROUNDED, fontSize: 14, fontWeight: '800', marginTop: 2, }, caption: { flexDirection: 'row', alignItems: 'center', gap: 6, alignSelf: 'center', marginTop: Spacing.three, }, captionText: { fontFamily: ROUNDED, fontSize: 13, fontWeight: '600', },});