Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115import {useMemo} from 'react'import {View} from 'react-native'import {Image} from 'expo-image'import {LinearGradient} from 'expo-linear-gradient'import {msg} from '@lingui/core/macro'import {useLingui} from '@lingui/react'import {Trans} from '@lingui/react/macro'
import {HITSLOP_10} from '#/lib/constants'import {Nux, useNux, useSaveNux} from '#/state/queries/nuxs'import {atoms as a, useTheme} from '#/alf'import {Button} from '#/components/Button'import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times'import {Text} from '#/components/Typography'import {useAnalytics} from '#/analytics'import {IS_WEB} from '#/env'import {Link} from '../Link'import {useIsFindContactsFeatureEnabledBasedOnGeolocation} from './country-allowlist'
export function FindContactsBannerNUX() { const t = useTheme() const {_} = useLingui() const ax = useAnalytics() const {visible, close} = useInternalState()
if (!visible) return null
return ( <View style={[a.w_full, a.p_lg, a.border_b, t.atoms.border_contrast_low]}> <View style={a.w_full}> <Link to={{screen: 'FindContactsFlow'}} label={_(msg`Import contacts to find your friends`)} onPress={() => { ax.metric('contacts:nux:bannerPressed', {}) }} style={[ a.w_full, a.rounded_xl, a.curve_continuous, a.overflow_hidden, ]}> <LinearGradient colors={[t.palette.primary_200, t.palette.primary_50]} start={{x: 0, y: 0.5}} end={{x: 1, y: 0.5}} style={[ a.w_full, a.h_full, a.flex_row, a.align_center, a.gap_lg, a.pl_lg, ]}> <Image source={require('../../../assets/images/find_friends_illustration_small.webp')} accessibilityIgnoresInvertColors style={[ {height: 70, aspectRatio: 573 / 286}, a.self_end, a.mt_sm, ]} useAppleWebpCodec /> <View style={[a.flex_1, a.justify_center, a.py_xl, a.pr_5xl]}> <Text style={[ a.text_md, a.font_bold, {color: t.palette.primary_900}, ]}> <Trans>Import contacts to find your friends</Trans> </Text> </View> </LinearGradient> </Link> <Button label={_(msg`Dismiss banner`)} hitSlop={HITSLOP_10} onPress={close} style={[a.absolute, {top: 14, right: 14}]} hoverStyle={[a.bg_transparent, {opacity: 0.5}]}> <XIcon size="xs" style={[t.atoms.text_contrast_low]} /> </Button> </View> </View> )}function useInternalState() { const ax = useAnalytics() const {nux} = useNux(Nux.FindContactsDismissibleBanner) const {mutate: save, variables} = useSaveNux() const hidden = !!variables const isFeatureEnabled = useIsFindContactsFeatureEnabledBasedOnGeolocation()
const visible = useMemo(() => { if (IS_WEB) return false if (hidden) return false if (nux && nux.completed) return false if (!isFeatureEnabled) return false return true }, [hidden, nux, isFeatureEnabled])
const close = () => { save({ id: Nux.FindContactsDismissibleBanner, completed: true, data: undefined, }) ax.metric('contacts:nux:bannerDismissed', {}) }
return {visible, close}}