import React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { StatusBar } from "expo-status-bar";
import { useColorScheme } from "nativewind";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "../../components/card";
import { Heading, MutedText } from "../../components/text";
/**
* Which shape an auth screen takes.
*
* `card` is a dialog floated in the middle of the viewport: a title, a
* description, the content and the actions, all inside a bordered panel. It is
* right on a desktop portal and it is what every consumer of these screens has
* always had.
*
* `screen` is the phone shape — heading at the top, content filling the space
* below it, actions at the bottom, no panel. A card on a phone is a panel
* floated over nothing, with its own padding inside the screen's padding, and
* next to a flow built the other way it reads as something from another app.
*
* The default stays `card` so nothing changes for anyone who does not ask.
*/
export type AuthPageLayout = "card" | "screen";
export interface AuthPageProps {
layout?: AuthPageLayout;
title: string;
subtitle?: string | null;
/** Drawn above the title in the card layout, and nowhere in the screen one. */
icon?: React.ReactNode;
/** Top-left of the page, outside the content — a sign-out control, usually. */
corner?: React.ReactNode;
children: React.ReactNode;
footer?: React.ReactNode;
/** Card width. Ignored by the screen layout, which has the whole width. */
maxWidth?: number;
}
export function AuthPage({
layout = "card",
title,
subtitle,
icon,
corner,
children,
footer,
maxWidth = 440,
}: AuthPageProps) {
const { colorScheme } = useColorScheme();
const isDark = colorScheme === "dark";
if (layout === "screen") {
return (
{/* The corner control sits in the 40px above the heading rather
than absolutely over the content, which is where the card
layout puts it. Same row every screen in the flow leaves for a
back control, so the headings all land in the same place. */}
{corner}
{title}
{subtitle ? (
{subtitle}
) : null}
{children}
{footer ? {footer} : null}
);
}
return (
{corner ? {corner} : null}
{icon}
{title}
{subtitle ? (
{subtitle}
) : null}
{children}
{footer ? (
{footer}
) : null}
);
}
export default AuthPage;