rebreak-monorepo/apps/rebreak-native/components/blocker/DeactivationExplainerSheet.tsx
chahinebrini d7b15e231a feat(theme): Dark Mode Wave 2 — blocker, mail, chat, community, notifications, all remaining screens
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>
2026-05-09 14:51:02 +02:00

234 lines
6.9 KiB
TypeScript

import { Modal, View, Text, Pressable, ScrollView, ActionSheetIOS, Platform, Alert } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useColors } from '../../lib/theme';
type Props = {
visible: boolean;
onClose: () => void;
/** User triggert "Atmen" → Deflector zur Urge-Page (Click-2 ende, kein Cooldown). */
onBreathe: () => void;
/** Click-3 Bestätigung — final destruktive Aktion via ActionSheet. */
onStartCooldown: (reason: string) => Promise<void>;
};
/**
* Click 2 of 3 (Cooldown-Friction).
*
* Erklärt was Cooldown bedeutet, bietet [Atmen] als primary Deflector an,
* und ein kleines [Cooldown trotzdem starten] das einen nativen ActionSheet
* zur finalen Bestätigung öffnet (Click 3).
*/
export function DeactivationExplainerSheet({
visible,
onClose,
onBreathe,
onStartCooldown,
}: Props) {
const { t } = useTranslation();
const colors = useColors();
const [submitting, setSubmitting] = useState(false);
function showFinalConfirm() {
if (Platform.OS === 'ios') {
ActionSheetIOS.showActionSheetWithOptions(
{
title: t('blocker.deactivation_actionsheet_title'),
message: t('blocker.deactivation_actionsheet_message'),
options: [t('common.cancel'), t('blocker.deactivation_start_cta')],
destructiveButtonIndex: 1,
cancelButtonIndex: 0,
},
async (idx) => {
if (idx === 1) await runCooldown();
},
);
} else {
// Android Fallback
Alert.alert(
t('blocker.deactivation_actionsheet_title'),
t('blocker.deactivation_actionsheet_message'),
[
{ text: t('common.cancel'), style: 'cancel' },
{ text: t('blocker.deactivation_start_cta'), style: 'destructive', onPress: runCooldown },
],
);
}
}
async function runCooldown() {
setSubmitting(true);
try {
await onStartCooldown('user_requested_deactivation');
onClose();
} catch (e: any) {
Alert.alert(t('common.error'), e?.message ?? t('blocker.deactivation_failed_msg'));
} finally {
setSubmitting(false);
}
}
return (
<Modal
visible={visible}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={onClose}
>
<View style={{ flex: 1, backgroundColor: colors.bg }}>
{/* Header */}
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 16,
paddingTop: 14,
paddingBottom: 12,
borderBottomWidth: 1,
borderBottomColor: colors.border,
}}
>
<Pressable onPress={onClose} hitSlop={10}>
<Text style={{ fontSize: 16, fontFamily: 'Nunito_400Regular', color: colors.textMuted }}>
{t('common.back')}
</Text>
</Pressable>
<Text style={{ fontSize: 16, fontFamily: 'Nunito_700Bold', color: colors.text }}>
{t('blocker.deactivation_heading')}
</Text>
<View style={{ width: 50 }} />
</View>
<ScrollView contentContainerStyle={{ padding: 20, gap: 18 }}>
<Text style={{ fontSize: 22, fontFamily: 'Nunito_800ExtraBold', color: colors.text }}>
{t('blocker.deactivation_title')}
</Text>
<Text
style={{
fontSize: 15,
fontFamily: 'Nunito_400Regular',
color: colors.textMuted,
lineHeight: 22,
}}
>
{t('blocker.deactivation_intro')}
</Text>
{/* Was passiert */}
<View style={{ gap: 12 }}>
<BulletRow
icon="time-outline"
title={t('blocker.deactivation_bullet1_title')}
text={t('blocker.deactivation_bullet1_text')}
/>
<BulletRow
icon="refresh-outline"
title={t('blocker.deactivation_bullet2_title')}
text={t('blocker.deactivation_bullet2_text')}
/>
<BulletRow
icon="leaf-outline"
title={t('blocker.deactivation_bullet3_title')}
text={t('blocker.deactivation_bullet3_text')}
/>
</View>
<View style={{ height: 12 }} />
{/* Primary Deflector */}
<Pressable
onPress={onBreathe}
style={({ pressed }) => ({
opacity: pressed ? 0.85 : 1,
})}
>
<View style={{
backgroundColor: '#16a34a',
borderRadius: 14,
paddingVertical: 16,
paddingHorizontal: 16,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 10,
}}>
<Ionicons name="leaf" size={18} color="#fff" />
<Text style={{ fontSize: 15, fontFamily: 'Nunito_700Bold', color: '#fff' }}>
{t('blocker.deactivation_breathe_cta')}
</Text>
</View>
</Pressable>
{/* Destructive secondary */}
<Pressable
onPress={showFinalConfirm}
disabled={submitting}
hitSlop={8}
style={({ pressed }) => ({
opacity: pressed || submitting ? 0.5 : 1,
alignSelf: 'center',
paddingVertical: 12,
})}
>
<Text
style={{
fontSize: 13,
fontFamily: 'Nunito_400Regular',
color: '#dc2626',
}}
>
{submitting ? t('blocker.deactivation_starting') : t('blocker.deactivation_start_anyway')}
</Text>
</Pressable>
</ScrollView>
</View>
</Modal>
);
}
function BulletRow({
icon,
title,
text,
}: {
icon: React.ComponentProps<typeof Ionicons>['name'];
title: string;
text: string;
}) {
const colors = useColors();
return (
<View style={{ flexDirection: 'row', gap: 12 }}>
<View
style={{
width: 36,
height: 36,
borderRadius: 10,
backgroundColor: colors.surfaceElevated,
alignItems: 'center',
justifyContent: 'center',
}}
>
<Ionicons name={icon} size={18} color={colors.textMuted} />
</View>
<View style={{ flex: 1 }}>
<Text style={{ fontSize: 14, fontFamily: 'Nunito_700Bold', color: colors.text }}>
{title}
</Text>
<Text
style={{
fontSize: 12,
fontFamily: 'Nunito_400Regular',
color: colors.textMuted,
marginTop: 2,
lineHeight: 17,
}}
>
{text}
</Text>
</View>
</View>
);
}