import React from 'react'; import { View, Text } from 'react-native'; import { useTheme } from '../theme/ThemeProvider'; import { useTranslation } from 'react-i18next'; import SubscriptionButton from './SubscriptionButton'; import ManaIcon from './ManaIcon'; import colors from '~/tailwind.config.js'; export interface SubscriptionPlanProps { id: string; name: string; price: number; priceString: string; currencyCode: string; priceBreakdown?: string; monthlyMana: number; canGiftMana: boolean; popular?: boolean; billingCycle?: 'monthly' | 'yearly'; monthlyEquivalent?: number; isTeamSubscription?: boolean; isEnterpriseSubscription?: boolean; } interface SubscriptionCardProps { plan: SubscriptionPlanProps; onSelect: (planId: string) => void; isCurrentPlan?: boolean; isLegacy?: boolean; } export const SubscriptionCard: React.FC = ({ plan, onSelect, isCurrentPlan = false, isLegacy = false, }) => { const { isDark, themeVariant, tw } = useTheme(); const { t } = useTranslation(); const formatPrice = (plan: SubscriptionPlanProps) => { // Use priceString from RevenueCat if available, otherwise format the price return plan.priceString || `${plan.price.toFixed(2).replace('.', ',')}€`; }; // Theme-aware colors using the same system as MemoPreview and SettingsToggle const themeColors = (colors as any).theme?.extend?.colors; const textColor = isDark ? '#FFFFFF' : '#000000'; const secondaryTextColor = isDark ? 'rgba(255,255,255,0.7)' : 'rgba(0,0,0,0.7)'; const bgColor = isDark ? themeColors?.dark?.[themeVariant]?.contentBackground || '#1E1E1E' : themeColors?.[themeVariant]?.contentBackground || '#FFFFFF'; const borderColor = isDark ? themeColors?.dark?.[themeVariant]?.border || '#424242' : themeColors?.[themeVariant]?.border || '#e6e6e6'; const accentColor = '#4287f5'; // Konsistente Mana-Farbe (identisch mit Tailwind mana) const cardBgColor = isDark ? 'rgba(255,255,255,0.03)' : 'rgba(0,0,0,0.02)'; // Tier-specific background colors and sizes for Mana icon const getTierStyles = () => { switch (plan.id) { case 'free': return { bg: '#F5F5F5', icon: '#9E9E9E', bgSize: '30%' }; // Smallest background case 'Mana_Stream_Small_v1': case 'Mana_Stream_Small_Yearly_v1': return { bg: '#E3F2FD', icon: '#2196F3', bgSize: '45%' }; // Light blue 50 / Blue 500 case 'Mana_Stream_Medium_v1': case 'Mana_Stream_Medium_Yearly_v1': return { bg: '#BBDEFB', icon: '#1976D2', bgSize: '60%' }; // Light blue 100 / Blue 700 case 'Mana_Stream_Large_v1': case 'Mana_Stream_Large_Yearly_v1': return { bg: '#90CAF9', icon: '#1565C0', bgSize: '75%' }; // Light blue 200 / Blue 800 case 'Mana_Stream_Giant_v1': case 'Mana_Stream_Giant_Yearly_v1': return { bg: '#64B5F6', icon: '#0D47A1', bgSize: '90%' }; // Light blue 300 / Blue 900 - Max size default: // Legacy plans get a neutral blue and medium size return { bg: '#E1F5FE', icon: '#0288D1', bgSize: '50%' }; } }; const tierStyles = getTierStyles(); return ( {isCurrentPlan && ( {isLegacy ? t('subscription.legacy_plan', 'Legacy Plan') : t('subscription.current_plan', 'Current Plan')} )} {plan.popular && !isCurrentPlan && ( {t('subscription.popular', 'Popular')} )} {/* Tier Name - full width */} {plan.name} {/* Three column layout */} {/* Mana Icon with background */} {/* Inner container that grows */} {/* Mana Amount */} {plan.monthlyMana} {t('subscription.per_month', 'pro Monat')} {/* Price */} {formatPrice(plan)} {plan.billingCycle === 'yearly' ? t('subscription.per_year', 'pro Jahr') : t('subscription.per_month', 'pro Monat')} {plan.billingCycle === 'yearly' && plan.monthlyEquivalent && ( ({plan.monthlyEquivalent.toFixed(2).replace('.', ',')}€/Mo) )} {/* Button nur anzeigen wenn es NICHT der Free Plan ist */} {plan.id !== 'free' && ( onSelect(plan.id)} iconName={isCurrentPlan ? 'checkmark-circle-outline' : 'arrow-forward-outline'} variant={isCurrentPlan ? 'secondary' : plan.popular ? 'accent' : 'primary'} disabled={isCurrentPlan} /> )} ); }; export default SubscriptionCard;