update state
This commit is contained in:
@@ -13,9 +13,6 @@ import {msg, Trans} from '@lingui/macro'
|
|||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText, ButtonIcon} from '#/components/Button'
|
import {Button, ButtonText, ButtonIcon} from '#/components/Button'
|
||||||
import {StreamingLive_Stroke2_Corner0_Rounded as StreamingLive} from '#/components/icons/StreamingLive'
|
import {StreamingLive_Stroke2_Corner0_Rounded as StreamingLive} from '#/components/icons/StreamingLive'
|
||||||
import {Camera_Stroke2_Corner0_Rounded as Camera} from '#/components/icons/Camera'
|
|
||||||
import {Text} from '#/components/Typography'
|
|
||||||
// import {useOnboardingDispatch} from '#/state/shell'
|
|
||||||
import {useAnalytics} from '#/lib/analytics/analytics'
|
import {useAnalytics} from '#/lib/analytics/analytics'
|
||||||
|
|
||||||
import {Context} from '#/screens/Onboarding/state'
|
import {Context} from '#/screens/Onboarding/state'
|
||||||
@@ -27,11 +24,8 @@ import {
|
|||||||
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron'
|
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron'
|
||||||
import {IconCircle} from '#/components/IconCircle'
|
import {IconCircle} from '#/components/IconCircle'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {usePhotoLibraryPermission} from 'lib/hooks/usePermissions'
|
|
||||||
import {openCropper, openPicker} from 'lib/media/picker'
|
|
||||||
import {Emoji, EmojiName, emojiItems, emojiNames} from './types'
|
import {Emoji, EmojiName, emojiItems, emojiNames} from './types'
|
||||||
import {SelectImageButton} from '#/screens/Onboarding/StepProfile/SelectImageButton'
|
import {SelectImageButton} from '#/screens/Onboarding/StepProfile/SelectImageButton'
|
||||||
import ViewShot from 'react-native-view-shot'
|
|
||||||
import {
|
import {
|
||||||
PlaceholderCanvas,
|
PlaceholderCanvas,
|
||||||
PlaceholderCanvasRef,
|
PlaceholderCanvasRef,
|
||||||
@@ -84,10 +78,22 @@ export function StepProfile() {
|
|||||||
track('OnboardingV2:StepProfile:Start')
|
track('OnboardingV2:StepProfile:Start')
|
||||||
}, [track])
|
}, [track])
|
||||||
|
|
||||||
const onContinue = React.useCallback(() => {
|
const onContinue = React.useCallback(async () => {
|
||||||
|
let imageUri = avatar?.image?.path
|
||||||
|
if (!imageUri) {
|
||||||
|
imageUri = await canvasRef.current?.capture()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageUri) {
|
||||||
|
dispatch({
|
||||||
|
type: 'setProfileStepResults',
|
||||||
|
imageUri,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
dispatch({type: 'next'})
|
dispatch({type: 'next'})
|
||||||
track('OnboardingV2:StepProfile:End')
|
track('OnboardingV2:StepProfile:End')
|
||||||
}, [track, dispatch])
|
}, [avatar?.image?.path, dispatch, track])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SetAvatarContext.Provider value={setAvatar}>
|
<SetAvatarContext.Provider value={setAvatar}>
|
||||||
@@ -113,8 +119,12 @@ export function StepProfile() {
|
|||||||
</View>
|
</View>
|
||||||
<Items type="emojis" />
|
<Items type="emojis" />
|
||||||
<Items type="colors" />
|
<Items type="colors" />
|
||||||
{/* TOOD remove, testing */}
|
{/* TODO remove, testing */}
|
||||||
<Image source={uri} style={{height: 100, width: 100}} />
|
<Image
|
||||||
|
source={uri}
|
||||||
|
style={{height: 100, width: 100}}
|
||||||
|
accessibilityIgnoresInvertColors
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<OnboardingControls.Portal>
|
<OnboardingControls.Portal>
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export type OnboardingState = {
|
|||||||
topicalFeedsStepResults: {
|
topicalFeedsStepResults: {
|
||||||
feedUris: string[]
|
feedUris: string[]
|
||||||
}
|
}
|
||||||
|
profileStepResults: {
|
||||||
|
imageUri?: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OnboardingAction =
|
export type OnboardingAction =
|
||||||
@@ -58,6 +61,10 @@ export type OnboardingAction =
|
|||||||
type: 'setTopicalFeedsStepResults'
|
type: 'setTopicalFeedsStepResults'
|
||||||
feedUris: string[]
|
feedUris: string[]
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: 'setProfileStepResults'
|
||||||
|
imageUri: string
|
||||||
|
}
|
||||||
|
|
||||||
export type ApiResponseMap = {
|
export type ApiResponseMap = {
|
||||||
interests: string[]
|
interests: string[]
|
||||||
@@ -93,6 +100,9 @@ export const initialState: OnboardingState = {
|
|||||||
topicalFeedsStepResults: {
|
topicalFeedsStepResults: {
|
||||||
feedUris: [],
|
feedUris: [],
|
||||||
},
|
},
|
||||||
|
profileStepResults: {
|
||||||
|
imageUri: '',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const INTEREST_TO_DISPLAY_NAME_DEFAULTS: {
|
export const INTEREST_TO_DISPLAY_NAME_DEFAULTS: {
|
||||||
@@ -220,6 +230,12 @@ export function reducer(
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
case 'setProfileStepResults': {
|
||||||
|
next.profileStepResults = {
|
||||||
|
imageUri: a.imageUri,
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
@@ -237,6 +253,7 @@ export function reducer(
|
|||||||
suggestedAccountsStepResults: state.suggestedAccountsStepResults,
|
suggestedAccountsStepResults: state.suggestedAccountsStepResults,
|
||||||
algoFeedsStepResults: state.algoFeedsStepResults,
|
algoFeedsStepResults: state.algoFeedsStepResults,
|
||||||
topicalFeedsStepResults: state.topicalFeedsStepResults,
|
topicalFeedsStepResults: state.topicalFeedsStepResults,
|
||||||
|
profileStepResults: state.profileStepResults,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (s.activeStep !== state.activeStep) {
|
if (s.activeStep !== state.activeStep) {
|
||||||
|
|||||||
Reference in New Issue
Block a user