import {useEffect, useRef, useState} from 'react' import {ScrollView, View} from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useOnboardingDispatch} from '#/state/shell' import {useOnboardingInternalState} from '#/screens/Onboarding/state' import { atoms as a, native, type TextStyleProp, tokens, useBreakpoints, useTheme, web, } from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeft} from '#/components/icons/Arrow' import {HEADER_SLOT_SIZE} from '#/components/Layout' import {createPortalGroup} from '#/components/Portal' import {P, Text} from '#/components/Typography' import {IS_ANDROID, IS_WEB} from '#/env' import {IS_INTERNAL} from '#/env' const ONBOARDING_COL_WIDTH = 420 export const OnboardingControls = createPortalGroup() export const OnboardingHeaderSlot = createPortalGroup() export function Layout({children}: React.PropsWithChildren<{}>) { const {_} = useLingui() const t = useTheme() const insets = useSafeAreaInsets() const {gtMobile} = useBreakpoints() const onboardDispatch = useOnboardingDispatch() const {state, dispatch} = useOnboardingInternalState() const scrollview = useRef(null) const prevActiveStep = useRef(state.activeStep) useEffect(() => { if (state.activeStep !== prevActiveStep.current) { prevActiveStep.current = state.activeStep scrollview.current?.scrollTo({y: 0, animated: false}) } }, [state]) const dialogLabel = _(msg`Set up your account`) const [headerHeight, setHeaderHeight] = useState(0) const [footerHeight, setFooterHeight] = useState(0) return ( {!gtMobile ? ( setHeaderHeight(evt.nativeEvent.layout.height)}> {state.canGoBack && ( )} {IS_INTERNAL && ( )} ) : ( <> {IS_INTERNAL && ( )} )} {children} setFooterHeight(evt.nativeEvent.layout.height)} style={[ IS_WEB ? a.fixed : a.absolute, {bottom: 0, left: 0, right: 0}, t.atoms.bg, t.atoms.border_contrast_low, a.border_t, a.align_center, gtMobile ? a.px_5xl : a.px_xl, IS_WEB ? a.py_2xl : { paddingTop: tokens.space.md, paddingBottom: insets.bottom + tokens.space.md, }, ]}> {gtMobile && (state.canGoBack ? ( ) : ( ))} ) } function HeaderSlot({children}: {children?: React.ReactNode}) { return ( {children} ) } export function OnboardingPosition() { const {state} = useOnboardingInternalState() const t = useTheme() return ( Step {state.activeStepIndex + 1} of {state.totalSteps} ) } export function OnboardingTitleText({ children, style, }: React.PropsWithChildren) { return ( {children} ) } export function OnboardingDescriptionText({ children, style, }: React.PropsWithChildren) { const t = useTheme() return (

{children}

) }