Auth / FaceID — eingeloggt bleiben funktioniert jetzt: - AppLock-Init idempotent: late re-init durch router.replace-Re-Mount behält locked-State (fixt Endlosschleife: unlock → re-mount → init reset → lock) - LockScreen-Auto-Prompt nur wenn AppState=active (verhindert silent FaceID- Fail wenn LockScreen während background-Event mountet — User sah dann nur Fallback-Button) - index.tsx: wenn Session schon in AsyncStorage liegt → router.replace zu /(app), Landing wird übersprungen; early-return nach allen Hooks (Rules of Hooks) - WebBrowser.dismissAuthSession vor openAuthSessionAsync (verhindert "Another web browser is already open" nach abgebrochenen OAuth-Flows) UI — iOS-Grouped-Look auf Settings + Profile: - Neue Theme-Tokens groupedBg (#F2F2F7 / #000) + card (#fff / #1c1c1e), identisch zu Apples systemGroupedBackground / secondarySystemGroupedBackground - settings.tsx + profile/index.tsx + profile/[userId].tsx: Page-BG → groupedBg - StreakSection / UrgeStatsCard / DemographicsAccordion / StatsBar / ApprovedDomainsList: Card-BG colors.surface → colors.card Mail-Connect — Outlook-Tile entschärft: - Microsoft hat App-Passwords für consumer-Outlook (.com/hotmail/live/msn) im September 2024 abgeschaltet, der bisherige Guide-Flow ist seit ~8 Monaten wirkungslos → AUTHENTICATIONFAILED - Tile bleibt sichtbar mit opacity 0.45, "Kommt bald"-Sub-Label, disabled=true - Provider-Typ um disabled? + disabledLabelKey? erweitert (wiederverwendbar) - Backend-OAuth-Plan unter backend/docs/mail-outlook-oauth-plan.md (mo) → Generisches AuthMethod-Framework (app_password | oauth) geplant Profile — Cooldown-Verlauf als Sparkline statt Endlos-Liste: - 8 Wochen-Buckets, Bar-Höhe nach Frequenz (cap 5/Woche), leere Wochen als 2px-Flatlines - Sub-Label: "{n} Cooldowns in 8 Wochen · Ø 1 pro {avg} Wochen · zuletzt {date}" - Neutral formuliert (Sucht-/Stigma-Sensibilität: Cooldown = Schutz-Pause, kein Rückfall) - useProfileData.ts liefert rawStartedAt (ISO) zusätzlich zum formatierten Wert - i18n-Keys unter profile.cooldown.* in DE + EN Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
211 lines
6.1 KiB
TypeScript
211 lines
6.1 KiB
TypeScript
import { View, Text } from 'react-native';
|
|
import { Ionicons } from '@expo/vector-icons';
|
|
import { useColors } from '../../lib/theme';
|
|
|
|
export type HelpedByEntry = {
|
|
key: 'breathing' | 'game' | 'talk' | 'other';
|
|
label: string;
|
|
count: number;
|
|
};
|
|
|
|
type Props = {
|
|
sessions: number;
|
|
overcome: number;
|
|
helpedBy: HelpedByEntry[];
|
|
topEmotion: string | null;
|
|
};
|
|
|
|
export function UrgeStatsCard({ sessions, overcome, helpedBy, topEmotion }: Props) {
|
|
const colors = useColors();
|
|
const overcomePct = sessions > 0 ? Math.round((overcome / sessions) * 100) : 0;
|
|
const totalHelped = helpedBy.reduce((sum, h) => sum + h.count, 0);
|
|
|
|
return (
|
|
<View style={{ marginHorizontal: 16, marginTop: 24 }}>
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
gap: 8,
|
|
marginBottom: 10,
|
|
}}
|
|
>
|
|
<Ionicons name="sparkles-outline" size={14} color={colors.textMuted} />
|
|
<Text
|
|
style={{
|
|
fontSize: 11,
|
|
color: colors.textMuted,
|
|
fontFamily: 'Nunito_700Bold',
|
|
letterSpacing: 0.8,
|
|
}}
|
|
>
|
|
LYRA INSIGHTS
|
|
</Text>
|
|
</View>
|
|
|
|
<View
|
|
style={{
|
|
backgroundColor: colors.card,
|
|
borderWidth: 1,
|
|
borderColor: colors.border,
|
|
borderRadius: 14,
|
|
padding: 16,
|
|
}}
|
|
>
|
|
<Text
|
|
style={{
|
|
fontSize: 12,
|
|
color: colors.textMuted,
|
|
fontFamily: 'Nunito_400Regular',
|
|
}}
|
|
>
|
|
Letzte 30 Tage
|
|
</Text>
|
|
|
|
{sessions === 0 ? (
|
|
<Text
|
|
style={{
|
|
marginTop: 8,
|
|
fontSize: 13,
|
|
color: colors.text,
|
|
fontFamily: 'Nunito_600SemiBold',
|
|
}}
|
|
>
|
|
Noch keine SOS-Session. Lyra ist da, wenn du sie brauchst.
|
|
</Text>
|
|
) : (
|
|
<>
|
|
<View style={{ marginTop: 6, flexDirection: 'row', alignItems: 'baseline', gap: 6 }}>
|
|
<Text
|
|
style={{
|
|
fontSize: 22,
|
|
color: colors.text,
|
|
fontFamily: 'Nunito_700Bold',
|
|
}}
|
|
>
|
|
{sessions}
|
|
</Text>
|
|
<Text
|
|
style={{
|
|
fontSize: 13,
|
|
color: colors.text,
|
|
fontFamily: 'Nunito_600SemiBold',
|
|
}}
|
|
>
|
|
SOS-Sessions, {overcome} bewältigt
|
|
</Text>
|
|
</View>
|
|
|
|
<View
|
|
style={{
|
|
marginTop: 8,
|
|
height: 6,
|
|
backgroundColor: colors.surfaceElevated,
|
|
borderRadius: 999,
|
|
overflow: 'hidden',
|
|
}}
|
|
>
|
|
<View
|
|
style={{
|
|
height: '100%',
|
|
width: `${overcomePct}%`,
|
|
backgroundColor: colors.success,
|
|
borderRadius: 999,
|
|
}}
|
|
/>
|
|
</View>
|
|
<Text
|
|
style={{
|
|
marginTop: 4,
|
|
fontSize: 11,
|
|
color: colors.textMuted,
|
|
fontFamily: 'Nunito_400Regular',
|
|
}}
|
|
>
|
|
{overcomePct}% bewältigt
|
|
</Text>
|
|
|
|
{totalHelped > 0 ? (
|
|
<View style={{ marginTop: 16 }}>
|
|
<Text
|
|
style={{
|
|
fontSize: 12,
|
|
color: colors.text,
|
|
fontFamily: 'Nunito_600SemiBold',
|
|
marginBottom: 8,
|
|
}}
|
|
>
|
|
Was hat geholfen
|
|
</Text>
|
|
{helpedBy.map((h) => {
|
|
const pct = totalHelped > 0 ? (h.count / totalHelped) * 100 : 0;
|
|
return (
|
|
<View key={h.key} style={{ marginBottom: 8 }}>
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
justifyContent: 'space-between',
|
|
marginBottom: 3,
|
|
}}
|
|
>
|
|
<Text
|
|
style={{
|
|
fontSize: 12,
|
|
color: colors.text,
|
|
fontFamily: 'Nunito_600SemiBold',
|
|
}}
|
|
>
|
|
{h.label}
|
|
</Text>
|
|
<Text
|
|
style={{
|
|
fontSize: 11,
|
|
color: colors.textMuted,
|
|
fontFamily: 'Nunito_400Regular',
|
|
}}
|
|
>
|
|
{h.count} {h.count === 1 ? 'Session' : 'Sessions'}
|
|
</Text>
|
|
</View>
|
|
<View
|
|
style={{
|
|
height: 4,
|
|
backgroundColor: colors.surfaceElevated,
|
|
borderRadius: 999,
|
|
overflow: 'hidden',
|
|
}}
|
|
>
|
|
<View
|
|
style={{
|
|
height: '100%',
|
|
width: `${pct}%`,
|
|
backgroundColor: colors.brandOrange,
|
|
borderRadius: 999,
|
|
}}
|
|
/>
|
|
</View>
|
|
</View>
|
|
);
|
|
})}
|
|
</View>
|
|
) : null}
|
|
|
|
{topEmotion ? (
|
|
<Text
|
|
style={{
|
|
marginTop: 8,
|
|
fontSize: 12,
|
|
color: colors.textMuted,
|
|
fontFamily: 'Nunito_400Regular',
|
|
}}
|
|
>
|
|
Häufigste Emotion: {topEmotion}
|
|
</Text>
|
|
) : null}
|
|
</>
|
|
)}
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|