working on both platforms

This commit is contained in:
Hailey
2024-02-13 22:45:59 -08:00
parent 4ac53f168a
commit f529738227
4 changed files with 36 additions and 18 deletions
+5 -1
View File
@@ -34,9 +34,13 @@ export async function uploadBlob(
): Promise<ComAtprotoRepoUploadBlob.Response> {
if (isWeb) {
// `blob` should be a data uri
return agent.uploadBlob(convertDataURIToUint8Array(blob), {
console.log(convertDataURIToUint8Array(blob))
const x = await agent.uploadBlob(convertDataURIToUint8Array(blob), {
encoding,
})
return x
} else {
// `blob` should be a path to a file in the local FS
return agent.uploadBlob(
+4 -2
View File
@@ -78,10 +78,12 @@ export function StepFinished() {
const res = await uploadBlob(
getAgent(),
profileStepResults.imageUri,
profileStepResults.imageUri,
profileStepResults.imageMime,
)
existing.avatar = res.data.blob
if (res.data.blob) {
existing.avatar = res.data.blob
}
}
return existing
@@ -1,10 +1,11 @@
import React from 'react'
import {useAvatar} from '#/screens/Onboarding/StepProfile/index'
import {StyleSheet, View} from 'react-native'
const CANVAS_HEIGHT = 24 * 10
const CANVAS_OFFSET = 24 * 1.5
const CANVAS_HEIGHT = 24 * 20
const CANVAS_OFFSET = 24 * 3
interface PlaceholderCanvasRef {
export interface PlaceholderCanvasRef {
capture: () => string
}
@@ -16,7 +17,7 @@ export const PlaceholderCanvas = React.forwardRef(function PlaceholderCanvas(
const canvasRef = React.useRef<HTMLCanvasElement>(null)
const capture = React.useCallback(() => {
return ''
return canvasRef.current?.toDataURL('image/jpeg')
}, [])
React.useImperativeHandle(ref, () => ({
@@ -35,9 +36,20 @@ export const PlaceholderCanvas = React.forwardRef(function PlaceholderCanvas(
ctx.fillStyle = '#fff'
ctx.lineWidth = 0.1
ctx?.translate(CANVAS_OFFSET, CANVAS_OFFSET)
ctx?.scale(7, 7)
ctx?.scale(14, 14)
ctx?.fill(path)
}, [avatar.backgroundColor, avatar.placeholder.path])
return <canvas ref={canvasRef} height={CANVAS_HEIGHT} width={CANVAS_HEIGHT} />
return (
<View style={styles.container}>
<canvas ref={canvasRef} height={CANVAS_HEIGHT} width={CANVAS_HEIGHT} />
</View>
)
})
const styles = StyleSheet.create({
container: {
top: -2000,
position: 'absolute',
},
})
+9 -9
View File
@@ -66,15 +66,15 @@ export function StepProfile() {
const canvasRef = React.useRef<PlaceholderCanvasRef>(null)
React.useEffect(() => {
// TODO remove, this is for testing
;(async () => {
const res = await canvasRef.current?.capture()
if (res) {
setUri(res)
}
})()
}, [avatar])
// 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')