import React from 'react' import {StyleSheet, View} from 'react-native' import { FontAwesomeIcon, FontAwesomeIconStyle, } from '@fortawesome/react-native-fontawesome' import {ComAtprotoServerDescribeServer} from '@atproto/api' import {TextLink} from '../../util/Link' import {Text} from '../../util/text/Text' import {s, colors} from 'lib/styles' import {usePalette} from 'lib/hooks/usePalette' type ServiceDescription = ComAtprotoServerDescribeServer.OutputSchema export const Policies = ({ serviceDescription, needsGuardian, }: { serviceDescription: ServiceDescription needsGuardian: boolean }) => { const pal = usePalette('default') if (!serviceDescription) { return } const tos = validWebLink(serviceDescription.links?.termsOfService) const pp = validWebLink(serviceDescription.links?.privacyPolicy) if (!tos && !pp) { return ( This service has not provided terms of service or a privacy policy. ) } const els = [] if (tos) { els.push( , ) } if (pp) { els.push( , ) } if (els.length === 2) { els.splice( 1, 0, {' '} and{' '} , ) } return ( By creating an account you agree to the {els}. {needsGuardian && ( If you are not yet an adult according to the laws of your country, your parent or legal guardian must read these Terms on your behalf. )} ) } function validWebLink(url?: string): string | undefined { return url && (url.startsWith('http://') || url.startsWith('https://')) ? url : undefined } const styles = StyleSheet.create({ policies: { flexDirection: 'column', gap: 8, }, errorIcon: { borderWidth: 1, borderColor: colors.white, borderRadius: 30, width: 16, height: 16, alignItems: 'center', justifyContent: 'center', }, })