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>
This commit is contained in:
1 parent
c474cd64ed
commit
53e1af5196
16 files changed
+786
-190
No files matched your search
+102
-73
@@ -1,14 +1,16 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { View, Text, Pressable, StyleSheet, KeyboardAvoidingView, ScrollView, Platform } from "react-native";
|
||||
import { Animated, Text, StyleSheet, Platform } from "react-native";
|
||||
import { useSignIn } from "@clerk/expo";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "../../src/components/Button";
|
||||
import { TextField } from "../../src/components/TextField";
|
||||
import { PasswordField } from "../../src/components/PasswordField";
|
||||
import { LanguageSwitcher } from "../../src/components/LanguageSwitcher";
|
||||
import { KeyRound, Lock, Mail } from "lucide-react-native";
|
||||
import { GoogleSignInButton } from "../../src/components/GoogleSignInButton";
|
||||
import { AppleSignInButton } from "../../src/components/AppleSignInButton";
|
||||
import { AuthDivider, AuthFooterLink, AuthShell } from "../../src/components/auth/AuthShell";
|
||||
import { AuthField } from "../../src/components/auth/AuthField";
|
||||
import { Reveal } from "../../src/components/auth/Reveal";
|
||||
import { useShake } from "../../src/hooks/useShake";
|
||||
import { useTheme } from "../../src/context/ThemeContext";
|
||||
import { getTypography, type ColorTokens, type Typography } from "../../src/theme/tokens";
|
||||
|
||||
@@ -35,6 +37,9 @@ export default function SignInScreen() {
|
||||
const [code, setCode] = useState("");
|
||||
const [step, setStep] = useState<"credentials" | "verify-device">("credentials");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [isCredentialError, setIsCredentialError] = useState(false);
|
||||
const { shakeStyle, shake } = useShake();
|
||||
const isBusy = fetchStatus === "fetching";
|
||||
|
||||
const finalizeIfComplete = async () => {
|
||||
if (signIn.status !== "complete") {
|
||||
@@ -50,6 +55,8 @@ export default function SignInScreen() {
|
||||
const { error: signInError } = await signIn.password({ identifier: emailAddress, password });
|
||||
if (signInError) {
|
||||
setError(signInError.longMessage ?? signInError.message);
|
||||
setIsCredentialError(true);
|
||||
shake();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -71,6 +78,7 @@ export default function SignInScreen() {
|
||||
const { error: verifyError } = await signIn.mfa.verifyEmailCode({ code });
|
||||
if (verifyError) {
|
||||
setError(verifyError.longMessage ?? verifyError.message);
|
||||
shake();
|
||||
return;
|
||||
}
|
||||
await finalizeIfComplete();
|
||||
@@ -78,89 +86,110 @@ export default function SignInScreen() {
|
||||
|
||||
if (step === "verify-device") {
|
||||
return (
|
||||
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === "ios" ? "padding" : undefined}>
|
||||
<ScrollView contentContainerStyle={styles.container} keyboardShouldPersistTaps="handled">
|
||||
<View style={styles.form}>
|
||||
<Text style={styles.title}>{t("auth.verifyDeviceTitle")}</Text>
|
||||
<Text style={styles.hint}>{t("auth.verifyDeviceHint", { email: emailAddress })}</Text>
|
||||
<TextField
|
||||
autoCapitalize="none"
|
||||
keyboardType="number-pad"
|
||||
placeholder={t("auth.codePlaceholder")}
|
||||
value={code}
|
||||
onChangeText={setCode}
|
||||
/>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
<Button title={t("auth.confirmButton")} disabled={fetchStatus === "fetching"} onPress={onVerifyPress} />
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
<AuthShell>
|
||||
<Reveal index={3}>
|
||||
<Text style={styles.title}>{t("auth.verifyDeviceTitle")}</Text>
|
||||
</Reveal>
|
||||
<Reveal index={4}>
|
||||
<Text style={styles.hint}>{t("auth.verifyDeviceHint", { email: emailAddress })}</Text>
|
||||
</Reveal>
|
||||
<Animated.View style={shakeStyle}>
|
||||
<AuthField
|
||||
icon={KeyRound}
|
||||
autoCapitalize="none"
|
||||
keyboardType="number-pad"
|
||||
placeholder={t("auth.codePlaceholder")}
|
||||
value={code}
|
||||
onChangeText={setCode}
|
||||
/>
|
||||
</Animated.View>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
<Button title={t("auth.confirmButton")} isLoading={isBusy} onPress={onVerifyPress} style={styles.submit} />
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
|
||||
const onCredentialChange = (setter: (value: string) => void) => (value: string) => {
|
||||
setter(value);
|
||||
setIsCredentialError(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === "ios" ? "padding" : undefined}>
|
||||
<ScrollView contentContainerStyle={styles.container} keyboardShouldPersistTaps="handled">
|
||||
<View style={styles.form}>
|
||||
<LanguageSwitcher />
|
||||
<Text style={styles.title}>{t("auth.signInTitle")}</Text>
|
||||
<AuthShell
|
||||
footer={
|
||||
<Reveal index={11}>
|
||||
<AuthFooterLink
|
||||
prompt={t("auth.noAccountPrompt")}
|
||||
action={t("auth.signUpButton")}
|
||||
onPress={() => router.replace("/(auth)/sign-up")}
|
||||
/>
|
||||
</Reveal>
|
||||
}
|
||||
>
|
||||
<Reveal index={3}>
|
||||
<Text style={styles.title}>{t("auth.welcomeBack")}</Text>
|
||||
</Reveal>
|
||||
<Reveal index={4}>
|
||||
<Text style={styles.hint}>{t("auth.welcomeBackHint")}</Text>
|
||||
</Reveal>
|
||||
<Animated.View style={[styles.fields, shakeStyle]}>
|
||||
<Reveal index={5}>
|
||||
<AuthField
|
||||
icon={Mail}
|
||||
autoCapitalize="none"
|
||||
autoComplete="email"
|
||||
keyboardType="email-address"
|
||||
placeholder={t("auth.emailPlaceholder")}
|
||||
value={emailAddress}
|
||||
onChangeText={onCredentialChange(setEmailAddress)}
|
||||
isInvalid={isCredentialError}
|
||||
/>
|
||||
</Reveal>
|
||||
<Reveal index={6}>
|
||||
<AuthField
|
||||
icon={Lock}
|
||||
isSecure
|
||||
autoComplete="password"
|
||||
placeholder={t("auth.passwordPlaceholder")}
|
||||
value={password}
|
||||
onChangeText={onCredentialChange(setPassword)}
|
||||
isInvalid={isCredentialError}
|
||||
/>
|
||||
</Reveal>
|
||||
</Animated.View>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
<Reveal index={7}>
|
||||
<Button title={t("auth.signInButton")} isLoading={isBusy} onPress={onSignInPress} style={styles.submit} />
|
||||
</Reveal>
|
||||
<Reveal index={8}>
|
||||
<AuthDivider label={t("auth.continueWith")} />
|
||||
</Reveal>
|
||||
{/* Apple renders nothing on Android — skip its Reveal so no empty gap remains. */}
|
||||
{Platform.OS === "ios" ? (
|
||||
<Reveal index={9}>
|
||||
<AppleSignInButton
|
||||
onError={setError}
|
||||
onNeedsConsent={() => setError(t("auth.appleNeedsSignUpError"))}
|
||||
/>
|
||||
</Reveal>
|
||||
) : null}
|
||||
<Reveal index={10}>
|
||||
<GoogleSignInButton
|
||||
onError={setError}
|
||||
onNeedsConsent={() => setError(t("auth.googleNeedsSignUpError"))}
|
||||
/>
|
||||
<AppleSignInButton
|
||||
onError={setError}
|
||||
onNeedsConsent={() => setError(t("auth.appleNeedsSignUpError"))}
|
||||
/>
|
||||
<Text style={styles.divider}>{t("auth.orDivider")}</Text>
|
||||
<TextField
|
||||
autoCapitalize="none"
|
||||
keyboardType="email-address"
|
||||
placeholder={t("auth.emailPlaceholder")}
|
||||
value={emailAddress}
|
||||
onChangeText={setEmailAddress}
|
||||
/>
|
||||
<PasswordField
|
||||
placeholder={t("auth.passwordPlaceholder")}
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
/>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
<Button
|
||||
title={t("auth.signInButton")}
|
||||
disabled={fetchStatus === "fetching"}
|
||||
onPress={onSignInPress}
|
||||
/>
|
||||
<Pressable onPress={() => router.replace("/(auth)/sign-up")} hitSlop={8}>
|
||||
<Text style={styles.link}>{t("auth.noAccountLink")}</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
</Reveal>
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
|
||||
function makeStyles(colors: ColorTokens) {
|
||||
const typography: Typography = getTypography(colors);
|
||||
return StyleSheet.create({
|
||||
flex: { flex: 1, backgroundColor: colors.porchWhite },
|
||||
container: {
|
||||
flexGrow: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
padding: 24,
|
||||
backgroundColor: colors.porchWhite,
|
||||
},
|
||||
// Capped so the form stays a readable phone-width column instead of
|
||||
// stretching full-bleed edge-to-edge on tablets (reported: "die gesamte
|
||||
// App sieht sehr großgezogen aus" on a tablet login screenshot) — the
|
||||
// container above had no maxWidth, so flex "stretch" filled the entire
|
||||
// screen width on large devices.
|
||||
form: { width: "100%", maxWidth: 420, gap: 12 },
|
||||
title: { ...typography.headline, marginBottom: 16 },
|
||||
divider: { ...typography.label, textAlign: "center", textTransform: "none" as const },
|
||||
hint: { ...typography.body, color: colors.quietGray, marginBottom: 8 },
|
||||
title: { ...typography.headline, fontSize: 22 },
|
||||
hint: { ...typography.body, color: colors.quietGray, marginTop: -6, marginBottom: 6 },
|
||||
fields: { gap: 10 },
|
||||
error: { ...typography.body, color: colors.alertRed },
|
||||
link: { ...typography.body, color: colors.marigoldDeep, textAlign: "center", marginTop: 8 },
|
||||
submit: { height: 52, borderRadius: 14 },
|
||||
});
|
||||
}
|
||||
+154
-89
@@ -1,15 +1,16 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { View, Text, Pressable, Linking, StyleSheet, KeyboardAvoidingView, ScrollView, Platform } from "react-native";
|
||||
import { Animated, View, Text, Pressable, Linking, StyleSheet, Platform } from "react-native";
|
||||
import { useSignUp } from "@clerk/expo";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Check } from "lucide-react-native";
|
||||
import { Check, KeyRound, Lock, Mail, User } from "lucide-react-native";
|
||||
import { Button } from "../../src/components/Button";
|
||||
import { TextField } from "../../src/components/TextField";
|
||||
import { PasswordField } from "../../src/components/PasswordField";
|
||||
import { LanguageSwitcher } from "../../src/components/LanguageSwitcher";
|
||||
import { GoogleSignInButton } from "../../src/components/GoogleSignInButton";
|
||||
import { AppleSignInButton } from "../../src/components/AppleSignInButton";
|
||||
import { AuthDivider, AuthFooterLink, AuthShell } from "../../src/components/auth/AuthShell";
|
||||
import { AuthField } from "../../src/components/auth/AuthField";
|
||||
import { Reveal } from "../../src/components/auth/Reveal";
|
||||
import { useShake } from "../../src/hooks/useShake";
|
||||
import { useTheme } from "../../src/context/ThemeContext";
|
||||
import { env } from "../../src/lib/env";
|
||||
import { getTypography, type ColorTokens, type Typography } from "../../src/theme/tokens";
|
||||
@@ -50,6 +51,12 @@ export default function SignUpScreen() {
|
||||
const [code, setCode] = useState("");
|
||||
const [step, setStep] = useState<"credentials" | "verify-email">("credentials");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const { shakeStyle, shake } = useShake();
|
||||
const { shakeStyle: consentShakeStyle, shake: shakeConsent } = useShake();
|
||||
// Set when someone taps Google/Apple before ticking the consent box.
|
||||
const [isConsentNudged, setIsConsentNudged] = useState(false);
|
||||
const showConsentHint = isConsentNudged && !legalAccepted;
|
||||
const isBusy = fetchStatus === "fetching";
|
||||
|
||||
const canSubmit =
|
||||
firstName.trim().length > 0 && lastName.trim().length > 0 && emailAddress.trim().length > 0 && password.length > 0 && legalAccepted;
|
||||
@@ -74,6 +81,7 @@ export default function SignUpScreen() {
|
||||
});
|
||||
if (signUpError) {
|
||||
setError(signUpError.longMessage ?? signUpError.message);
|
||||
shake();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,6 +103,7 @@ export default function SignUpScreen() {
|
||||
const { error: verifyError } = await signUp.verifications.verifyEmailCode({ code });
|
||||
if (verifyError) {
|
||||
setError(verifyError.longMessage ?? verifyError.message);
|
||||
shake();
|
||||
return;
|
||||
}
|
||||
await finalizeIfComplete();
|
||||
@@ -102,112 +111,165 @@ export default function SignUpScreen() {
|
||||
|
||||
if (step === "verify-email") {
|
||||
return (
|
||||
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === "ios" ? "padding" : undefined}>
|
||||
<ScrollView contentContainerStyle={styles.container} keyboardShouldPersistTaps="handled">
|
||||
<View style={styles.form}>
|
||||
<Text style={styles.title}>{t("auth.verifyEmailTitle")}</Text>
|
||||
<Text style={styles.hint}>{t("auth.verifyEmailHint", { email: emailAddress })}</Text>
|
||||
<TextField
|
||||
autoCapitalize="none"
|
||||
keyboardType="number-pad"
|
||||
placeholder={t("auth.codePlaceholder")}
|
||||
value={code}
|
||||
onChangeText={setCode}
|
||||
/>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
<Button title={t("auth.confirmButton")} disabled={fetchStatus === "fetching"} onPress={onVerifyPress} />
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
<AuthShell>
|
||||
<Reveal index={3}>
|
||||
<Text style={styles.title}>{t("auth.verifyEmailTitle")}</Text>
|
||||
</Reveal>
|
||||
<Reveal index={4}>
|
||||
<Text style={styles.hint}>{t("auth.verifyEmailHint", { email: emailAddress })}</Text>
|
||||
</Reveal>
|
||||
<Animated.View style={shakeStyle}>
|
||||
<AuthField
|
||||
icon={KeyRound}
|
||||
autoCapitalize="none"
|
||||
keyboardType="number-pad"
|
||||
placeholder={t("auth.codePlaceholder")}
|
||||
value={code}
|
||||
onChangeText={setCode}
|
||||
/>
|
||||
</Animated.View>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
<Button title={t("auth.confirmButton")} isLoading={isBusy} onPress={onVerifyPress} style={styles.submit} />
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
|
||||
const nudgeConsent = () => {
|
||||
setIsConsentNudged(true);
|
||||
shakeConsent();
|
||||
};
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === "ios" ? "padding" : undefined}>
|
||||
<ScrollView contentContainerStyle={styles.container} keyboardShouldPersistTaps="handled">
|
||||
<View style={styles.form}>
|
||||
<LanguageSwitcher />
|
||||
<Text style={styles.title}>{t("auth.signUpTitle")}</Text>
|
||||
<GoogleSignInButton onError={setError} legalAccepted={legalAccepted} disabled={!legalAccepted} />
|
||||
<AppleSignInButton onError={setError} legalAccepted={legalAccepted} disabled={!legalAccepted} />
|
||||
<Text style={styles.divider}>{t("auth.orDivider")}</Text>
|
||||
<TextField
|
||||
placeholder={t("auth.firstNamePlaceholder")}
|
||||
value={firstName}
|
||||
onChangeText={setFirstName}
|
||||
/>
|
||||
<TextField
|
||||
placeholder={t("auth.lastNamePlaceholder")}
|
||||
value={lastName}
|
||||
onChangeText={setLastName}
|
||||
/>
|
||||
<TextField
|
||||
autoCapitalize="none"
|
||||
keyboardType="email-address"
|
||||
placeholder={t("auth.emailPlaceholder")}
|
||||
value={emailAddress}
|
||||
onChangeText={setEmailAddress}
|
||||
/>
|
||||
<PasswordField
|
||||
placeholder={t("auth.passwordPlaceholder")}
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
/>
|
||||
<Pressable style={styles.checkboxRow} onPress={() => setLegalAccepted((v) => !v)}>
|
||||
<View style={[styles.checkbox, legalAccepted && styles.checkboxChecked]}>
|
||||
{legalAccepted && <Check color={colors.pureWhite} size={14} />}
|
||||
<AuthShell
|
||||
footer={
|
||||
<Reveal index={13}>
|
||||
<AuthFooterLink
|
||||
prompt={t("auth.hasAccountPrompt")}
|
||||
action={t("auth.signInButton")}
|
||||
onPress={() => router.replace("/(auth)/sign-in")}
|
||||
/>
|
||||
</Reveal>
|
||||
}
|
||||
>
|
||||
<Reveal index={3}>
|
||||
<Text style={styles.title}>{t("auth.signUpHeading")}</Text>
|
||||
</Reveal>
|
||||
<Reveal index={4}>
|
||||
<Text style={styles.hint}>{t("auth.signUpHint")}</Text>
|
||||
</Reveal>
|
||||
<Animated.View style={[styles.fields, shakeStyle]}>
|
||||
<Reveal index={5} style={styles.nameRow}>
|
||||
<View style={styles.nameField}>
|
||||
<AuthField
|
||||
icon={User}
|
||||
autoComplete="given-name"
|
||||
placeholder={t("auth.firstNamePlaceholder")}
|
||||
value={firstName}
|
||||
onChangeText={setFirstName}
|
||||
/>
|
||||
</View>
|
||||
<Text style={styles.checkboxLabel}>{t("auth.legalConsentLabel")}</Text>
|
||||
</Pressable>
|
||||
<View style={styles.nameField}>
|
||||
<AuthField
|
||||
autoComplete="family-name"
|
||||
placeholder={t("auth.lastNamePlaceholder")}
|
||||
value={lastName}
|
||||
onChangeText={setLastName}
|
||||
/>
|
||||
</View>
|
||||
</Reveal>
|
||||
<Reveal index={6}>
|
||||
<AuthField
|
||||
icon={Mail}
|
||||
autoCapitalize="none"
|
||||
autoComplete="email"
|
||||
keyboardType="email-address"
|
||||
placeholder={t("auth.emailPlaceholder")}
|
||||
value={emailAddress}
|
||||
onChangeText={setEmailAddress}
|
||||
/>
|
||||
</Reveal>
|
||||
<Reveal index={7}>
|
||||
<AuthField
|
||||
icon={Lock}
|
||||
isSecure
|
||||
autoComplete="new-password"
|
||||
placeholder={t("auth.passwordPlaceholder")}
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
/>
|
||||
</Reveal>
|
||||
</Animated.View>
|
||||
<Reveal index={8}>
|
||||
<Animated.View style={consentShakeStyle}>
|
||||
<Pressable style={styles.checkboxRow} onPress={() => setLegalAccepted((v) => !v)} hitSlop={6}>
|
||||
<View
|
||||
style={[styles.checkbox, showConsentHint && styles.checkboxNudged, legalAccepted && styles.checkboxChecked]}
|
||||
>
|
||||
{legalAccepted && <Check color={colors.pureWhite} size={14} />}
|
||||
</View>
|
||||
<Text style={styles.checkboxLabel}>{t("auth.legalConsentLabel")}</Text>
|
||||
</Pressable>
|
||||
</Animated.View>
|
||||
{showConsentHint ? <Text style={styles.consentHint}>{t("auth.consentFirstHint")}</Text> : null}
|
||||
<View style={styles.legalLinksRow}>
|
||||
<Pressable onPress={() => Linking.openURL(`${env.apiUrl}/nutzungsbedingungen`)}>
|
||||
<Pressable onPress={() => Linking.openURL(`${env.apiUrl}/nutzungsbedingungen`)} hitSlop={8}>
|
||||
<Text style={styles.link}>{t("pets.legalTerms")}</Text>
|
||||
</Pressable>
|
||||
<Pressable onPress={() => Linking.openURL(`${env.apiUrl}/datenschutz`)}>
|
||||
<Pressable onPress={() => Linking.openURL(`${env.apiUrl}/datenschutz`)} hitSlop={8}>
|
||||
<Text style={styles.link}>{t("pets.legalPrivacy")}</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
</Reveal>
|
||||
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||
<Reveal index={9}>
|
||||
<Button
|
||||
title={t("auth.signUpButton")}
|
||||
disabled={fetchStatus === "fetching" || !canSubmit}
|
||||
disabled={!canSubmit}
|
||||
isLoading={isBusy}
|
||||
onPress={onSignUpPress}
|
||||
style={styles.submit}
|
||||
/>
|
||||
<Pressable onPress={() => router.replace("/(auth)/sign-in")} hitSlop={8}>
|
||||
<Text style={styles.link}>{t("auth.hasAccountLink")}</Text>
|
||||
</Pressable>
|
||||
</Reveal>
|
||||
<Reveal index={10}>
|
||||
<AuthDivider label={t("auth.continueWith")} />
|
||||
</Reveal>
|
||||
{/* Buttons stay visually active: a greyed-out Google button without any
|
||||
explanation confused users. Before consent, a tap lands on the overlay
|
||||
and points at the checkbox instead of starting the SSO flow. */}
|
||||
<View style={styles.ssoGroup}>
|
||||
{/* Apple renders nothing on Android — skip its Reveal so no empty gap remains. */}
|
||||
{Platform.OS === "ios" ? (
|
||||
<Reveal index={11}>
|
||||
<AppleSignInButton onError={setError} legalAccepted={legalAccepted} />
|
||||
</Reveal>
|
||||
) : null}
|
||||
<Reveal index={12}>
|
||||
<GoogleSignInButton onError={setError} legalAccepted={legalAccepted} />
|
||||
</Reveal>
|
||||
{!legalAccepted ? (
|
||||
<Pressable
|
||||
style={StyleSheet.absoluteFill}
|
||||
onPress={nudgeConsent}
|
||||
accessibilityRole="button"
|
||||
accessibilityHint={t("auth.consentFirstHint")}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
</AuthShell>
|
||||
);
|
||||
}
|
||||
|
||||
function makeStyles(colors: ColorTokens) {
|
||||
const typography: Typography = getTypography(colors);
|
||||
return StyleSheet.create({
|
||||
flex: { flex: 1, backgroundColor: colors.porchWhite },
|
||||
// flexGrow (not flex) on a ScrollView's contentContainerStyle — still
|
||||
// centers short content but lets the view actually scroll once the
|
||||
// keyboard pushes content taller than the screen (found.md: password
|
||||
// field and submit button were getting hidden behind the keyboard).
|
||||
container: {
|
||||
flexGrow: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
padding: 24,
|
||||
backgroundColor: colors.porchWhite,
|
||||
},
|
||||
// Capped so the form stays a readable phone-width column instead of
|
||||
// stretching full-bleed edge-to-edge on tablets (reported: "die gesamte
|
||||
// App sieht sehr großgezogen aus" on a tablet login screenshot) — the
|
||||
// container above had no maxWidth, so flex "stretch" filled the entire
|
||||
// screen width on large devices.
|
||||
form: { width: "100%", maxWidth: 420, gap: 12 },
|
||||
title: { ...typography.headline, marginBottom: 16 },
|
||||
divider: { ...typography.label, textAlign: "center", textTransform: "none" as const },
|
||||
hint: { ...typography.body, color: colors.quietGray, marginBottom: 8 },
|
||||
title: { ...typography.headline, fontSize: 22 },
|
||||
hint: { ...typography.body, color: colors.quietGray, marginTop: -6, marginBottom: 6 },
|
||||
fields: { gap: 10 },
|
||||
nameRow: { flexDirection: "row", gap: 10 },
|
||||
nameField: { flex: 1 },
|
||||
error: { ...typography.body, color: colors.alertRed },
|
||||
link: { ...typography.body, color: colors.marigoldDeep, textAlign: "center", marginTop: 8 },
|
||||
submit: { height: 52, borderRadius: 14 },
|
||||
link: { ...typography.body, fontSize: 13, color: colors.marigoldDeep },
|
||||
checkboxRow: { flexDirection: "row", alignItems: "flex-start", gap: 10, marginTop: 4 },
|
||||
checkbox: {
|
||||
width: 20,
|
||||
@@ -220,7 +282,10 @@ function makeStyles(colors: ColorTokens) {
|
||||
marginTop: 2,
|
||||
},
|
||||
checkboxChecked: { backgroundColor: colors.marigoldOrange, borderColor: colors.marigoldOrange },
|
||||
checkboxNudged: { borderColor: colors.alertRed, borderWidth: 2 },
|
||||
consentHint: { ...typography.body, fontSize: 13, color: colors.alertRed, marginTop: 6 },
|
||||
ssoGroup: { gap: 10 },
|
||||
checkboxLabel: { ...typography.body, flex: 1, fontSize: 13, lineHeight: 19 },
|
||||
legalLinksRow: { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", gap: 16 },
|
||||
legalLinksRow: { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", gap: 16, marginTop: 6 },
|
||||
});
|
||||
}
|
||||
@@ -212,3 +212,6 @@ Neu 7:
|
||||
|
||||
- [x] Gefunden 04.10. (Marketing-Aufnahmen): Nach „Vermisst-Meldung starten“ war die Bestätigung auf Android abgeschnitten („… dass Berli schnell nac…“).
|
||||
→ **Behoben (04.10.):** Android kürzt Dialog-Titel auf zwei Zeilen, und der ganze Text stand als Titel im Dialog. Jetzt kurzer Titel + vollständige Nachricht: „Die Meldung ist raus“ / „Wir drücken die Daumen, dass {Name} schnell nach Hause findet.“, Entwarnung „Wie schön! 🎉“ / „Willkommen zurück, {Name}!“, Fehler „Hoppla“ + Meldung des Servers. Am Android-Emulator geprüft (Fehlerdialog bei der 24-h-Sperre vollständig lesbar). Typecheck, Lint und 406 Tests grün. Commit `b1d3b61`, OTA Runtime 1.0.6: Android `ab6e7fc6-9b24-44a6-bb65-b88e2b0cf937`, iOS `f63c0db6-6f5b-49de-b369-bf6aa7d52a1b`.
|
||||
|
||||
- [x] Wunsch 09.10. (Obsidian „Mobile - UI Rework“): Login-Seite wirkt statisch, Sprachwahl zu dominant, Logo fehlt, Reihenfolge seltsam. Nachtrag: Nutzer versteht nicht, warum „Mit Google anmelden“ auf der Registrierung ausgegraut ist.
|
||||
→ **Umgesetzt (09.10.):** Login und Registrierung neu aufgebaut (gemeinsamer Rahmen `src/components/auth/AuthShell.tsx`): Logo + „PawFeed“ oben, Sprache als kleiner „DE ⌄“-Chip mit Menü, Formular unten (E-Mail/Passwort → Anmelden → „oder weiter mit“ Apple/Google). Animationen nur mit eingebautem `Animated` (OTA-fähig): Logo federt rein, Inhalte gleiten gestaffelt ein, Feldrahmen orange bei Fokus, Ladekringel im Knopf, Felder wackeln + rot bei falschem Login; „Bewegung reduzieren“ wird beachtet. Android: Abstände über Statusleiste/Gestenleiste per Safe-Area, 28 pt Seitenrand (Zurück-Wischzone), Sprachmenü als Modal (Zurück-Geste schließt nur das Menü), Tastatur schiebt das Formular jetzt hoch (`KeyboardAvoidingView` auch auf Android, nötig seit Edge-to-Edge). Google/Apple auf der Registrierung nicht mehr ausgegraut: Tippen ohne Haken markiert die Checkbox rot, lässt sie wackeln und zeigt einen Hinweis. Typecheck + Lint sauber, live im Android-Emulator (Pixel 10 Pro, Gestensteuerung) getestet: Layout, Sprachmenü + Zurück-Geste, Tastatur, Fehlerfall, Hinweis. iOS nur per HTML-Vorschau abgenommen, nicht auf Gerät.
|
||||
@@ -6,7 +6,6 @@ import * as AppleAuthentication from "expo-apple-authentication";
|
||||
import { useSignInWithApple } from "@clerk/expo/apple";
|
||||
import * as Sentry from "@sentry/react-native";
|
||||
import { useTheme } from "../context/ThemeContext";
|
||||
import { radii } from "../theme/tokens";
|
||||
|
||||
type Props = {
|
||||
onError: (message: string) => void;
|
||||
@@ -102,7 +101,7 @@ function AppleSignInButtonInner({ onError, legalAccepted, onNeedsConsent, disabl
|
||||
? AppleAuthentication.AppleAuthenticationButtonStyle.WHITE
|
||||
: AppleAuthentication.AppleAuthenticationButtonStyle.BLACK
|
||||
}
|
||||
cornerRadius={radii.lg}
|
||||
cornerRadius={14}
|
||||
style={styles.button}
|
||||
onPress={onPress}
|
||||
/>
|
||||
@@ -111,6 +110,6 @@ function AppleSignInButtonInner({ onError, legalAccepted, onNeedsConsent, disabl
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: { height: 48, width: "100%" },
|
||||
button: { height: 52, width: "100%" },
|
||||
disabled: { opacity: 0.5 },
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from "react";
|
||||
import { Pressable, Text, StyleSheet, type PressableProps } from "react-native";
|
||||
import { ActivityIndicator, Pressable, Text, StyleSheet, type PressableProps } from "react-native";
|
||||
import { useTheme } from "../context/ThemeContext";
|
||||
import { radii, fontFamily, type ColorTokens } from "../theme/tokens";
|
||||
|
||||
@@ -8,6 +8,8 @@ type Variant = "primary" | "outline";
|
||||
type Props = PressableProps & {
|
||||
title: string;
|
||||
variant?: Variant;
|
||||
/** Spinner instead of the title; also blocks presses. */
|
||||
isLoading?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -16,13 +18,13 @@ type Props = PressableProps & {
|
||||
* Height is 48px rather than the web's 32px: that control size is a
|
||||
* desktop-density choice, too small as a touch target on a phone.
|
||||
*/
|
||||
export function Button({ title, variant = "primary", style, disabled, ...rest }: Props) {
|
||||
export function Button({ title, variant = "primary", style, disabled, isLoading = false, ...rest }: Props) {
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
disabled={disabled}
|
||||
disabled={disabled || isLoading}
|
||||
style={(state) => [
|
||||
styles.base,
|
||||
variant === "primary" ? styles.primary : styles.outline,
|
||||
@@ -32,7 +34,11 @@ export function Button({ title, variant = "primary", style, disabled, ...rest }:
|
||||
]}
|
||||
{...rest}
|
||||
>
|
||||
<Text style={variant === "primary" ? styles.primaryText : styles.outlineText}>{title}</Text>
|
||||
{isLoading ? (
|
||||
<ActivityIndicator color={variant === "primary" ? colors.pureWhite : colors.marigoldOrange} />
|
||||
) : (
|
||||
<Text style={variant === "primary" ? styles.primaryText : styles.outlineText}>{title}</Text>
|
||||
)}
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useSSO } from "@clerk/expo";
|
||||
import * as Sentry from "@sentry/react-native";
|
||||
import { useTheme } from "../context/ThemeContext";
|
||||
import { useWarmUpBrowser } from "../hooks/useWarmUpBrowser";
|
||||
import { radii, fontFamily, type ColorTokens } from "../theme/tokens";
|
||||
import { fontFamily, type ColorTokens } from "../theme/tokens";
|
||||
import { GoogleIcon } from "./GoogleIcon";
|
||||
|
||||
type Props = {
|
||||
@@ -109,8 +109,8 @@ export function GoogleSignInButton({ onError, legalAccepted, onNeedsConsent, dis
|
||||
function makeStyles(colors: ColorTokens) {
|
||||
return StyleSheet.create({
|
||||
base: {
|
||||
height: 48,
|
||||
borderRadius: radii.lg,
|
||||
height: 52,
|
||||
borderRadius: 14,
|
||||
borderWidth: 1,
|
||||
borderColor: colors.hairlineGray,
|
||||
backgroundColor: colors.pureWhite,
|
||||
|
||||
@@ -14,17 +14,15 @@ import { getTypography, type ColorTokens, type Typography } from "../theme/token
|
||||
* changeLanguage() logic, no backend field (mirrors web: locale lives only
|
||||
* in a cookie/local preference, never on the Owner row).
|
||||
*/
|
||||
export function LanguageSwitcher() {
|
||||
export function useLanguagePreference() {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const queryClient = useQueryClient();
|
||||
const [preference, setPreferenceState] = useState<Locale | null>(() => getLanguagePreference());
|
||||
|
||||
const languageOptions = [
|
||||
{ value: "de" as const, label: t("pets.languageGerman"), flag: "🇩🇪" },
|
||||
{ value: "en" as const, label: t("pets.languageEnglish"), flag: "🇬🇧" },
|
||||
{ value: null, label: t("pets.languageAuto"), flag: "🌐" },
|
||||
{ value: "de" as const, label: t("pets.languageGerman"), flag: "🇩🇪", short: "DE" },
|
||||
{ value: "en" as const, label: t("pets.languageEnglish"), flag: "🇬🇧", short: "EN" },
|
||||
{ value: null, label: t("pets.languageAuto"), flag: "🌐", short: "Auto" },
|
||||
];
|
||||
|
||||
const handleSelect = (value: Locale | null) => {
|
||||
@@ -33,6 +31,14 @@ export function LanguageSwitcher() {
|
||||
queryClient.invalidateQueries();
|
||||
};
|
||||
|
||||
return { preference, languageOptions, handleSelect };
|
||||
}
|
||||
|
||||
export function LanguageSwitcher() {
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const { preference, languageOptions, handleSelect } = useLanguagePreference();
|
||||
|
||||
return (
|
||||
<View style={styles.row}>
|
||||
{languageOptions.map((option) => {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Animated, Pressable, StyleSheet, TextInput, type TextInputProps } from "react-native";
|
||||
import { Eye, EyeOff, type LucideIcon } from "lucide-react-native";
|
||||
import { useTheme } from "../../context/ThemeContext";
|
||||
import { fontFamily, type ColorTokens } from "../../theme/tokens";
|
||||
|
||||
const FOCUS_MS = 200;
|
||||
|
||||
type Props = TextInputProps & {
|
||||
icon?: LucideIcon;
|
||||
/** Red border after a rejected submit. */
|
||||
isInvalid?: boolean;
|
||||
/** Password field: hidden text plus a show/hide toggle. */
|
||||
isSecure?: boolean;
|
||||
};
|
||||
|
||||
/** Larger auth-screen input: leading icon, animated marigold border on focus, red when invalid. */
|
||||
export function AuthField({ icon: Icon, isInvalid = false, isSecure = false, onFocus, onBlur, ...rest }: Props) {
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const [focus] = useState(() => new Animated.Value(0));
|
||||
|
||||
const animateFocus = (toValue: number) =>
|
||||
// borderColor can't run on the native driver.
|
||||
Animated.timing(focus, { toValue, duration: FOCUS_MS, useNativeDriver: false }).start();
|
||||
|
||||
useEffect(() => () => focus.stopAnimation(), [focus]);
|
||||
|
||||
const borderColor = isInvalid
|
||||
? colors.alertRed
|
||||
: focus.interpolate({ inputRange: [0, 1], outputRange: [colors.hairlineGray, colors.marigoldOrange] });
|
||||
|
||||
return (
|
||||
<Animated.View style={[styles.field, { borderColor }]}>
|
||||
{Icon ? <Icon color={colors.quietGray} size={18} /> : null}
|
||||
<TextInput
|
||||
placeholderTextColor={colors.quietGray}
|
||||
secureTextEntry={isSecure && !isVisible}
|
||||
onFocus={(e) => {
|
||||
animateFocus(1);
|
||||
onFocus?.(e);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
animateFocus(0);
|
||||
onBlur?.(e);
|
||||
}}
|
||||
{...rest}
|
||||
style={styles.input}
|
||||
/>
|
||||
{isSecure ? (
|
||||
<Pressable onPress={() => setIsVisible((v) => !v)} hitSlop={12} accessibilityRole="button">
|
||||
{isVisible ? <EyeOff color={colors.quietGray} size={18} /> : <Eye color={colors.quietGray} size={18} />}
|
||||
</Pressable>
|
||||
) : null}
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
function makeStyles(colors: ColorTokens) {
|
||||
return StyleSheet.create({
|
||||
field: {
|
||||
height: 52,
|
||||
borderRadius: 14,
|
||||
borderWidth: 1.5,
|
||||
backgroundColor: colors.pureWhite,
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 10,
|
||||
paddingHorizontal: 14,
|
||||
},
|
||||
input: {
|
||||
flex: 1,
|
||||
height: "100%",
|
||||
fontFamily: fontFamily.regular,
|
||||
fontSize: 15,
|
||||
color: colors.ink,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Animated, Platform, StyleSheet } from "react-native";
|
||||
import Svg, { Circle, Defs, G, LinearGradient, Path, Rect, Stop } from "react-native-svg";
|
||||
import { useReducedMotion } from "../../hooks/useReducedMotion";
|
||||
|
||||
const SIZE = 68;
|
||||
const RADIUS = 22;
|
||||
const TOE_DELAY_MS = 450;
|
||||
const TOE_STAGGER_MS = 70;
|
||||
const TOES = [
|
||||
{ cx: 5.5, cy: 9.5, r: 2.4 },
|
||||
{ cx: 10, cy: 5.2, r: 2.4 },
|
||||
{ cx: 15, cy: 5.6, r: 2.4 },
|
||||
{ cx: 19, cy: 10, r: 2.3 },
|
||||
];
|
||||
|
||||
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
||||
|
||||
/** App icon mark for the auth screens: springs in, then the four toes appear one by one. */
|
||||
export function AuthLogo() {
|
||||
const isReducedMotion = useReducedMotion();
|
||||
const [pop] = useState(() => new Animated.Value(0));
|
||||
const [toes] = useState(() => TOES.map(() => new Animated.Value(0)));
|
||||
|
||||
useEffect(() => {
|
||||
if (isReducedMotion) {
|
||||
pop.setValue(1);
|
||||
toes.forEach((toe) => toe.setValue(1));
|
||||
return;
|
||||
}
|
||||
const animation = Animated.parallel([
|
||||
Animated.spring(pop, { toValue: 1, friction: 5, tension: 80, useNativeDriver: true }),
|
||||
Animated.sequence([
|
||||
Animated.delay(TOE_DELAY_MS),
|
||||
// SVG props can't run on the native driver.
|
||||
Animated.stagger(
|
||||
TOE_STAGGER_MS,
|
||||
toes.map((toe) => Animated.timing(toe, { toValue: 1, duration: 300, useNativeDriver: false })),
|
||||
),
|
||||
]),
|
||||
]);
|
||||
animation.start();
|
||||
return () => animation.stop();
|
||||
}, [isReducedMotion, pop, toes]);
|
||||
|
||||
const scale = pop.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1] });
|
||||
const opacity = pop.interpolate({ inputRange: [0, 0.6], outputRange: [0, 1], extrapolate: "clamp" });
|
||||
|
||||
return (
|
||||
<Animated.View style={[styles.mark, { opacity, transform: [{ scale }] }]}>
|
||||
<Svg width={SIZE} height={SIZE} viewBox={`0 0 ${SIZE} ${SIZE}`}>
|
||||
<Defs>
|
||||
<LinearGradient id="authLogoFill" x1="0" y1="0" x2="1" y2="1">
|
||||
<Stop offset="0" stopColor="#fb923c" />
|
||||
<Stop offset="1" stopColor="#ea580c" />
|
||||
</LinearGradient>
|
||||
</Defs>
|
||||
<Rect width={SIZE} height={SIZE} rx={RADIUS} fill="url(#authLogoFill)" />
|
||||
<G transform="translate(12 12) scale(1.8333)" fill="#ffffff">
|
||||
{TOES.map((toe, i) => (
|
||||
<AnimatedCircle key={i} cx={toe.cx} cy={toe.cy} r={toe.r} opacity={toes[i]} />
|
||||
))}
|
||||
<Path d="M12.3 11.2c3 0 6.2 3.6 6.2 6.4 0 2.2-1.7 3-3.3 3-1.3 0-1.9-.6-2.9-.6s-1.6.6-2.9.6c-1.6 0-3.3-.8-3.3-3 0-2.8 3.2-6.4 6.2-6.4z" />
|
||||
</G>
|
||||
</Svg>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
mark: {
|
||||
width: SIZE,
|
||||
height: SIZE,
|
||||
borderRadius: RADIUS,
|
||||
marginBottom: 12,
|
||||
// Android needs a background for elevation to cast a shadow.
|
||||
backgroundColor: "#ea580c",
|
||||
...Platform.select({
|
||||
ios: { shadowColor: "#ea580c", shadowOpacity: 0.45, shadowRadius: 14, shadowOffset: { width: 0, height: 10 } },
|
||||
android: { elevation: 8 },
|
||||
}),
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
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 },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { Modal, Pressable, StyleSheet, Text, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { ChevronDown, ChevronUp } from "lucide-react-native";
|
||||
import { useTheme } from "../../context/ThemeContext";
|
||||
import { useLanguagePreference } from "../LanguageSwitcher";
|
||||
import { fontFamily, type ColorTokens } from "../../theme/tokens";
|
||||
|
||||
const CHIP_HEIGHT = 34;
|
||||
const MENU_GAP = 6;
|
||||
|
||||
/**
|
||||
* Compact language picker for the auth screens. The menu is a Modal on
|
||||
* purpose: Android's back gesture then closes the menu (onRequestClose)
|
||||
* instead of leaving the app from the root sign-in screen.
|
||||
*/
|
||||
export function LanguageChip() {
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const insets = useSafeAreaInsets();
|
||||
const { preference, languageOptions, handleSelect } = useLanguagePreference();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [chipBottom, setChipBottom] = useState(insets.top + CHIP_HEIGHT);
|
||||
const chipRef = useRef<View>(null);
|
||||
|
||||
// Measured on press, not onLayout: the entrance animation is still moving the chip at mount.
|
||||
const open = () => {
|
||||
if (!chipRef.current) return setIsOpen(true);
|
||||
chipRef.current.measureInWindow((_x, y, _w, h) => {
|
||||
setChipBottom(y + h);
|
||||
setIsOpen(true);
|
||||
});
|
||||
};
|
||||
|
||||
const current = languageOptions.find((o) => o.value === preference) ?? languageOptions[2];
|
||||
const Chevron = isOpen ? ChevronUp : ChevronDown;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Pressable
|
||||
ref={chipRef}
|
||||
onPress={open}
|
||||
android_ripple={{ color: colors.marigoldTint, borderless: false }}
|
||||
style={styles.chip}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ expanded: isOpen }}
|
||||
>
|
||||
<Text style={styles.flag}>{current.flag}</Text>
|
||||
<Text style={styles.chipText}>{current.short}</Text>
|
||||
<Chevron color={colors.quietGray} size={14} />
|
||||
</Pressable>
|
||||
|
||||
<Modal
|
||||
visible={isOpen}
|
||||
transparent
|
||||
animationType="fade"
|
||||
statusBarTranslucent
|
||||
navigationBarTranslucent
|
||||
onRequestClose={() => setIsOpen(false)}
|
||||
>
|
||||
<Pressable style={StyleSheet.absoluteFill} onPress={() => setIsOpen(false)} accessibilityLabel="close" />
|
||||
<View style={[styles.menu, { top: chipBottom + MENU_GAP }]}>
|
||||
{languageOptions.map((option) => {
|
||||
const isActive = option.value === preference;
|
||||
return (
|
||||
<Pressable
|
||||
key={option.label}
|
||||
onPress={() => {
|
||||
handleSelect(option.value);
|
||||
setIsOpen(false);
|
||||
}}
|
||||
android_ripple={{ color: colors.marigoldTint }}
|
||||
style={[styles.item, isActive && styles.itemActive]}
|
||||
>
|
||||
<Text style={styles.flag}>{option.flag}</Text>
|
||||
<Text style={[styles.itemText, isActive && styles.itemTextActive]}>{option.label}</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function makeStyles(colors: ColorTokens) {
|
||||
return StyleSheet.create({
|
||||
chip: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 6,
|
||||
height: CHIP_HEIGHT,
|
||||
paddingHorizontal: 12,
|
||||
borderRadius: CHIP_HEIGHT / 2,
|
||||
borderWidth: 1,
|
||||
borderColor: colors.hairlineGray,
|
||||
backgroundColor: colors.pureWhite,
|
||||
overflow: "hidden",
|
||||
},
|
||||
flag: { fontSize: 14 },
|
||||
chipText: { fontFamily: fontFamily.semiBold, fontSize: 13, color: colors.ink },
|
||||
menu: {
|
||||
position: "absolute",
|
||||
right: 28,
|
||||
minWidth: 180,
|
||||
padding: 6,
|
||||
borderRadius: 14,
|
||||
borderWidth: 1,
|
||||
borderColor: colors.hairlineGray,
|
||||
backgroundColor: colors.pureWhite,
|
||||
elevation: 6,
|
||||
shadowColor: "#000",
|
||||
shadowOpacity: 0.18,
|
||||
shadowRadius: 16,
|
||||
shadowOffset: { width: 0, height: 8 },
|
||||
},
|
||||
item: { flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 12, paddingVertical: 11, borderRadius: 9, overflow: "hidden" },
|
||||
itemActive: { backgroundColor: colors.marigoldTint },
|
||||
itemText: { fontFamily: fontFamily.regular, fontSize: 14, color: colors.ink },
|
||||
itemTextActive: { fontFamily: fontFamily.semiBold, color: colors.marigoldDeep },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import { Animated, Easing, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { useReducedMotion } from "../../hooks/useReducedMotion";
|
||||
|
||||
const START_DELAY_MS = 250;
|
||||
const STAGGER_MS = 60;
|
||||
const DURATION_MS = 550;
|
||||
const RISE_PX = 18;
|
||||
|
||||
type Props = {
|
||||
/** Position in the entrance sequence — each step starts STAGGER_MS later. */
|
||||
index: number;
|
||||
children: ReactNode;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
};
|
||||
|
||||
/** Fades and slides its children up once on mount, staggered by `index`. */
|
||||
export function Reveal({ index, children, style }: Props) {
|
||||
const isReducedMotion = useReducedMotion();
|
||||
const [progress] = useState(() => new Animated.Value(0));
|
||||
|
||||
useEffect(() => {
|
||||
if (isReducedMotion) {
|
||||
progress.setValue(1);
|
||||
return;
|
||||
}
|
||||
const animation = Animated.timing(progress, {
|
||||
toValue: 1,
|
||||
duration: DURATION_MS,
|
||||
delay: START_DELAY_MS + index * STAGGER_MS,
|
||||
easing: Easing.bezier(0.2, 0.8, 0.2, 1),
|
||||
useNativeDriver: true,
|
||||
});
|
||||
animation.start();
|
||||
return () => animation.stop();
|
||||
}, [isReducedMotion, index, progress]);
|
||||
|
||||
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [RISE_PX, 0] });
|
||||
return <Animated.View style={[style, { opacity: progress, transform: [{ translateY }] }]}>{children}</Animated.View>;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { AccessibilityInfo } from "react-native";
|
||||
|
||||
/** Follows the OS "Reduce motion" setting (iOS + Android), live. */
|
||||
export function useReducedMotion(): boolean {
|
||||
const [isReduced, setIsReduced] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
AccessibilityInfo.isReduceMotionEnabled().then(setIsReduced).catch(() => {});
|
||||
const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", setIsReduced);
|
||||
return () => subscription.remove();
|
||||
}, []);
|
||||
|
||||
return isReduced;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { Animated } from "react-native";
|
||||
import { useReducedMotion } from "./useReducedMotion";
|
||||
|
||||
const SHAKE_STEPS = [-8, 7, -5, 3, 0];
|
||||
const STEP_MS = 70;
|
||||
|
||||
/** Short sideways shake for a form that was rejected (wrong password etc.). */
|
||||
export function useShake() {
|
||||
const [offset] = useState(() => new Animated.Value(0));
|
||||
const isReducedMotion = useReducedMotion();
|
||||
|
||||
const shake = useCallback(() => {
|
||||
if (isReducedMotion) return;
|
||||
offset.setValue(0);
|
||||
Animated.sequence(
|
||||
SHAKE_STEPS.map((toValue) => Animated.timing(offset, { toValue, duration: STEP_MS, useNativeDriver: true })),
|
||||
).start();
|
||||
}, [isReducedMotion, offset]);
|
||||
|
||||
return { shakeStyle: { transform: [{ translateX: offset }] }, shake };
|
||||
}
|
||||
@@ -245,8 +245,6 @@
|
||||
"logoutConfirmMessage": "Du wirst von deinem Konto abgemeldet und zum Login zurückgeschickt."
|
||||
},
|
||||
"auth": {
|
||||
"signInTitle": "PawFeed Login",
|
||||
"signUpTitle": "PawFeed Registrierung",
|
||||
"firstNamePlaceholder": "Vorname",
|
||||
"lastNamePlaceholder": "Nachname",
|
||||
"legalConsentLabel": "Ich akzeptiere die Nutzungsbedingungen und die Datenschutzerklärung.",
|
||||
@@ -256,8 +254,6 @@
|
||||
"signInButton": "Anmelden",
|
||||
"signUpButton": "Registrieren",
|
||||
"confirmButton": "Bestätigen",
|
||||
"noAccountLink": "Noch kein Account? Registrieren",
|
||||
"hasAccountLink": "Schon registriert? Anmelden",
|
||||
"verifyDeviceTitle": "Gerät bestätigen",
|
||||
"verifyDeviceHint": "Wir haben einen Code an {{email}} geschickt, um dieses Gerät zu bestätigen.",
|
||||
"verifyEmailTitle": "E-Mail bestätigen",
|
||||
@@ -265,11 +261,19 @@
|
||||
"signInIncompleteError": "Anmeldung unvollständig — Status: {{status}}",
|
||||
"signUpIncompleteError": "Registrierung unvollständig — Status: {{status}}",
|
||||
"googleButton": "Mit Google anmelden",
|
||||
"orDivider": "oder",
|
||||
"googleSignInError": "Anmeldung mit Google fehlgeschlagen. Bitte versuche es erneut.",
|
||||
"googleNeedsSignUpError": "Für dieses Google-Konto existiert noch kein PawFeed-Account. Bitte über \"Registrieren\" fortfahren, um den Nutzungsbedingungen zuzustimmen.",
|
||||
"appleSignInError": "Anmeldung mit Apple fehlgeschlagen. Bitte versuche es erneut.",
|
||||
"appleNeedsSignUpError": "Für diese Apple-ID existiert noch kein PawFeed-Account. Bitte über \"Registrieren\" fortfahren, um den Nutzungsbedingungen zuzustimmen."
|
||||
"appleNeedsSignUpError": "Für diese Apple-ID existiert noch kein PawFeed-Account. Bitte über \"Registrieren\" fortfahren, um den Nutzungsbedingungen zuzustimmen.",
|
||||
"tagline": "Das soziale Netzwerk für Tiere",
|
||||
"welcomeBack": "Willkommen zurück",
|
||||
"welcomeBackHint": "Schau, was dein Tier verpasst hat.",
|
||||
"signUpHeading": "Konto erstellen",
|
||||
"signUpHint": "Gleich bekommt dein Tier sein eigenes Profil.",
|
||||
"continueWith": "oder weiter mit",
|
||||
"noAccountPrompt": "Noch kein Account?",
|
||||
"hasAccountPrompt": "Schon registriert?",
|
||||
"consentFirstHint": "Bitte setz zuerst den Haken bei den Nutzungsbedingungen, dann kannst du dich auch so registrieren."
|
||||
},
|
||||
"onboarding": {
|
||||
"addPetTitle": "Tier hinzufügen",
|
||||
|
||||
@@ -245,8 +245,6 @@
|
||||
"logoutConfirmMessage": "You'll be signed out of your account and sent back to the login screen."
|
||||
},
|
||||
"auth": {
|
||||
"signInTitle": "PawFeed Login",
|
||||
"signUpTitle": "PawFeed Sign Up",
|
||||
"firstNamePlaceholder": "First name",
|
||||
"lastNamePlaceholder": "Last name",
|
||||
"legalConsentLabel": "I accept the Terms of Service and the Privacy Policy.",
|
||||
@@ -256,8 +254,6 @@
|
||||
"signInButton": "Sign in",
|
||||
"signUpButton": "Sign up",
|
||||
"confirmButton": "Confirm",
|
||||
"noAccountLink": "No account yet? Sign up",
|
||||
"hasAccountLink": "Already have an account? Sign in",
|
||||
"verifyDeviceTitle": "Confirm device",
|
||||
"verifyDeviceHint": "We sent a code to {{email}} to confirm this device.",
|
||||
"verifyEmailTitle": "Confirm email",
|
||||
@@ -265,11 +261,19 @@
|
||||
"signInIncompleteError": "Sign-in incomplete — status: {{status}}",
|
||||
"signUpIncompleteError": "Sign-up incomplete — status: {{status}}",
|
||||
"googleButton": "Continue with Google",
|
||||
"orDivider": "or",
|
||||
"googleSignInError": "Google sign-in failed. Please try again.",
|
||||
"googleNeedsSignUpError": "There's no PawFeed account for this Google account yet. Please continue via \"Sign up\" to accept the Terms of Service.",
|
||||
"appleSignInError": "Apple sign-in failed. Please try again.",
|
||||
"appleNeedsSignUpError": "There's no PawFeed account for this Apple ID yet. Please continue via \"Sign up\" to accept the Terms of Service."
|
||||
"appleNeedsSignUpError": "There's no PawFeed account for this Apple ID yet. Please continue via \"Sign up\" to accept the Terms of Service.",
|
||||
"tagline": "The social network for pets",
|
||||
"welcomeBack": "Welcome back",
|
||||
"welcomeBackHint": "See what your pet has missed.",
|
||||
"signUpHeading": "Create account",
|
||||
"signUpHint": "Your pet gets its own profile in a minute.",
|
||||
"continueWith": "or continue with",
|
||||
"noAccountPrompt": "No account yet?",
|
||||
"hasAccountPrompt": "Already registered?",
|
||||
"consentFirstHint": "Please tick the Terms of Service box first, then you can sign up this way too."
|
||||
},
|
||||
"onboarding": {
|
||||
"addPetTitle": "Add pet",
|
||||
|
||||
Reference in new issue
Block a user