Something went wrong. Try again.
Effortlessly glide through your todos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176import { useAuth, useUser } from '@clerk/expo';import { router } from 'expo-router';import { SymbolView, type SymbolViewProps } from 'expo-symbols';import { Pressable, StyleSheet, Text, View } from 'react-native';
import { useIsClerkConfigured } from '@/auth/clerk';import { accountInitials, accountShortName } from '@/auth/use-glide-profile';import { Fonts, Spacing } from '@/constants/theme';import { AccountAvatar } from '@/design/account-avatar';import { platformSymbol } from '@/design/symbols';import { useTheme } from '@/hooks/use-theme';import { selectionHaptic } from '@/lib/haptics';
const ROUNDED = Fonts?.rounded;
type AuthMode = 'signIn' | 'signUp';
function openAuth(mode: AuthMode) { router.push({ pathname: './auth', params: { mode } });}
export function AuthControls({ shadowColor }: { shadowColor: string }) { const configured = useIsClerkConfigured(); return configured ? <ClerkAuthControls shadowColor={shadowColor} /> : null;}
function ClerkAuthControls({ shadowColor }: { shadowColor: string }) { const palette = useTheme(); const { isLoaded, isSignedIn } = useAuth();
if (!isLoaded) return null;
if (isSignedIn) { return <AccountButton shadowColor={shadowColor} />; }
return ( <View style={styles.signedOut}> <AuthPill label="Sign in" symbol="person.crop.circle" background={palette.surface} textColor={palette.text} borderColor={palette.border} shadowColor={shadowColor} onPress={() => openAuth('signIn')} /> <AuthPill label="Sign up" symbol="person.badge.plus" background={palette.accent} textColor="#FFFFFF" borderColor={palette.border} shadowColor={shadowColor} onPress={() => openAuth('signUp')} /> </View> );}
/** * The signed-in header control: a compact Glide account button — short display * name plus a circular avatar (the user's photo, or an accent monogram). It * never shows a long email or a square image; tapping opens the Glide-owned * profile sheet. Thick border, rounded type and a hard offset shadow that nudges * in on press, matching the sign-in / sign-up pills it sits in place of. */export function AccountButton({ shadowColor }: { shadowColor: string }) { const palette = useTheme(); const { user } = useUser(); const name = accountShortName(user); const photo = user?.hasImage ? user.imageUrl : null;
return ( <Pressable accessibilityRole="button" accessibilityLabel={`Account: ${name}`} onPressIn={selectionHaptic} onPress={() => router.push('/profile')} style={({ pressed }) => [ styles.account, { backgroundColor: palette.surface, borderColor: palette.border, boxShadow: `${pressed ? 1 : 3}px ${pressed ? 1 : 3}px 0 ${shadowColor}`, transform: [{ translateX: pressed ? 1 : 0 }, { translateY: pressed ? 1 : 0 }], }, ]}> <Text style={[styles.accountText, { color: palette.text }]} numberOfLines={1}> {name} </Text> <AccountAvatar photo={photo} initials={accountInitials(user)} size={28} palette={palette} /> </Pressable> );}
function AuthPill({ label, symbol, background, textColor, borderColor, shadowColor, onPress,}: { label: string; symbol: SymbolViewProps['name']; background: string; textColor: string; borderColor: string; shadowColor: string; onPress: () => void;}) { return ( <Pressable accessibilityRole="button" accessibilityLabel={label} onPressIn={selectionHaptic} onPress={onPress} style={({ pressed }) => [ styles.authPill, { backgroundColor: background, borderColor, boxShadow: `3px 3px 0 ${shadowColor}`, transform: [{ translateX: pressed ? 1 : 0 }, { translateY: pressed ? 1 : 0 }], }, ]}> <SymbolView name={platformSymbol(symbol)} size={14} tintColor={textColor} weight="bold" fallback={null} /> <Text style={[styles.authText, { color: textColor }]}>{label}</Text> </Pressable> );}
const styles = StyleSheet.create({ signedOut: { flexDirection: 'row', alignItems: 'center', gap: Spacing.two, }, authPill: { minHeight: 34, flexDirection: 'row', alignItems: 'center', gap: 6, borderWidth: 2.5, borderRadius: 999, paddingHorizontal: 11, paddingVertical: 6, }, authText: { fontFamily: ROUNDED, fontSize: 13, fontWeight: '800', }, account: { minHeight: 38, maxWidth: 180, flexDirection: 'row', alignItems: 'center', gap: Spacing.two, borderWidth: 2.5, borderRadius: 999, paddingLeft: 14, paddingRight: 6, paddingVertical: 5, }, accountText: { flexShrink: 1, maxWidth: 120, fontFamily: ROUNDED, fontSize: 14, fontWeight: '800', },});