import { Image, ImageStyle, ImageSource } from 'expo-image' import { FC, useCallback } from 'react' import { googleIcon } from '@/constants' import { useColorScheme } from '@/contexts' import { Button, ButtonProps, Icon } from '@/design-system' import i18n from '@/i18n' type SocialMediaType = 'apple' | 'facebook' | 'google' const socialButtonVariants: { [key in SocialMediaType]: { source?: { light: ImageSource; dark?: ImageSource } text: () => string } } = { apple: { text: () => i18n.t('sign_in_screen.sign_in_by_apple'), }, facebook: { text: () => i18n.t('sign_in_screen.sign_in_by_facebook'), }, google: { source: { light: googleIcon }, text: () => i18n.t('sign_in_screen.sign_in_by_google'), }, } type SocialButtonProps = { onPress: () => void type: SocialMediaType } & ButtonProps export const SocialButton: FC = ({ type = 'google', ...rest }) => { const { colorScheme } = useColorScheme() const { source, text } = socialButtonVariants[type] const generateLeftElement = useCallback( (type: SocialMediaType) => { switch (type) { case 'apple': return ( ) case 'facebook': // @ts-expect-error icon type accepts only ColorNames in order to make suggestion in code, but strings works as well return case 'google': return ( ) } }, [colorScheme, source] ) return ( ) } SocialButton.displayName = 'SocialButton'