import { StyleSheet } from 'react-native'; import { FlexView, ListSocial, LogoSelect, Spacing, Text } from '@reown/appkit-ui-react-native'; import { type SocialProvider, StringUtil } from '@reown/appkit-common-react-native'; import { EventsController, RouterController } from '@reown/appkit-core-react-native'; export interface SocialLoginListProps { options: readonly SocialProvider[]; disabled?: boolean; } const MAX_OPTIONS = 6; export function SocialLoginList({ options, disabled }: SocialLoginListProps) { const showBigSocial = options?.length > 2 || options?.length === 1; const showMoreButton = options?.length > MAX_OPTIONS; const topSocial = showBigSocial ? options[0] : null; let bottomSocials = showBigSocial ? options.slice(1) : options; bottomSocials = showMoreButton ? bottomSocials.slice(0, MAX_OPTIONS - 2) : bottomSocials; const onItemPress = (provider: SocialProvider) => { if (provider === 'email') { EventsController.sendEvent({ type: 'track', event: 'EMAIL_LOGIN_SELECTED' }); } else { EventsController.sendEvent({ type: 'track', event: 'SOCIAL_LOGIN_STARTED', properties: { provider } }); } RouterController.push('ConnectingSocial', { socialProvider: provider }); }; const onMorePress = () => { RouterController.push('ConnectSocials'); }; return ( {topSocial ? ( onItemPress(topSocial)}> {`Continue with ${StringUtil.capitalize(topSocial)}`} ) : null} {bottomSocials?.map((social: SocialProvider, index) => ( onItemPress(social)} style={[ styles.socialItem, index === 0 && styles.socialItemFirst, !showMoreButton && index === bottomSocials.length - 1 && styles.socialItemLast ]} /> ))} {showMoreButton ? ( ) : null} ); } const styles = StyleSheet.create({ topDescription: { textAlign: 'center' }, socialItem: { flex: 1, marginHorizontal: Spacing['2xs'] }, socialItemFirst: { marginLeft: 0 }, socialItemLast: { marginRight: 0 } });