mirror of https://github.com/tooot-app/app
Simple permission request
This commit is contained in:
parent
3473337442
commit
c9726d904f
|
@ -31,7 +31,6 @@
|
||||||
"expo-linear-gradient": "~8.4.0",
|
"expo-linear-gradient": "~8.4.0",
|
||||||
"expo-linking": "~2.0.0",
|
"expo-linking": "~2.0.0",
|
||||||
"expo-localization": "~9.1.0",
|
"expo-localization": "~9.1.0",
|
||||||
"expo-permissions": "~10.0.0",
|
|
||||||
"expo-random": "~10.0.0",
|
"expo-random": "~10.0.0",
|
||||||
"expo-secure-store": "~9.3.0",
|
"expo-secure-store": "~9.3.0",
|
||||||
"expo-splash-screen": "~0.8.1",
|
"expo-splash-screen": "~0.8.1",
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
import Emojis from '@components/Timelines/Timeline/Shared/Emojis'
|
import Emojis from '@components/Timelines/Timeline/Shared/Emojis'
|
||||||
import {
|
import { ComposeContext } from '@screens/Shared/Compose'
|
||||||
ComposeAction,
|
|
||||||
ComposeState,
|
|
||||||
ComposeContext
|
|
||||||
} from '@screens/Shared/Compose'
|
|
||||||
import ComposeActions from '@screens/Shared/Compose/Actions'
|
import ComposeActions from '@screens/Shared/Compose/Actions'
|
||||||
import ComposeRootFooter from '@screens/Shared/Compose/Root/Footer'
|
import ComposeRootFooter from '@screens/Shared/Compose/Root/Footer'
|
||||||
import ComposeRootHeader from '@screens/Shared/Compose/Root/Header'
|
import ComposeRootHeader from '@screens/Shared/Compose/Root/Header'
|
||||||
|
@ -31,6 +27,7 @@ import {
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import { Chase } from 'react-native-animated-spinkit'
|
import { Chase } from 'react-native-animated-spinkit'
|
||||||
import { useQuery } from 'react-query'
|
import { useQuery } from 'react-query'
|
||||||
|
import { ComposeAction, ComposeState } from './utils/types'
|
||||||
|
|
||||||
const ListItem = React.memo(
|
const ListItem = React.memo(
|
||||||
({
|
({
|
||||||
|
@ -125,20 +122,6 @@ const ComposeRoot: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, [composeState.tag?.text])
|
}, [composeState.tag?.text])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
;(async () => {
|
|
||||||
Permissions.askAsync(Permissions.CAMERA)
|
|
||||||
// const permissionGaleery = await ImagePicker.requestCameraRollPermissionsAsync()
|
|
||||||
// if (permissionGaleery.status !== 'granted') {
|
|
||||||
// alert('Sorry, we need camera roll permissions to make this work!')
|
|
||||||
// }
|
|
||||||
// const permissionCamera = await ImagePicker.requestCameraPermissionsAsync()
|
|
||||||
// if (permissionCamera.status !== 'granted') {
|
|
||||||
// alert('Sorry, we need camera roll permissions to make this work!')
|
|
||||||
// }
|
|
||||||
})()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const { data: emojisData } = useQuery(['Emojis'], emojisFetch)
|
const { data: emojisData } = useQuery(['Emojis'], emojisFetch)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (emojisData && emojisData.length) {
|
if (emojisData && emojisData.length) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as ImagePicker from 'expo-image-picker'
|
||||||
import { ImageInfo } from 'expo-image-picker/build/ImagePicker.types'
|
import { ImageInfo } from 'expo-image-picker/build/ImagePicker.types'
|
||||||
import * as VideoThumbnails from 'expo-video-thumbnails'
|
import * as VideoThumbnails from 'expo-video-thumbnails'
|
||||||
import { Dispatch } from 'react'
|
import { Dispatch } from 'react'
|
||||||
import { ActionSheetIOS, Alert } from 'react-native'
|
import { ActionSheetIOS, Alert, Linking } from 'react-native'
|
||||||
import { ComposeAction } from './utils/types'
|
import { ComposeAction } from './utils/types'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
@ -103,6 +103,23 @@ const addAttachment = async ({ composeDispatch }: Props): Promise<any> => {
|
||||||
},
|
},
|
||||||
async buttonIndex => {
|
async buttonIndex => {
|
||||||
if (buttonIndex === 0) {
|
if (buttonIndex === 0) {
|
||||||
|
const {
|
||||||
|
status
|
||||||
|
} = await ImagePicker.requestMediaLibraryPermissionsAsync()
|
||||||
|
if (status !== 'granted') {
|
||||||
|
Alert.alert('🈚️读取权限', '需要相片权限才能上传照片', [
|
||||||
|
{
|
||||||
|
text: '取消',
|
||||||
|
style: 'cancel',
|
||||||
|
onPress: () => {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '去系统设置',
|
||||||
|
style: 'default',
|
||||||
|
onPress: () => Linking.openURL('app-settings:')
|
||||||
|
}
|
||||||
|
])
|
||||||
|
} else {
|
||||||
const result = await ImagePicker.launchImageLibraryAsync({
|
const result = await ImagePicker.launchImageLibraryAsync({
|
||||||
mediaTypes: ImagePicker.MediaTypeOptions.All,
|
mediaTypes: ImagePicker.MediaTypeOptions.All,
|
||||||
exif: false
|
exif: false
|
||||||
|
@ -111,7 +128,23 @@ const addAttachment = async ({ composeDispatch }: Props): Promise<any> => {
|
||||||
if (!result.cancelled) {
|
if (!result.cancelled) {
|
||||||
uploadAttachment(result)
|
uploadAttachment(result)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (buttonIndex === 1) {
|
} else if (buttonIndex === 1) {
|
||||||
|
const { status } = await ImagePicker.requestCameraPermissionsAsync()
|
||||||
|
if (status !== 'granted') {
|
||||||
|
Alert.alert('🈚️读取权限', '需要相机权限才能上传照片', [
|
||||||
|
{
|
||||||
|
text: '取消',
|
||||||
|
style: 'cancel',
|
||||||
|
onPress: () => {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '去系统设置',
|
||||||
|
style: 'default',
|
||||||
|
onPress: () => Linking.openURL('app-settings:')
|
||||||
|
}
|
||||||
|
])
|
||||||
|
} else {
|
||||||
const result = await ImagePicker.launchCameraAsync({
|
const result = await ImagePicker.launchCameraAsync({
|
||||||
mediaTypes: ImagePicker.MediaTypeOptions.All,
|
mediaTypes: ImagePicker.MediaTypeOptions.All,
|
||||||
exif: false
|
exif: false
|
||||||
|
@ -122,6 +155,7 @@ const addAttachment = async ({ composeDispatch }: Props): Promise<any> => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue