## Duo-Style Onboarding (Foundation + alle Slides) Self-contained Onboarding-Flow mit Lyra-Mascot ersetzt das Spotlight-POC vom vorherigen Iteration. Slides leben unter `components/onboarding/slides/`. - Foundation: OnboardingShell (Progress + ScrollView + sticky CTABar), LyraBubble (Rive-Avatar + animierte Speech-Bubble), SlideProgress, CTABar - Slides: Welcome, Privacy (4 Versprechen), Nickname (inline + PATCH /me), DigaChoice (Ja/Nein-Branch), DigaCode (redeem-Endpoint + inline-Errors), Plan (Pro/Legend cards, monthly/yearly toggle, 2 Monate gratis, Härtefall- Mailto), Payment (RevenueCat-Dev-Stub bis Phase-0), Protection (activate + PermissionDeniedSheet-Wiring), Done (animierter Checkmark + Streak-Day-1) - State-Machine in app/onboarding/index.tsx: 9 Slides, DiGA-Branch, Resume- on-launch via slideFromStep(me.onboardingStep) - Routing-gate in (app)/_layout.tsx: step != 'done' → /onboarding - Backend Profile.onboardingStep enum extended: welcome | account | plan | pre_protection | done (+ legacy nickname/block) - Backend diga redeem: step='pre_protection' (NICHT 'done') — User muss noch durch Protection-Slide für NEFilter/VPN-Aktivierung - Locale-Keys (de/en/fr/ar): onboarding.lyra.<slide>.body, .cta_primary, Plan-Tier-Details (3,99/7,99 €/Mo, 39,90/79,90 €/Jahr mit 2 Monaten gratis), Härtefall-Link, DiGA-Code-Errors, Protection-Feat-Descriptions ## Cooldown Auto-Disable Race-Fix Bug: nach Cooldown-Ablauf bleib URL-Filter installiert (NEFilter in iOS- Settings sichtbar als "Läuft..."). Root-cause: `/api/cooldown/status` GET auto-resolved beim ersten expired-Hit; zweiter Call in applyCooldownDisableIfElapsed sah cooldownEndsAt=null → bail → forceDisable nie aufgerufen. - useProtectionState.fetchState: lokalen next.cooldown.endsAt state nutzen statt redundantem API-Call. Atomarer, race-frei. - AppState-Listener-Path unverändert (dort ist es der erste API-Call, kein Race). - lib/protection.forceDisable: console.log für Debug-Visibility. ## iOS NEFilter Robust-Disable (Native) `removeFromPreferences()` alleine ist auf iOS 18+ unzuverlässig — Settings- UI zeigt "Läuft..." obwohl Provider beendet sein sollte. 2-Step-Pattern: 1. loadFromPreferences 2. isEnabled = false + saveToPreferences (stoppt Filter-Daemon) 3. removeFromPreferences (Config-Eintrag aus Settings) Quelle: Apple-Developer-Forums + eigene Empirie. Pattern wird auch in PermissionDeniedSheet's resetUrlFilter genutzt (analog). ## Family Controls jetzt immer aktiv Apple-Entitlement seit 2026-05 für ReBreak approved (TestFlight-akzeptiert). `familyControlsEnabled: true` hart in app.config.ts (kein Env-Var-Gating mehr). "Bald verfügbar"-Placeholder in blocker.tsx entfernt — App-Lock-Toggle ist jetzt voll funktional auf iOS. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
152 lines
4.4 KiB
TypeScript
152 lines
4.4 KiB
TypeScript
import { useState } from 'react';
|
|
import { Text, TextInput, View } from 'react-native';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { Ionicons } from '@expo/vector-icons';
|
|
import { useColors } from '../../../lib/theme';
|
|
import { apiFetch } from '../../../lib/api';
|
|
import { invalidateMe } from '../../../hooks/useMe';
|
|
import { OnboardingShell } from '../OnboardingShell';
|
|
import { LyraBubble } from '../LyraBubble';
|
|
import { CTABar } from '../CTABar';
|
|
|
|
type RedeemError = 'not_found' | 'already_used' | 'expired' | 'invalid_input';
|
|
|
|
export function DigaCodeSlide({
|
|
onSuccess,
|
|
onBack,
|
|
current,
|
|
total,
|
|
}: {
|
|
/** Wird gerufen wenn der Code erfolgreich eingelöst wurde. Backend hat dann
|
|
* plan='legend' + onboarding_step='pre_protection' gesetzt. */
|
|
onSuccess: () => void;
|
|
/** Zurück zum DigaChoiceSlide (User hat sich's anders überlegt). */
|
|
onBack: () => void;
|
|
current: number;
|
|
total: number;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const colors = useColors();
|
|
const [code, setCode] = useState('');
|
|
const [submitting, setSubmitting] = useState(false);
|
|
const [errorKey, setErrorKey] = useState<RedeemError | null>(null);
|
|
|
|
const trimmed = code.trim();
|
|
const valid = trimmed.length >= 6;
|
|
|
|
async function redeem() {
|
|
if (!valid || submitting) return;
|
|
setSubmitting(true);
|
|
setErrorKey(null);
|
|
try {
|
|
await apiFetch('/api/onboarding/redeem-diga-code', {
|
|
method: 'POST',
|
|
body: { code: trimmed },
|
|
});
|
|
invalidateMe();
|
|
onSuccess();
|
|
} catch (e: any) {
|
|
// apiFetch wirft Error mit `code` Feld bei strukturierten 4xx
|
|
const code = (e?.code ?? e?.data?.error) as RedeemError | undefined;
|
|
setErrorKey(code ?? 'not_found');
|
|
} finally {
|
|
setSubmitting(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<OnboardingShell
|
|
current={current}
|
|
total={total}
|
|
cta={
|
|
<CTABar
|
|
primaryLabel={t('onboarding.diga_code.cta_primary')}
|
|
onPrimary={redeem}
|
|
primaryDisabled={!valid}
|
|
primaryLoading={submitting}
|
|
secondaryLabel={t('onboarding.diga_code.cta_secondary')}
|
|
onSecondary={onBack}
|
|
/>
|
|
}
|
|
>
|
|
<LyraBubble text={t('onboarding.lyra.diga_code.body')} emotion="thinking" />
|
|
|
|
<View style={{ marginTop: 24 }}>
|
|
<Text
|
|
style={{
|
|
fontFamily: 'Nunito_700Bold',
|
|
fontSize: 12,
|
|
color: colors.textMuted,
|
|
letterSpacing: 0.8,
|
|
marginBottom: 8,
|
|
}}
|
|
>
|
|
{t('onboarding.diga_code.label')}
|
|
</Text>
|
|
<TextInput
|
|
autoFocus
|
|
value={code}
|
|
onChangeText={(v) => {
|
|
setCode(v.toUpperCase());
|
|
if (errorKey) setErrorKey(null);
|
|
}}
|
|
onSubmitEditing={redeem}
|
|
placeholder="REBREAK-XXXX-XXX"
|
|
placeholderTextColor="#a3a3a3"
|
|
autoCapitalize="characters"
|
|
autoCorrect={false}
|
|
maxLength={32}
|
|
returnKeyType="done"
|
|
style={{
|
|
fontSize: 16,
|
|
lineHeight: 22,
|
|
paddingVertical: 14,
|
|
paddingHorizontal: 16,
|
|
color: colors.text,
|
|
fontFamily: 'Nunito_700Bold',
|
|
letterSpacing: 1,
|
|
backgroundColor: colors.surfaceElevated,
|
|
borderRadius: 12,
|
|
borderWidth: 2,
|
|
borderColor: errorKey ? colors.error : valid ? colors.brandOrange : 'transparent',
|
|
}}
|
|
/>
|
|
{errorKey ? (
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
gap: 6,
|
|
marginTop: 10,
|
|
paddingHorizontal: 2,
|
|
}}
|
|
>
|
|
<Ionicons name="alert-circle" size={16} color={colors.error} />
|
|
<Text
|
|
style={{
|
|
flex: 1,
|
|
fontFamily: 'Nunito_600SemiBold',
|
|
fontSize: 13,
|
|
color: colors.error,
|
|
}}
|
|
>
|
|
{t(`onboarding.diga_code.error_${errorKey}`)}
|
|
</Text>
|
|
</View>
|
|
) : (
|
|
<Text
|
|
style={{
|
|
marginTop: 8,
|
|
fontFamily: 'Nunito_400Regular',
|
|
fontSize: 12,
|
|
color: colors.textMuted,
|
|
}}
|
|
>
|
|
{t('onboarding.diga_code.hint')}
|
|
</Text>
|
|
)}
|
|
</View>
|
|
</OnboardingShell>
|
|
);
|
|
}
|