import { useState } from "react"; import { View, Text, TouchableOpacity, StyleSheet, Alert, KeyboardAvoidingView, Platform, ScrollView, } from "react-native"; import { router } from "expo-router"; import Animated, { FadeInDown, FadeInUp, } from "react-native-reanimated"; import { Ionicons } from "@expo/vector-icons"; import { GradientBackground, GlassCard, GlassButton, GlassInput } from "../../src/components/ui"; import { colors, spacing, radius, typography } from "../../src/theme"; export default function RedeemScreen() { const [email, setEmail] = useState(""); const [code, setCode] = useState(""); const [isLoading, setIsLoading] = useState(false); const [isRedeemed, setIsRedeemed] = useState(false); const [error, setError] = useState(null); const showError = (message: string) => { setError(message); if (Platform.OS !== 'web') { Alert.alert("Error", message); } }; const clearError = () => setError(null); const handleRedeem = async () => { clearError(); if (!email.trim()) { showError("Please enter your email address"); return; } if (!code.trim()) { showError("Please enter your redemption code"); return; } // Basic email validation const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(email.trim())) { showError("Please enter a valid email address"); return; } setIsLoading(true); // TODO: Wire up to backend // For now, just simulate a delay and show success await new Promise(resolve => setTimeout(resolve, 1500)); setIsLoading(false); setIsRedeemed(true); }; // Success screen if (isRedeemed) { return ( Code Redeemed! Your premium access has been activated for{'\n'} {email} Enjoy all premium question packs and features. router.back()} style={{ marginTop: spacing.lg }} > Back to Profile ); } return ( {/* Back Button */} router.back()} activeOpacity={0.7} > {/* Header */} Redeem Premium Enter your email and redemption code to unlock premium features {/* Form Card */} {/* Error Message */} {error && ( {error} )} {/* Form Fields */} { clearError(); setEmail(text); }} keyboardType="email-address" autoCapitalize="none" autoCorrect={false} icon={} /> { clearError(); setCode(text.toUpperCase()); }} autoCapitalize="characters" autoCorrect={false} icon={} /> Redeem Code {/* Info Text */} Redemption codes are provided through promotions and giveaways. Each code can only be used once. ); } const styles = StyleSheet.create({ container: { flex: 1, }, centeredContainer: { flex: 1, justifyContent: "center", alignItems: "center", }, centeredContent: { alignItems: "center", paddingHorizontal: spacing.lg, }, scrollContent: { flexGrow: 1, }, content: { flex: 1, paddingHorizontal: spacing.lg, paddingTop: 60, paddingBottom: spacing.xl, }, backButton: { width: 44, height: 44, borderRadius: 22, backgroundColor: colors.glass.background, justifyContent: "center", alignItems: "center", marginBottom: spacing.lg, }, headerContainer: { alignItems: "center", marginBottom: spacing.xl, }, logoContainer: { width: 80, height: 80, borderRadius: 40, backgroundColor: colors.primaryLight, justifyContent: "center", alignItems: "center", marginBottom: spacing.md, }, iconContainer: { width: 100, height: 100, borderRadius: 50, backgroundColor: colors.successLight, justifyContent: "center", alignItems: "center", marginBottom: spacing.lg, }, title: { ...typography.largeTitle, color: colors.text, marginBottom: spacing.xs, textAlign: "center", }, subtitle: { ...typography.body, color: colors.textSecondary, textAlign: "center", }, emailHighlight: { color: colors.primary, fontWeight: "600", }, hint: { ...typography.subhead, color: colors.textSecondary, textAlign: "center", marginTop: spacing.md, paddingHorizontal: spacing.md, }, formContainer: { marginBottom: spacing.lg, }, errorContainer: { flexDirection: "row", alignItems: "center", backgroundColor: colors.errorLight, padding: spacing.md, borderRadius: radius.md, marginBottom: spacing.md, gap: spacing.sm, }, errorText: { ...typography.subhead, color: colors.error, flex: 1, }, form: { gap: spacing.sm, }, infoContainer: { flexDirection: "row", alignItems: "flex-start", paddingHorizontal: spacing.sm, gap: spacing.sm, }, infoText: { ...typography.caption1, color: colors.textTertiary, flex: 1, lineHeight: 18, }, });