Wave 2 = ALLE app-files die in Wave 1 noch hardcoded waren. Komplette App-weit
theme-aware-Migration jetzt durch. Legacy `import { colors }` flat export
vollständig eliminiert.
Migrated this wave:
Top-level Screens:
- app/urge.tsx (makeStyles factory mit ~20 colors)
- app/room.tsx + dm.tsx + games.tsx
- app/(app)/chat.tsx + mail.tsx + coach.tsx + notifications.tsx
- app/profile/[userId].tsx + profile/edit.tsx (INPUT_STYLE in body moved)
- app/debug.tsx + auth/callback.tsx
Blocker (7):
- AddDomainSheet, CooldownBanner, DeactivationExplainerSheet, DomainGrid,
ProtectionCard, ProtectionDetailsSheet, ProtectionLockedCard
Mail (3):
- ConnectMailSheet, EditMailAccountSheet, MailEmptyState
Chat (1):
- ChatBubble, ChatInput
Community/Posts/Notifications:
- PostCard, PostCardSkeleton, ComposeCard, PostCommentsSheet
- NotificationsDropdown
- StreakBadge (Nativewind classes durch inline dynamic styles ersetzt)
Reusable Sheets:
- WheelPickerModal, OptionsBottomSheet, DeviceLimitReachedSheet
Urge subsystem (5):
- InlineRatingDrawer, ShareSuccessDrawer, UrgeStats, SosFeedbackModal,
Breathing
Profile components:
- DigaMissionBanner
Pattern: useColors() hook in component body, makeStyles(colors) factory wo
StyleSheet.create vorher hardcoded war. 11 base-tokens (bg/surface/
surfaceElevated/border/text/textMuted/brandOrange/brandBlue/success/error/
warning) nutzen colors.light vs colors.dark scheme.
Bewusst NICHT migriert (semantic colors):
- DigaMissionBanner amber (#fffbeb, #854d0e) — DiGA-brand, nicht neutral
- Lyra-thinking #3b82f6 in urge.tsx — Lyra-brand-color
- scrollDownBtn #374151 — intentional dark floating-button
TS clean. Test: Settings → Theme → Dark — alle screens sollen jetzt dunkel
werden ohne white-flashes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
137 lines
4.4 KiB
TypeScript
137 lines
4.4 KiB
TypeScript
import { View, Text, Pressable } from 'react-native';
|
|
import { Ionicons } from '@expo/vector-icons';
|
|
import { useTranslation } from 'react-i18next';
|
|
import type { ProtectionState } from '../../lib/protection';
|
|
import { useColors } from '../../lib/theme';
|
|
|
|
type Props = {
|
|
state: ProtectionState;
|
|
/** Click-1 of 3-Click-Cooldown-Trigger — öffnet ProtectionDetailsSheet. */
|
|
onPressSettings: () => void;
|
|
};
|
|
|
|
/**
|
|
* Wird gezeigt sobald Family Controls aktiv ist — der Schutz ist dann
|
|
* "locked in" und kann nur über den Cooldown-Flow deaktiviert werden.
|
|
* Daher: KEINE Switches mehr, nur ein Settings-Icon das den 3-Click-Flow startet.
|
|
*/
|
|
export function ProtectionLockedCard({ state, onPressSettings }: Props) {
|
|
const { t } = useTranslation();
|
|
const colors = useColors();
|
|
const isCooldown = state.phase === 'cooldownActive';
|
|
const cardBg = isCooldown ? '#fef3c7' : '#dcfce7';
|
|
const cardBorder = isCooldown ? '#fcd34d' : '#86efac';
|
|
const iconBg = isCooldown ? '#fde68a' : '#bbf7d0';
|
|
const iconColor = isCooldown ? '#d97706' : '#16a34a';
|
|
|
|
const subtitle = (() => {
|
|
if (isCooldown) return t('blocker.protection_subtitle_cooldown');
|
|
if (state.plan === 'legend') {
|
|
return t('blocker.protection_subtitle_legend');
|
|
}
|
|
if (state.plan === 'pro') {
|
|
return t('blocker.protection_subtitle_pro');
|
|
}
|
|
return t('blocker.protection_subtitle_free', { count: state.blocklistCount });
|
|
})();
|
|
|
|
return (
|
|
<View
|
|
style={{
|
|
backgroundColor: cardBg,
|
|
borderWidth: 1,
|
|
borderColor: cardBorder,
|
|
borderRadius: 18,
|
|
padding: 14,
|
|
}}
|
|
>
|
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
|
|
<View
|
|
style={{
|
|
width: 44,
|
|
height: 44,
|
|
borderRadius: 14,
|
|
backgroundColor: iconBg,
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
}}
|
|
>
|
|
<Ionicons name="shield-checkmark" size={22} color={iconColor} />
|
|
</View>
|
|
<View style={{ flex: 1 }}>
|
|
<Text style={{ fontSize: 15, fontFamily: 'Nunito_700Bold', color: colors.text }}>
|
|
{t('blocker.protection_card_locked_title')}
|
|
</Text>
|
|
<Text
|
|
style={{
|
|
fontSize: 12,
|
|
fontFamily: 'Nunito_400Regular',
|
|
color: colors.textMuted,
|
|
marginTop: 2,
|
|
}}
|
|
>
|
|
{subtitle}
|
|
</Text>
|
|
</View>
|
|
|
|
<Pressable
|
|
onPress={onPressSettings}
|
|
hitSlop={10}
|
|
style={({ pressed }) => ({
|
|
opacity: pressed ? 0.6 : 1,
|
|
})}
|
|
accessibilityLabel={t('blocker.protection_settings_a11y')}
|
|
>
|
|
<View style={{
|
|
width: 36,
|
|
height: 36,
|
|
borderRadius: 18,
|
|
backgroundColor: colors.surface,
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
shadowColor: '#000',
|
|
shadowOffset: { width: 0, height: 1 },
|
|
shadowOpacity: 0.05,
|
|
shadowRadius: 2,
|
|
}}>
|
|
<Ionicons name="settings-outline" size={18} color={colors.textMuted} />
|
|
</View>
|
|
</Pressable>
|
|
</View>
|
|
|
|
{/* Stats nur wenn aktiv und kein Cooldown */}
|
|
{!isCooldown && (
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
gap: 10,
|
|
marginTop: 14,
|
|
paddingTop: 12,
|
|
borderTopWidth: 1,
|
|
borderTopColor: 'rgba(0,0,0,0.06)',
|
|
}}
|
|
>
|
|
<Stat label={t('blocker.protection_stat_domains')} value={formatCount(state.blocklistCount)} />
|
|
<Stat label={t('blocker.protection_stat_method')} value={t('blocker.protection_stat_method_native')} />
|
|
<Stat label={t('blocker.protection_stat_status')} value={t('blocker.protection_stat_status_live')} valueColor="#16a34a" />
|
|
</View>
|
|
)}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
function Stat({ label, value, valueColor }: { label: string; value: string; valueColor?: string }) {
|
|
const colors = useColors();
|
|
return (
|
|
<View style={{ flex: 1, alignItems: 'center' }}>
|
|
<Text style={{ fontSize: 16, fontFamily: 'Nunito_800ExtraBold', color: valueColor ?? colors.text }}>{value}</Text>
|
|
<Text style={{ fontSize: 11, fontFamily: 'Nunito_400Regular', color: colors.textMuted }}>{label}</Text>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
function formatCount(n: number): string {
|
|
if (n >= 1000) return `${Math.floor(n / 1000)}k+`;
|
|
return String(n);
|
|
}
|