Vitalik
3 years ago
37 changed files with 434 additions and 217 deletions
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
import { Alert, PermissionsAndroid } from 'react-native' |
||||
import { request, check, RESULTS } from 'react-native-permissions' |
||||
|
||||
const requestCameraPermission = async () => { |
||||
try { |
||||
const granted = await PermissionsAndroid.request( |
||||
PermissionsAndroid.PERMISSIONS.CAMERA, |
||||
{ |
||||
title: 'Cool Photo App Camera Permission', |
||||
message: |
||||
'Cool Photo App needs access to your camera ' + |
||||
'so you can take awesome pictures.', |
||||
buttonNegative: 'Cancel', |
||||
buttonPositive: 'OK', |
||||
}, |
||||
) |
||||
console.log({ granted }) |
||||
if (granted === PermissionsAndroid.RESULTS.GRANTED) { |
||||
console.log('You can use the camera') |
||||
} else { |
||||
console.log('Camera permission denied') |
||||
} |
||||
} catch (err) { |
||||
console.warn('requestCameraPermission: ', err) |
||||
} |
||||
} |
||||
|
||||
const checkCameraPermissions = async (permission: any): Promise<boolean> => { |
||||
const perm = await check(permission) |
||||
console.log(permission, perm) |
||||
switch (perm) { |
||||
case RESULTS.GRANTED: |
||||
return true |
||||
case RESULTS.BLOCKED: { |
||||
// needMediaPermissions()
|
||||
break |
||||
} |
||||
case RESULTS.UNAVAILABLE: { |
||||
Alert.alert('Your device does not support this function') |
||||
break |
||||
} |
||||
default: { |
||||
const requestRes = await request(permission) |
||||
|
||||
if (requestRes === RESULTS.GRANTED) return true |
||||
else return false |
||||
} |
||||
} |
||||
} |
||||
|
||||
export const mediaPermissionsService = { |
||||
checkCameraPermissions, |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
import { useTheme } from '@/shared/hooks/use-theme.hook' |
||||
import React from 'react' |
||||
import { ActivityIndicator, StyleSheet, View } from 'react-native' |
||||
|
||||
export const Loading = () => { |
||||
const { theme } = useTheme(() => {}) |
||||
return ( |
||||
<View style={styles.container}> |
||||
<ActivityIndicator color={theme.$secondaryText} /> |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
const styles = StyleSheet.create({ |
||||
container: { |
||||
marginTop: 20, |
||||
}, |
||||
}) |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
import { Txt } from '@/shared' |
||||
import React from 'react' |
||||
import { StyleSheet, View } from 'react-native' |
||||
|
||||
interface NotFoundParams { |
||||
text: string |
||||
} |
||||
|
||||
export const NotFound = (params: NotFoundParams) => { |
||||
return ( |
||||
<View> |
||||
<Txt style={styles.text}>{params.text}</Txt> |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
const styles = StyleSheet.create({ |
||||
text: { |
||||
fontSize: 18, |
||||
textAlign: 'center', |
||||
flex: 1, |
||||
marginTop: 100, |
||||
}, |
||||
}) |
Loading…
Reference in new issue