Skip to content

Commit

Permalink
Add iOS hack to fix cropper failing to show
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 19, 2024
1 parent a3031de commit caea620
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/screens/Onboarding/StepProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {openCropper} from '#/lib/media/picker'
import {getDataUriSize} from '#/lib/media/util'
import {useRequestNotificationsPermission} from '#/lib/notifications/notifications'
import {logEvent, useGate} from '#/lib/statsig/statsig'
import {isNative, isWeb} from '#/platform/detection'
import {isIOS, isNative, isWeb} from '#/platform/detection'
import {
DescriptionText,
OnboardingControls,
Expand Down Expand Up @@ -181,6 +181,10 @@ export function StepProfile() {
if (!image) return

if (!isWeb) {
if (isIOS) {
// https://github.com/ivpusic/react-native-image-crop-picker/issues/1631
await new Promise(resolve => setTimeout(resolve, 1000))
}
image = await openCropper({
mediaType: 'photo',
cropperCircleOverlay: true,
Expand Down
6 changes: 5 additions & 1 deletion src/view/com/util/UserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import {makeProfileLink} from '#/lib/routes/links'
import {colors} from '#/lib/styles'
import {logger} from '#/logger'
import {isAndroid, isNative, isWeb} from '#/platform/detection'
import {isAndroid, isIOS, isNative, isWeb} from '#/platform/detection'
import {precacheProfile} from '#/state/queries/profile'
import {HighPriorityImage} from '#/view/com/util/images/Image'
import {tokens, useTheme} from '#/alf'
Expand Down Expand Up @@ -319,6 +319,10 @@ let EditableUserAvatar = ({
}

try {
if (isIOS) {
// https://github.com/ivpusic/react-native-image-crop-picker/issues/1631
await new Promise(resolve => setTimeout(resolve, 1000))
}
const croppedImage = await openCropper({
mediaType: 'photo',
cropperCircleOverlay: true,
Expand Down
6 changes: 5 additions & 1 deletion src/view/com/util/UserBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import {colors} from '#/lib/styles'
import {useTheme} from '#/lib/ThemeContext'
import {logger} from '#/logger'
import {isAndroid, isNative} from '#/platform/detection'
import {isAndroid, isIOS, isNative} from '#/platform/detection'
import {EventStopper} from '#/view/com/util/EventStopper'
import {tokens, useTheme as useAlfTheme} from '#/alf'
import {useSheetWrapper} from '#/components/Dialog/sheet-wrapper'
Expand Down Expand Up @@ -68,6 +68,10 @@ export function UserBanner({
}

try {
if (isIOS) {
// https://github.com/ivpusic/react-native-image-crop-picker/issues/1631
await new Promise(resolve => setTimeout(resolve, 1000))
}
onSelectNewBanner?.(
await openCropper({
mediaType: 'photo',
Expand Down

0 comments on commit caea620

Please sign in to comment.