Merge branch 'hailey/swap-out-cropper' into hailey/79fab

This commit is contained in:
Hailey
2025-05-05 14:16:23 -07:00
22 changed files with 148 additions and 209 deletions
+6 -8
View File
@@ -2,7 +2,7 @@ import React from 'react'
import {View} from 'react-native'
import {Image as ExpoImage} from 'expo-image'
import {
ImagePickerOptions,
type ImagePickerOptions,
launchImageLibraryAsync,
MediaTypeOptions,
} from 'expo-image-picker'
@@ -27,7 +27,7 @@ import {AvatarCreatorCircle} from '#/screens/Onboarding/StepProfile/AvatarCreato
import {AvatarCreatorItems} from '#/screens/Onboarding/StepProfile/AvatarCreatorItems'
import {
PlaceholderCanvas,
PlaceholderCanvasRef,
type PlaceholderCanvasRef,
} from '#/screens/Onboarding/StepProfile/PlaceholderCanvas'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
@@ -38,7 +38,7 @@ import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components
import {CircleInfo_Stroke2_Corner0_Rounded} from '#/components/icons/CircleInfo'
import {StreamingLive_Stroke2_Corner0_Rounded as StreamingLive} from '#/components/icons/StreamingLive'
import {Text} from '#/components/Typography'
import {AvatarColor, avatarColors, Emoji, emojiItems} from './types'
import {type AvatarColor, avatarColors, type Emoji, emojiItems} from './types'
export interface Avatar {
image?: {
@@ -182,11 +182,9 @@ export function StepProfile() {
if (!isWeb) {
image = await openCropper({
mediaType: 'photo',
cropperCircleOverlay: true,
height: 1000,
width: 1000,
path: image.path,
imageUri: image.path,
shape: 'circle',
aspectRatio: 1 / 1,
})
}
image = await compressIfNeeded(image, 1000000)
@@ -1,12 +1,12 @@
import {useCallback, useEffect, useState} from 'react'
import {Dimensions, View} from 'react-native'
import {type Image as RNImage} from 'react-native-image-crop-picker'
import {type AppBskyActorDefs} from '@atproto/api'
import {msg, Plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {urls} from '#/lib/constants'
import {compressIfNeeded} from '#/lib/media/manip'
import {type PickerImage} from '#/lib/media/picker.shared'
import {cleanError} from '#/lib/strings/errors'
import {useWarnMaxGraphemeCount} from '#/lib/strings/helpers'
import {logger} from '#/logger'
@@ -127,10 +127,10 @@ function DialogInner({
profile.avatar,
)
const [newUserBanner, setNewUserBanner] = useState<
RNImage | undefined | null
PickerImage | undefined | null
>()
const [newUserAvatar, setNewUserAvatar] = useState<
RNImage | undefined | null
PickerImage | undefined | null
>()
const dirty =
@@ -144,7 +144,7 @@ function DialogInner({
}, [dirty, setDirty])
const onSelectNewAvatar = useCallback(
async (img: RNImage | null) => {
async (img: PickerImage | null) => {
setImageError('')
if (img === null) {
setNewUserAvatar(null)
@@ -163,7 +163,7 @@ function DialogInner({
)
const onSelectNewBanner = useCallback(
async (img: RNImage | null) => {
async (img: PickerImage | null) => {
setImageError('')
if (!img) {
setNewUserBanner(null)