diff options
| author | Shravya Ramesh <shravs1208@gmail.com> | 2021-02-03 10:51:11 -0800 |
|---|---|---|
| committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-02-03 10:51:11 -0800 |
| commit | bbc7d3b3169e145708c6646a6f4003fc2735f1fb (patch) | |
| tree | 263c7b6c5388dae39104a8cdc73d7c366ee036b2 /src/screens | |
| parent | c4de05cff65c1b81c135aeee6c8fe2ed6420ba5d (diff) | |
Enabled button functionality
Diffstat (limited to 'src/screens')
| -rw-r--r-- | src/screens/search/RequestContactsAccess.tsx | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/screens/search/RequestContactsAccess.tsx b/src/screens/search/RequestContactsAccess.tsx index af511f23..c869ed1e 100644 --- a/src/screens/search/RequestContactsAccess.tsx +++ b/src/screens/search/RequestContactsAccess.tsx @@ -14,9 +14,30 @@ import {useNavigation} from '@react-navigation/native'; import {SafeAreaView} from 'react-native-safe-area-context'; import Animated from 'react-native-reanimated'; import LinearGradient from 'react-native-linear-gradient'; +import {checkPermission, requestPermission} from 'react-native-contacts'; +import AsyncStorage from '@react-native-community/async-storage'; const RequestContactsAccess: React.FC = () => { const navigation = useNavigation(); + + const handleAllowAccess = async () => { + checkPermission().then((permission) => { + if (permission === 'undefined') { + requestPermission().then((response) => { + if (response === 'authorized' || response === 'denied') { + navigation.navigate('Search'); + } + }); + } + }); + await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + }; + + const handleDontAllowAccess = async () => { + await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + navigation.navigate('Search'); + }; + return ( <LinearGradient colors={BACKGROUND_GRADIENT_MAP[BackgroundGradientType.Light]} @@ -67,16 +88,14 @@ const RequestContactsAccess: React.FC = () => { </Text> </View> <TouchableOpacity - onPress={() => { - console.log('Show IOS opoup'); - }} + onPress={handleAllowAccess} style={styles.allowButton}> <Text style={styles.allowButtonLabel}>Allow Contacts</Text> </TouchableOpacity> <TouchableOpacity accessibilityLabel="Don't allow button" style={styles.dontAllowButton} - onPress={() => navigation.pop()}> + onPress={handleDontAllowAccess}> <Text style={styles.dontAllowButtonText}>Don’t Allow</Text> </TouchableOpacity> </View> |
