Bluesky app fork with some witchin' additions 馃挮
at main 112 lines 3.6 kB view raw
1import {useMemo} from 'react' 2import {View} from 'react-native' 3import {Image} from 'expo-image' 4import {LinearGradient} from 'expo-linear-gradient' 5import {msg, Trans} from '@lingui/macro' 6import {useLingui} from '@lingui/react' 7 8import {HITSLOP_10} from '#/lib/constants' 9import {Nux, useNux, useSaveNux} from '#/state/queries/nuxs' 10import {atoms as a, useTheme} from '#/alf' 11import {Button} from '#/components/Button' 12import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times' 13import {Text} from '#/components/Typography' 14import {useAnalytics} from '#/analytics' 15import {IS_WEB} from '#/env' 16import {Link} from '../Link' 17import {useIsFindContactsFeatureEnabledBasedOnGeolocation} from './country-allowlist' 18 19export function FindContactsBannerNUX() { 20 const t = useTheme() 21 const {_} = useLingui() 22 const ax = useAnalytics() 23 const {visible, close} = useInternalState() 24 25 if (!visible) return null 26 27 return ( 28 <View style={[a.w_full, a.p_lg, a.border_b, t.atoms.border_contrast_low]}> 29 <View style={a.w_full}> 30 <Link 31 to={{screen: 'FindContactsFlow'}} 32 label={_(msg`Import contacts to find your friends`)} 33 onPress={() => { 34 ax.metric('contacts:nux:bannerPressed', {}) 35 }} 36 style={[ 37 a.w_full, 38 a.rounded_xl, 39 a.curve_continuous, 40 a.overflow_hidden, 41 ]}> 42 <LinearGradient 43 colors={[t.palette.primary_200, t.palette.primary_50]} 44 start={{x: 0, y: 0.5}} 45 end={{x: 1, y: 0.5}} 46 style={[ 47 a.w_full, 48 a.h_full, 49 a.flex_row, 50 a.align_center, 51 a.gap_lg, 52 a.pl_lg, 53 ]}> 54 <Image 55 source={require('../../../assets/images/find_friends_illustration_small.webp')} 56 accessibilityIgnoresInvertColors 57 style={[ 58 {height: 70, aspectRatio: 573 / 286}, 59 a.self_end, 60 a.mt_sm, 61 ]} 62 /> 63 <View style={[a.flex_1, a.justify_center, a.py_xl, a.pr_5xl]}> 64 <Text 65 style={[ 66 a.text_md, 67 a.font_bold, 68 {color: t.palette.primary_900}, 69 ]}> 70 <Trans>Import contacts to find your friends</Trans> 71 </Text> 72 </View> 73 </LinearGradient> 74 </Link> 75 <Button 76 label={_(msg`Dismiss banner`)} 77 hitSlop={HITSLOP_10} 78 onPress={close} 79 style={[a.absolute, {top: 14, right: 14}]} 80 hoverStyle={[a.bg_transparent, {opacity: 0.5}]}> 81 <XIcon size="xs" style={[t.atoms.text_contrast_low]} /> 82 </Button> 83 </View> 84 </View> 85 ) 86} 87function useInternalState() { 88 const ax = useAnalytics() 89 const {nux} = useNux(Nux.FindContactsDismissibleBanner) 90 const {mutate: save, variables} = useSaveNux() 91 const hidden = !!variables 92 const isFeatureEnabled = useIsFindContactsFeatureEnabledBasedOnGeolocation() 93 94 const visible = useMemo(() => { 95 if (IS_WEB) return false 96 if (hidden) return false 97 if (nux && nux.completed) return false 98 if (!isFeatureEnabled) return false 99 return true 100 }, [hidden, nux, isFeatureEnabled]) 101 102 const close = () => { 103 save({ 104 id: Nux.FindContactsDismissibleBanner, 105 completed: true, 106 data: undefined, 107 }) 108 ax.metric('contacts:nux:bannerDismissed', {}) 109 } 110 111 return {visible, close} 112}