forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {type ReactElement} from 'react'
2import {View} from 'react-native'
3import {type ComAtprotoServerDescribeServer} from '@atproto/api'
4import {msg} from '@lingui/core/macro'
5import {useLingui} from '@lingui/react'
6import {Trans} from '@lingui/react/macro'
7
8import {atoms as a, useTheme} from '#/alf'
9import {Admonition} from '#/components/Admonition'
10import {InlineLinkText} from '#/components/Link'
11import {Text} from '#/components/Typography'
12
13export const Policies = ({
14 serviceDescription,
15}: {
16 serviceDescription: ComAtprotoServerDescribeServer.OutputSchema
17}) => {
18 const t = useTheme()
19 const {_} = useLingui()
20
21 if (!serviceDescription) {
22 return <View />
23 }
24
25 const tos = validWebLink(serviceDescription.links?.termsOfService)
26 const pp = validWebLink(serviceDescription.links?.privacyPolicy)
27
28 if (!tos && !pp) {
29 return (
30 <View style={[a.gap_sm]}>
31 <Admonition type="info">
32 <Trans>
33 This service has not provided terms of service or a privacy policy.
34 </Trans>
35 </Admonition>
36 </View>
37 )
38 }
39
40 let els: ReactElement<any>
41 if (tos && pp) {
42 els = (
43 <Trans>
44 By creating an account you agree to the{' '}
45 <InlineLinkText
46 label={_(msg`Read the Bluesky Terms of Service`)}
47 key="tos"
48 to={tos}>
49 Terms of Service
50 </InlineLinkText>{' '}
51 and{' '}
52 <InlineLinkText
53 label={_(msg`Read the Bluesky Privacy Policy`)}
54 key="pp"
55 to={pp}>
56 Privacy Policy
57 </InlineLinkText>
58 .
59 </Trans>
60 )
61 } else if (tos) {
62 els = (
63 <Trans>
64 By creating an account you agree to the{' '}
65 <InlineLinkText
66 label={_(msg`Read the Bluesky Terms of Service`)}
67 key="tos"
68 to={tos}>
69 Terms of Service
70 </InlineLinkText>
71 .
72 </Trans>
73 )
74 } else if (pp) {
75 els = (
76 <Trans>
77 By creating an account you agree to the{' '}
78 <InlineLinkText
79 label={_(msg`Read the Bluesky Privacy Policy`)}
80 key="pp"
81 to={pp}>
82 Privacy Policy
83 </InlineLinkText>
84 .
85 </Trans>
86 )
87 } else {
88 return null
89 }
90
91 return els ? (
92 <Text style={[a.leading_snug, t.atoms.text_contrast_medium]}>{els}</Text>
93 ) : null
94}
95
96function validWebLink(url?: string): string | undefined {
97 return url && (url.startsWith('http://') || url.startsWith('https://'))
98 ? url
99 : undefined
100}