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/UserBanner.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/UserBanner.tsx')
-rw-r--r-- | src/view/com/util/UserBanner.tsx | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/view/com/util/UserBanner.tsx b/src/view/com/util/UserBanner.tsx index fe606bc55..d5d6e3aaa 100644 --- a/src/view/com/util/UserBanner.tsx +++ b/src/view/com/util/UserBanner.tsx @@ -2,57 +2,56 @@ import React, {useCallback} from 'react' import {StyleSheet, View, TouchableOpacity, Alert, Image} from 'react-native' import Svg, {Rect, Defs, LinearGradient, Stop} from 'react-native-svg' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' -import {Image as PickedImage} from './images/ImageCropPicker' import {colors, gradients} from '../../lib/styles' -import {openCamera, openCropper, openPicker} from './images/ImageCropPicker' +import { + openCamera, + openCropper, + openPicker, + PickedMedia, +} from './images/image-crop-picker/ImageCropPicker' +import {useStores} from '../../../state' export function UserBanner({ banner, onSelectNewBanner, }: { banner?: string | null - onSelectNewBanner?: (img: PickedImage) => void + onSelectNewBanner?: (img: PickedMedia) => void }) { + const store = useStores() const handleEditBanner = useCallback(() => { Alert.alert('Select upload method', '', [ { text: 'Take a new photo', onPress: () => { - openCamera({ + openCamera(store, { mediaType: 'photo', - cropping: true, - compressImageMaxWidth: 3000, + // compressImageMaxWidth: 3000, TODO needed? width: 3000, - compressImageMaxHeight: 1000, + // compressImageMaxHeight: 1000, TODO needed? height: 1000, - forceJpg: true, // ios only - compressImageQuality: 1, - includeExif: true, }).then(onSelectNewBanner) }, }, { 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, - compressImageMaxWidth: 3000, + path: items[0].path, + // compressImageMaxWidth: 3000, TODO needed? width: 3000, - compressImageMaxHeight: 1000, + // compressImageMaxHeight: 1000, TODO needed? height: 1000, - forceJpg: true, // ios only - compressImageQuality: 1, - includeExif: true, }).then(onSelectNewBanner) }) }, }, ]) - }, [onSelectNewBanner]) + }, [store, onSelectNewBanner]) const renderSvg = () => ( <Svg width="100%" height="150" viewBox="50 0 200 100"> |