import React from 'react'; import { Share, StyleSheet, Text, View, Pressable, Linking } from 'react-native'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import { Icon } from '../../../components/Icon'; import { Card, ScreenShell, Button } from '../../../components'; import { ServicesStackParamList } from '../../../navigation/types'; import { useTheme, fontFamily } from '../../../theme'; import { useSchemes } from '../hooks/useSchemes'; import { Accordion } from '../components/Accordion'; type Props = NativeStackScreenProps; export default function SchemeDetailScreen({ route, navigation }: Props) { const { schemeId } = route.params; const theme = useTheme(); const { schemes, bookmarks, toggleBookmark } = useSchemes(); const scheme = schemes.find((s) => s.id === schemeId); const isBookmarked = bookmarks.includes(schemeId); if (!scheme) { return ( Scheme not found. ); } const handleShare = async () => { try { await Share.share({ message: `${scheme.title}\n\n${scheme.description}\n\nLearn more on BankCBS!`, title: scheme.title, }); } catch (error) { console.error('Error sharing scheme', error); } }; const handleApply = async () => { if (scheme.isNew || scheme.type === 'GOVT_SCHEME') { navigation.navigate('SchemeEnrollment', { schemeId }); } else if (scheme.applyUrl) { const supported = await Linking.canOpenURL(scheme.applyUrl); if (supported) { await Linking.openURL(scheme.applyUrl); } } }; const rightContent = ( toggleBookmark(schemeId)} style={[styles.actionBtn, { backgroundColor: isBookmarked ? theme.tint(theme.colors.primary, 0.08) : theme.colors.surfaceMuted }]} > ); return ( {scheme.type.replace('_', ' ')} {scheme.category} {scheme.title} {scheme.description} About the Scheme {scheme.content} {scheme.benefits && ( Key Benefits {scheme.benefits.map((benefit, idx) => ( {benefit} ))} )} {scheme.eligibility && ( Eligibility Criteria {scheme.eligibility.map((criterion, idx) => ( {criterion} ))} )} {scheme.premiumInfo && ( Premium & Contributions {scheme.premiumInfo} )} {scheme.faqs && scheme.faqs.length > 0 && ( Frequently Asked Questions {scheme.faqs.map((faq, idx) => ( {faq.answer} ))} )} {scheme.applyUrl && (