import { useMemo, type ReactNode } from "react"; import { KeyboardAvoidingView, Pressable, ScrollView, StyleSheet, Text, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useTranslation } from "react-i18next"; import Svg, { Defs, RadialGradient, Rect, Stop } from "react-native-svg"; import { useTheme } from "../../context/ThemeContext"; import { getTypography, type ColorTokens } from "../../theme/tokens"; import { AuthLogo } from "./AuthLogo"; import { LanguageChip } from "./LanguageChip"; import { Reveal } from "./Reveal"; const GLOW_HEIGHT = 420; /** Keeps tappable content out of Android's edge back-gesture zone. */ const SIDE_GUTTER = 28; type Props = { children: ReactNode; footer?: ReactNode; }; /** * Shared frame for sign-in/sign-up: language chip top right, brand block, * then the form anchored to the bottom (thumb zone). Insets are applied by * hand because Android draws edge-to-edge — without them the chip sits under * the status bar and the footer under the gesture bar. Reveal indexes 0–2 * are used here, so the screens' own content starts at 3. */ export function AuthShell({ children, footer }: Props) { const { t } = useTranslation(); const { colors } = useTheme(); const styles = useMemo(() => makeStyles(colors), [colors]); const insets = useSafeAreaInsets(); return ( // "padding" on Android too: edge-to-edge means the window no longer resizes // for the keyboard, so without it the bottom-anchored form stays hidden. PawFeed {t("auth.tagline")} {children} {footer} ); } export function AuthDivider({ label }: { label: string }) { const { colors } = useTheme(); const styles = useMemo(() => makeStyles(colors), [colors]); return ( {label} ); } type FooterLinkProps = { prompt: string; action: string; onPress: () => void }; export function AuthFooterLink({ prompt, action, onPress }: FooterLinkProps) { const { colors } = useTheme(); const styles = useMemo(() => makeStyles(colors), [colors]); return ( {prompt} {action} ); } function makeStyles(colors: ColorTokens) { const typography = getTypography(colors); return StyleSheet.create({ flex: { flex: 1, backgroundColor: colors.porchWhite }, glow: { position: "absolute", top: 0, left: 0 }, container: { flexGrow: 1, paddingHorizontal: SIDE_GUTTER, alignItems: "center" }, // maxWidth keeps a phone-width column on tablets. column: { flexGrow: 1, width: "100%", maxWidth: 420 }, topline: { alignItems: "flex-end" }, brand: { alignItems: "center", marginTop: 16, marginBottom: 32 }, wordmark: { ...typography.display, fontSize: 32, lineHeight: 38 }, tagline: { ...typography.body, color: colors.quietGray, marginTop: 2 }, form: { marginTop: "auto", gap: 10 }, divider: { flexDirection: "row", alignItems: "center", gap: 12, marginVertical: 4 }, dividerLine: { flex: 1, height: StyleSheet.hairlineWidth, backgroundColor: colors.hairlineGray }, dividerText: { ...typography.caption, color: colors.quietGray }, footer: { marginTop: 18, alignSelf: "center" }, footerText: { ...typography.body, color: colors.quietGray }, footerAction: { fontFamily: typography.title.fontFamily, color: colors.marigoldDeep }, }); }