import { View, Text, ScrollView, ActivityIndicator } from 'react-native' import React, { useEffect, useState } from 'react' import TabBar from '../themes/TabBar' import { ChevronLeftIcon } from 'react-native-heroicons/outline' import { widthPercentageToDP as wp, heightPercentageToDP as hp } from 'react-native-responsive-screen'; import { useNavigation } from '@react-navigation/native'; import { getPrivacyPolicy } from '../api'; export default function PrivacyPolicyScreen() { const navigation = useNavigation(); const [policies, setPolicies] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetchPrivacyPolicies(); }, []); const fetchPrivacyPolicies = async () => { try { setLoading(true); const data = await getPrivacyPolicy(); setPolicies(data); } catch (err) { setError('Failed to load privacy policies'); console.error('Error fetching privacy policies:', err); } finally { setLoading(false); } }; const renderContent = (content) => { // Split content into sections based on numbered points const sections = content.split(/\d+\./).filter(section => section.trim()); return sections.map((section, index) => { const lines = section.split('\n').filter(line => line.trim()); return ( {lines.map((line, lineIndex) => { // Check if line is a sub-point (starts with spaces) const isSubPoint = line.trim().startsWith('-') || line.trim().startsWith('•'); return ( {line.trim()} ); })} ); }); }; return ( } titleStyle={{ color: "black", fontWeight: "bold", fontSize: 20 }} prefixStyle={{ backgroundColor: "transparent" }} suffixStyle={{ backgroundColor: "white", borderWidth: 1, borderColor: "black" }} containerStyle="" suffixAction={() => navigation.goBack()} /> {loading ? ( ) : error ? ( {error} ) : policies.length > 0 ? ( policies.map((policy, index) => ( {policy.title} {renderContent(policy.content)} )) ) : ( No privacy policies available )} ); }