Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import {useCallback, useState} from 'react'import {LayoutAnimationConfig} from 'react-native-reanimated'import {msg} from '@lingui/core/macro'import {useLingui} from '@lingui/react'import {useFocusEffect, usePreventRemove} from '@react-navigation/native'
import {getHomeNavigationAction} from '#/lib/routes/navigation'import { type CommonNavigatorParams, type NativeStackScreenProps,} from '#/lib/routes/types'import {useEnableMinimalShellMode} from '#/state/shell'import {ErrorScreen} from '#/view/com/util/error/ErrorScreen'import {useIsFindContactsFeatureEnabledBasedOnGeolocation} from '#/components/contacts/country-allowlist'import {FindContactsFlow} from '#/components/contacts/FindContactsFlow'import {useFindContactsFlowState} from '#/components/contacts/state'import * as Layout from '#/components/Layout'import {ScreenTransition} from '#/components/ScreenTransition'import {IS_NATIVE} from '#/env'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'FindContactsFlow'>export function FindContactsFlowScreen({navigation}: Props) { const {_} = useLingui()
// Blacksky: feature disabled/unreachable. Guard the deep-linkable route so it // can't be reached directly. See country-allowlist.ts. const findContactsEnabled = useIsFindContactsFeatureEnabledBasedOnGeolocation() useFocusEffect( useCallback(() => { if (!findContactsEnabled) { navigation.dispatch( getHomeNavigationAction(navigation.getState(), 'navigate'), ) } }, [findContactsEnabled, navigation]), )
const [state, dispatch] = useFindContactsFlowState()
const [transitionDirection, setTransitionDirection] = useState< 'Forward' | 'Backward' >('Forward')
const overrideGoBack = state.step === '2: verify number'
usePreventRemove(overrideGoBack, () => { setTransitionDirection('Backward') dispatch({type: 'BACK'}) setTimeout(() => { setTransitionDirection('Forward') }) })
useEnableMinimalShellMode()
return ( <Layout.Screen> {IS_NATIVE ? ( <LayoutAnimationConfig skipEntering skipExiting> <ScreenTransition key={state.step} direction={transitionDirection}> <FindContactsFlow state={state} dispatch={dispatch} onCancel={() => navigation.canGoBack() ? navigation.goBack() : navigation.navigate('FindContactsFlow', undefined, { pop: true, }) } context="Standalone" /> </ScreenTransition> </LayoutAnimationConfig> ) : ( <ErrorScreen title={_(msg`Not available on this platform.`)} message={_(msg`Please use the native app to sync your contacts.`)} showHeader /> )} </Layout.Screen> )}