fix typescript issue; force mediatype photo

zio/stable
João Ferreiro 2022-11-29 16:19:15 +00:00
parent 87d37f9df9
commit d08e877b3a
1 changed files with 17 additions and 12 deletions

View File

@ -2,7 +2,11 @@ import React from 'react'
import {Image, StyleSheet, TouchableOpacity, ScrollView} from 'react-native' import {Image, StyleSheet, TouchableOpacity, ScrollView} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {colors} from '../../lib/styles' import {colors} from '../../lib/styles'
import {openPicker, openCamera} from 'react-native-image-crop-picker' import {
openPicker,
openCamera,
ImageOrVideo,
} from 'react-native-image-crop-picker'
import {observer} from 'mobx-react-lite' import {observer} from 'mobx-react-lite'
export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({ export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({
@ -22,8 +26,7 @@ export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({
<TouchableOpacity <TouchableOpacity
style={[styles.galleryButton, styles.photo]} style={[styles.galleryButton, styles.photo]}
onPress={() => { onPress={() => {
openCamera({multiple: true, maxFiles: 4}).then(item => { openCamera({mediaType: 'photo'}).then(item => {
console.log(item)
setSelectedPhotos([item.path, ...selectedPhotos]) setSelectedPhotos([item.path, ...selectedPhotos])
}) })
}}> }}>
@ -46,15 +49,17 @@ export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({
<TouchableOpacity <TouchableOpacity
style={[styles.galleryButton, styles.photo]} style={[styles.galleryButton, styles.photo]}
onPress={() => { onPress={() => {
openPicker({multiple: true, maxFiles: 4}).then(items => { openPicker({multiple: true, maxFiles: 4, mediaType: 'photo'}).then(
setSelectedPhotos([ items => {
...items.reduce( setSelectedPhotos([
(accum, cur) => accum.concat(cur.sourceURL!), ...items.reduce(
[] as string[], (accum, cur) => accum.concat(cur.sourceURL!),
), [] as string[],
...selectedPhotos, ),
]) ...selectedPhotos,
}) ])
},
)
}}> }}>
<FontAwesomeIcon icon="image" style={{color: colors.blue3}} size={24} /> <FontAwesomeIcon icon="image" style={{color: colors.blue3}} size={24} />
</TouchableOpacity> </TouchableOpacity>