diff --git a/src/screens/Onboarding/StepProfile/PlaceholderCanvas.tsx b/src/screens/Onboarding/StepProfile/PlaceholderCanvas.tsx index f803a9e162..83d96cb250 100644 --- a/src/screens/Onboarding/StepProfile/PlaceholderCanvas.tsx +++ b/src/screens/Onboarding/StepProfile/PlaceholderCanvas.tsx @@ -3,42 +3,56 @@ import {useAvatar} from '#/screens/Onboarding/StepProfile/index' import ViewShot from 'react-native-view-shot' import {StyleSheet, View} from 'react-native' +export interface PlaceholderCanvasRef { + capture: () => Promise +} + // This component is supposed to be invisible to the user. We only need this for ViewShot to have something to -// "screenshot" -export const PlaceholderCanvas = React.forwardRef(function PlaceholderCanvas( - {}, - ref, -) { - const avatar = useAvatar() - const viewshotRef = React.useRef() - const Icon = avatar.placeholder.component +// "screenshot". +export const PlaceholderCanvas = React.forwardRef( + function PlaceholderCanvas({}, ref) { + const avatar = useAvatar() + const viewshotRef = React.useRef() + const Icon = avatar.placeholder.component - // React.useEffect(() => { - // // @ts-ignore this library doesn't have types - // viewshotRef.current.capture().then(uri => { - // return uri - // }) - // }, [avatar, ref]) + React.useImperativeHandle(ref, () => ({ + // @ts-ignore this library doesn't have types + capture: viewshotRef.current.capture, + })) - return ( - - - - - - - - ) -}) + return ( + + + + + + + + ) + }, +) const styles = StyleSheet.create({ - imageContainer: { - top: 100, + container: { + top: -2000, position: 'absolute', - zIndex: -5, + }, + imageContainer: { + height: 150 * 5, + width: 150 * 5, + alignItems: 'center', + justifyContent: 'center', }, }) diff --git a/src/screens/Onboarding/StepProfile/index.tsx b/src/screens/Onboarding/StepProfile/index.tsx index 83058433e7..47e9171029 100644 --- a/src/screens/Onboarding/StepProfile/index.tsx +++ b/src/screens/Onboarding/StepProfile/index.tsx @@ -32,7 +32,10 @@ import {openCropper, openPicker} from 'lib/media/picker' import {Emoji, EmojiName, emojiItems, emojiNames} from './types' import {SelectImageButton} from '#/screens/Onboarding/StepProfile/SelectImageButton' import ViewShot from 'react-native-view-shot' -import {PlaceholderCanvas} from '#/screens/Onboarding/StepProfile/PlaceholderCanvas' +import { + PlaceholderCanvas, + PlaceholderCanvasRef, +} from '#/screens/Onboarding/StepProfile/PlaceholderCanvas' interface Avatar { image?: { @@ -63,6 +66,19 @@ export function StepProfile() { placeholder: emojiItems.smile, backgroundColor: '#338388', }) + const [uri, setUri] = React.useState('') + + const canvasRef = React.useRef(null) + + React.useEffect(() => { + // TODO remove, this is for testing + ;(async () => { + const res = await canvasRef.current?.capture() + if (res) { + setUri(res) + } + })() + }, [avatar]) React.useEffect(() => { track('OnboardingV2:StepProfile:Start') @@ -97,6 +113,8 @@ export function StepProfile() { + {/* TOOD remove, testing */} + @@ -114,7 +132,7 @@ export function StepProfile() { - + @@ -140,6 +158,7 @@ function AvatarCircle() { @@ -256,7 +275,7 @@ const styles = StyleSheet.create({ height: 150, width: 150, overflow: 'hidden', - borderWidth: 1, + borderWidth: 2, alignItems: 'center', justifyContent: 'center', },