diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-27 15:51:24 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-01-27 15:51:24 -0600 |
commit | 7916b26aadb7e003728d9dc653ab8b8deabf4076 (patch) | |
tree | 507d24512fd71c67d4fe49af4ae5f8746444cceb /src/view/com/util/UserAvatar.tsx | |
parent | 0673129b2018c9db0f7c3fc3e2c3214150efcfb8 (diff) | |
download | voidsky-7916b26aadb7e003728d9dc653ab8b8deabf4076.tar.zst |
Break out the web/native image picking code and make some progress on the web version
Diffstat (limited to 'src/view/com/util/UserAvatar.tsx')
-rw-r--r-- | src/view/com/util/UserAvatar.tsx | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/view/com/util/UserAvatar.tsx b/src/view/com/util/UserAvatar.tsx index d91607b6c..287d94412 100644 --- a/src/view/com/util/UserAvatar.tsx +++ b/src/view/com/util/UserAvatar.tsx @@ -6,8 +6,9 @@ import { openCamera, openCropper, openPicker, - Image as PickedImage, -} from './images/ImageCropPicker' + PickedMedia, +} from './images/image-crop-picker/ImageCropPicker' +import {useStores} from '../../../state' import {colors, gradients} from '../../lib/styles' export function UserAvatar({ @@ -21,8 +22,9 @@ export function UserAvatar({ handle: string displayName: string | undefined avatar?: string | null - onSelectNewAvatar?: (img: PickedImage) => void + onSelectNewAvatar?: (img: PickedMedia) => void }) { + const store = useStores() const initials = getInitials(displayName || handle) const handleEditAvatar = useCallback(() => { @@ -30,37 +32,32 @@ export function UserAvatar({ { text: 'Take a new photo', onPress: () => { - openCamera({ + openCamera(store, { mediaType: 'photo', - cropping: true, width: 1000, height: 1000, cropperCircleOverlay: true, - forceJpg: true, // ios only - compressImageQuality: 1, }).then(onSelectNewAvatar) }, }, { text: 'Select from gallery', onPress: () => { - openPicker({ + openPicker(store, { mediaType: 'photo', - }).then(async item => { - await openCropper({ + }).then(async items => { + await openCropper(store, { mediaType: 'photo', - path: item.path, + path: items[0].path, width: 1000, height: 1000, cropperCircleOverlay: true, - forceJpg: true, // ios only - compressImageQuality: 1, }).then(onSelectNewAvatar) }) }, }, ]) - }, [onSelectNewAvatar]) + }, [store, onSelectNewAvatar]) const renderSvg = (svgSize: number, svgInitials: string) => ( <Svg width={svgSize} height={svgSize} viewBox="0 0 100 100"> |