mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {View, type ViewStyle} from 'react-native'
2import {msg, Trans} from '@lingui/macro'
3import {useLingui} from '@lingui/react'
4
5import {type Gate} from '#/lib/statsig/gates'
6import {useGate} from '#/lib/statsig/statsig'
7import {isWeb} from '#/platform/detection'
8import {useSession} from '#/state/session'
9import {useLoggedOutViewControls} from '#/state/shell/logged-out'
10import {Logo} from '#/view/icons/Logo'
11import {atoms as a, useTheme} from '#/alf'
12import {Button, ButtonText} from '#/components/Button'
13import {Text} from '#/components/Typography'
14
15interface LoggedOutCTAProps {
16 style?: ViewStyle
17 gateName: Gate
18}
19
20export function LoggedOutCTA({style, gateName}: LoggedOutCTAProps) {
21 const {hasSession} = useSession()
22 const {requestSwitchToAccount} = useLoggedOutViewControls()
23 const gate = useGate()
24 const t = useTheme()
25 const {_} = useLingui()
26
27 // Only show for logged-out users on web
28 if (hasSession || !isWeb) {
29 return null
30 }
31
32 // Check gate at the last possible moment to avoid counting users as exposed when they won't see the element
33 if (!gate(gateName)) {
34 return null
35 }
36
37 return (
38 <View style={[a.pb_md, style]}>
39 <View
40 style={[
41 a.flex_row,
42 a.align_center,
43 a.justify_between,
44 a.px_lg,
45 a.py_md,
46 a.rounded_md,
47 a.mb_xs,
48 t.atoms.bg_contrast_25,
49 ]}>
50 <View style={[a.flex_row, a.align_center, a.flex_1, a.pr_md]}>
51 <Logo width={30} style={[a.mr_md]} />
52 <View style={[a.flex_1]}>
53 <Text style={[a.text_lg, a.font_semi_bold, a.leading_snug]}>
54 <Trans>Join Bluesky</Trans>
55 </Text>
56 <Text
57 style={[
58 a.text_md,
59 a.font_medium,
60 a.leading_snug,
61 t.atoms.text_contrast_medium,
62 ]}>
63 <Trans>The open social network.</Trans>
64 </Text>
65 </View>
66 </View>
67 <Button
68 onPress={() => {
69 requestSwitchToAccount({requestedAccount: 'new'})
70 }}
71 label={_(msg`Create account`)}
72 size="small"
73 variant="solid"
74 color="primary">
75 <ButtonText>
76 <Trans>Create account</Trans>
77 </ButtonText>
78 </Button>
79 </View>
80 </View>
81 )
82}