Split image cropping into secondary step (#473)

* Split image cropping into secondary step

* Use ImageModel and GalleryModel

* Add fix for pasting image URLs

* Move models to state folder

* Fix things that broke after rebase

* Latest -- has image display bug

* Remove contentFit

* Fix iOS display in gallery

* Tuneup the api signatures and implement compress/resize on web

* Fix await

* Lint fix and remove unused function

* Fix android image pathing

* Fix external embed x button on android

* Remove min-height from composer (no longer useful and was mispositioning the composer on android)

* Fix e2e picker

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
Ollie Hsieh 2023-04-17 15:41:44 -07:00 committed by GitHub
parent 91fadadb58
commit 2509290fdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 875 additions and 833 deletions

View file

@ -4,12 +4,7 @@ import Svg, {Circle, Path} from 'react-native-svg'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {IconProp} from '@fortawesome/fontawesome-svg-core'
import {HighPriorityImage} from 'view/com/util/images/Image'
import {
openCamera,
openCropper,
openPicker,
PickedMedia,
} from '../../../lib/media/picker'
import {openCamera, openCropper, openPicker} from '../../../lib/media/picker'
import {
usePhotoLibraryPermission,
useCameraPermission,
@ -19,6 +14,7 @@ import {colors} from 'lib/styles'
import {DropdownButton} from './forms/DropdownButton'
import {usePalette} from 'lib/hooks/usePalette'
import {isWeb} from 'platform/detection'
import {Image as RNImage} from 'react-native-image-crop-picker'
function DefaultAvatar({size}: {size: number}) {
return (
@ -50,7 +46,7 @@ export function UserAvatar({
size: number
avatar?: string | null
hasWarning?: boolean
onSelectNewAvatar?: (img: PickedMedia | null) => void
onSelectNewAvatar?: (img: RNImage | null) => void
}) {
const store = useStores()
const pal = usePalette('default')
@ -68,7 +64,6 @@ export function UserAvatar({
}
onSelectNewAvatar?.(
await openCamera(store, {
mediaType: 'photo',
width: 1000,
height: 1000,
cropperCircleOverlay: true,
@ -84,9 +79,8 @@ export function UserAvatar({
if (!(await requestPhotoAccessIfNeeded())) {
return
}
const items = await openPicker(store, {
mediaType: 'photo',
})
const items = await openPicker(store)
onSelectNewAvatar?.(
await openCropper(store, {
mediaType: 'photo',