import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { LinearGradient } from 'expo-linear-gradient';
import Animated, { FadeInDown } from 'react-native-reanimated';
import { ShimmerEffect } from '../../../components/ui';
import { colors, gradients, spacing, typography, radius, shadows } from '../../../theme';
export interface SubscriptionCardProps {
/** Whether user has premium access (own or partner's) */
hasPremiumAccess: boolean;
/** Whether this is the user's own subscription (vs partner's) */
isOwnSubscription: boolean;
/** Formatted expiration/renewal date */
expirationDate: string;
/** Callback when upgrade button is pressed */
onUpgradePress: () => void;
/** Callback when manage subscription is pressed */
onManagePress: () => void;
/** Callback when restore purchases is pressed */
onRestorePress: () => void;
/** Whether restore is in progress */
isRestoring?: boolean;
/** Animation delay */
delay?: number;
}
const PREMIUM_FEATURES = [
{ icon: 'layers' as const, text: '50+ Premium Packs' },
{ icon: 'flame' as const, text: 'All Intensity Levels' },
{ icon: 'sparkles' as const, text: 'New Packs Weekly' },
];
export function SubscriptionCard({
hasPremiumAccess,
isOwnSubscription,
expirationDate,
onUpgradePress,
onManagePress,
onRestorePress,
isRestoring = false,
delay = 350,
}: SubscriptionCardProps) {
if (hasPremiumAccess) {
return (
);
}
return (
);
}
/** Premium member card - celebratory gold treatment */
function ProMemberCard({
isOwnSubscription,
expirationDate,
onManagePress,
}: {
isOwnSubscription: boolean;
expirationDate: string;
onManagePress: () => void;
}) {
return (
{/* Gold gradient border effect */}
{/* Header with badge */}
Pro Member
{isOwnSubscription
? `Renews ${expirationDate}`
: "Via partner's subscription"
}
{isOwnSubscription && (
Manage
)}
{/* Status row */}
All Packs Unlocked
Unlimited Access
);
}
/** Free user card - premium upsell with shimmer */
function FreeUserCard({
onUpgradePress,
onRestorePress,
isRestoring,
}: {
onUpgradePress: () => void;
onRestorePress: () => void;
isRestoring: boolean;
}) {
return (
{/* Gold gradient border */}
{/* Header */}
SAUCI PRO
{/* Features list */}
{PREMIUM_FEATURES.map((feature, index) => (
{feature.text}
))}
{/* CTA Button */}
Upgrade to Pro
{/* Restore link */}
{isRestoring ? "Restoring..." : "Restore Purchases"}
);
}
const styles = StyleSheet.create({
container: {
marginBottom: spacing.lg,
paddingHorizontal: spacing.lg,
},
shimmerContainer: {
borderRadius: radius.lg,
},
// Pro Member Card Styles
proCard: {
borderRadius: radius.lg,
overflow: 'hidden',
},
proBorderGradient: {
...StyleSheet.absoluteFill,
opacity: 0.3,
},
proCardInner: {
backgroundColor: colors.backgroundLight, // Solid/Flat background
margin: 1,
borderRadius: radius.lg - 1,
padding: spacing.md,
},
// ...
proBadge: {
width: 36,
height: 36,
borderRadius: 18,
justifyContent: 'center',
alignItems: 'center',
// Removed glow
},
// ...
manageButton: {
paddingHorizontal: spacing.md,
paddingVertical: spacing.sm,
borderRadius: radius.md,
backgroundColor: colors.background,
borderWidth: 1,
borderColor: colors.border,
},
// ...
proStatusRow: {
flexDirection: 'row',
marginTop: spacing.md,
paddingTop: spacing.md,
borderTopWidth: 1,
borderTopColor: colors.border,
gap: spacing.lg,
},
// ...
freeCardInner: {
backgroundColor: colors.backgroundLight, // Solid/Flat background
margin: 1,
borderRadius: radius.lg - 1,
padding: spacing.lg,
},
// ...
ctaButtonContainer: {
borderRadius: radius.md,
overflow: 'hidden',
// Removed glow
},
proHeader: {
flexDirection: 'row',
alignItems: 'center',
},
proHeaderText: {
flex: 1,
marginLeft: spacing.md,
},
proTitle: {
...typography.headline,
color: colors.premium.champagne,
fontWeight: '700',
},
proSubtitle: {
...typography.caption1,
color: colors.textTertiary,
marginTop: 2,
},
manageButtonText: {
...typography.subhead,
color: colors.premium.gold,
fontWeight: '600',
},
proStatusItem: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.xs,
},
proStatusText: {
...typography.caption1,
color: colors.textSecondary,
},
// Free User Card Styles
freeCard: {
borderRadius: radius.lg,
overflow: 'hidden',
},
freeBorderGradient: {
...StyleSheet.absoluteFill,
},
freeHeader: {
alignItems: 'center',
marginBottom: spacing.lg,
},
freeHeaderBadge: {
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: spacing.md,
paddingVertical: spacing.sm,
borderRadius: radius.full,
gap: spacing.xs,
},
freeHeaderBadgeText: {
...typography.caption1,
fontWeight: '800',
letterSpacing: 2,
color: colors.background,
},
featuresList: {
marginBottom: spacing.lg,
},
featureItem: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: spacing.sm,
},
featureIconContainer: {
width: 28,
height: 28,
borderRadius: 14,
backgroundColor: colors.premium.goldLight,
justifyContent: 'center',
alignItems: 'center',
marginRight: spacing.md,
},
featureText: {
...typography.body,
color: colors.text,
},
ctaButton: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
paddingVertical: spacing.md,
gap: spacing.sm,
},
ctaButtonText: {
...typography.headline,
color: colors.background,
fontWeight: '700',
},
restoreLink: {
alignItems: 'center',
marginTop: spacing.md,
padding: spacing.sm,
},
restoreLinkText: {
...typography.caption1,
color: colors.textTertiary,
},
});
export default SubscriptionCard;