forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import React from 'react'
2import {View} from 'react-native'
3import {msg} from '@lingui/core/macro'
4import {useLingui} from '@lingui/react'
5import {Trans} from '@lingui/react/macro'
6
7import {useLoggedOutViewControls} from '#/state/shell/logged-out'
8import {useCloseAllActiveElements} from '#/state/util'
9import {Logo} from '#/view/icons/Logo'
10import {Logotype} from '#/view/icons/Logotype'
11import {atoms as a, useBreakpoints, useTheme} from '#/alf'
12import {Button, ButtonText} from '#/components/Button'
13import * as Dialog from '#/components/Dialog'
14import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
15import {Text} from '#/components/Typography'
16import {IS_NATIVE} from '#/env'
17
18export function SigninDialog() {
19 const {signinDialogControl: control} = useGlobalDialogsControlContext()
20 return (
21 <Dialog.Outer control={control}>
22 <Dialog.Handle />
23 <SigninDialogInner control={control} />
24 </Dialog.Outer>
25 )
26}
27
28function SigninDialogInner({}: {control: Dialog.DialogOuterProps['control']}) {
29 const t = useTheme()
30 const {_} = useLingui()
31 const {gtMobile} = useBreakpoints()
32 const {requestSwitchToAccount} = useLoggedOutViewControls()
33 const closeAllActiveElements = useCloseAllActiveElements()
34
35 const showSignIn = React.useCallback(() => {
36 closeAllActiveElements()
37 requestSwitchToAccount({requestedAccount: 'none'})
38 }, [requestSwitchToAccount, closeAllActiveElements])
39
40 const showCreateAccount = React.useCallback(() => {
41 closeAllActiveElements()
42 requestSwitchToAccount({requestedAccount: 'new'})
43 }, [requestSwitchToAccount, closeAllActiveElements])
44
45 return (
46 <Dialog.ScrollableInner
47 label={_(msg`Sign in to Bluesky or create a new account`)}
48 style={[gtMobile ? {width: 'auto', maxWidth: 420} : a.w_full]}>
49 <View style={[!IS_NATIVE && a.p_2xl]}>
50 <View
51 style={[
52 a.flex_row,
53 a.align_center,
54 a.justify_center,
55 a.gap_sm,
56 a.pb_lg,
57 ]}>
58 <Logo width={36} />
59 <View style={{paddingTop: 6}}>
60 <Logotype width={120} fill={t.atoms.text.color} />
61 </View>
62 </View>
63
64 <Text
65 style={[
66 a.text_lg,
67 a.text_center,
68 t.atoms.text,
69 a.pb_2xl,
70 a.leading_snug,
71 a.mx_auto,
72 {
73 maxWidth: 300,
74 },
75 ]}>
76 <Trans>
77 Sign in or create your account to join the conversation!
78 </Trans>
79 </Text>
80
81 <View style={[a.flex_col, a.gap_md]}>
82 <Button
83 variant="solid"
84 color="primary"
85 size="large"
86 onPress={showCreateAccount}
87 label={_(msg`Create an account`)}>
88 <ButtonText>
89 <Trans>Create an account</Trans>
90 </ButtonText>
91 </Button>
92
93 <Button
94 variant="solid"
95 color="secondary"
96 size="large"
97 onPress={showSignIn}
98 label={_(msg`Sign in`)}>
99 <ButtonText>
100 <Trans>Sign in</Trans>
101 </ButtonText>
102 </Button>
103 </View>
104
105 {IS_NATIVE && <View style={{height: 10}} />}
106 </View>
107
108 <Dialog.Close />
109 </Dialog.ScrollableInner>
110 )
111}