Files
petfeed/mobile/src/components/auth/AuthShell.tsx
T
adminandClaude Opus 5.5 53e1af5196 feat(mobile): Login und Registrierung neu gestaltet (Logo, Animationen, Android-Gesten)
- Gemeinsamer AuthShell: Logo + Wortmarke oben, Sprach-Chip mit Menü,
  Formular unten in der Daumenzone, Apple/Google unter "oder weiter mit"
- Animationen mit eingebautem Animated (OTA-fähig): Logo federt rein,
  gestaffeltes Einblenden, Fokusrahmen, Ladekringel, Wackeln bei Fehler;
  respektiert "Bewegung reduzieren"
- Android: Safe-Area für Status- und Gestenleiste, Seitenrand außerhalb der
  Zurück-Wischzone, Sprachmenü als Modal (Zurück schließt nur das Menü),
  KeyboardAvoidingView auch auf Android (Edge-to-Edge)
- Registrierung: Google/Apple nicht mehr ausgegraut; ohne Zustimmung
  markiert ein Tipp die Checkbox und zeigt einen Hinweis

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 06:33:27 +02:00

119 lines
4.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.
<KeyboardAvoidingView style={styles.flex} behavior="padding">
<Svg style={styles.glow} width="100%" height={GLOW_HEIGHT} pointerEvents="none">
<Defs>
<RadialGradient id="authGlow" cx="50%" cy="15%" rx="75%" ry="85%">
<Stop offset="0" stopColor={colors.marigoldTint} stopOpacity="1" />
<Stop offset="1" stopColor={colors.marigoldTint} stopOpacity="0" />
</RadialGradient>
</Defs>
<Rect width="100%" height="100%" fill="url(#authGlow)" />
</Svg>
<ScrollView
contentContainerStyle={[styles.container, { paddingTop: insets.top + 8, paddingBottom: insets.bottom + 24 }]}
keyboardShouldPersistTaps="handled"
>
<View style={styles.column}>
<Reveal index={0} style={styles.topline}>
<LanguageChip />
</Reveal>
<View style={styles.brand}>
<AuthLogo />
<Reveal index={1}>
<Text style={styles.wordmark}>PawFeed</Text>
</Reveal>
<Reveal index={2}>
<Text style={styles.tagline}>{t("auth.tagline")}</Text>
</Reveal>
</View>
<View style={styles.form}>{children}</View>
{footer}
</View>
</ScrollView>
</KeyboardAvoidingView>
);
}
export function AuthDivider({ label }: { label: string }) {
const { colors } = useTheme();
const styles = useMemo(() => makeStyles(colors), [colors]);
return (
<View style={styles.divider}>
<View style={styles.dividerLine} />
<Text style={styles.dividerText}>{label}</Text>
<View style={styles.dividerLine} />
</View>
);
}
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 (
<Pressable onPress={onPress} hitSlop={12} style={styles.footer} accessibilityRole="link">
<Text style={styles.footerText}>
{prompt} <Text style={styles.footerAction}>{action}</Text>
</Text>
</Pressable>
);
}
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 },
});
}