-
Notifications
You must be signed in to change notification settings - Fork 2
/
socialLogin.tsx
50 lines (42 loc) · 1.32 KB
/
socialLogin.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react'
import { Platform, View } from 'react-native'
import AppleAuth, { AppleAuthProps } from './apple'
import FacebookAuth, { FacebookAuthProps } from './facebook'
import GoogleAuth, { GoogleAuthProps } from './google'
import InstagramAuth, { InstagramAuthProps } from './instagram'
type Props = FacebookAuthProps &
GoogleAuthProps &
InstagramAuthProps &
AppleAuthProps & {
enableInstagram?: boolean
onSignInSuccess: (provider: string, token: string) => void
onError: (error: string) => void
onCancel?: () => void
}
/**
* expo social media login component
* @param enableInstagram boolean to enable Instagram sign in
*/
const SocialAuth = (props: Props) => {
const isIos = Platform.OS === 'ios'
return (
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-evenly'
}}
>
<GoogleAuth {...props} onSuccess={(token) => props.onSignInSuccess('google', token)} />
<FacebookAuth {...props} onSuccess={(token) => props.onSignInSuccess('facebook', token)} />
{props.enableInstagram && (
<InstagramAuth
{...props}
onSuccess={(token) => props.onSignInSuccess('instagram', token)}
/>
)}
{isIos && <AppleAuth {...props} />}
</View>
)
}
export default SocialAuth