From bbc7d3b3169e145708c6646a6f4003fc2735f1fb Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Wed, 3 Feb 2021 10:51:11 -0800 Subject: Enabled button functionality --- src/routes/main/MainStackScreen.tsx | 39 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/routes') diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx index 8042d267..15695288 100644 --- a/src/routes/main/MainStackScreen.tsx +++ b/src/routes/main/MainStackScreen.tsx @@ -1,6 +1,7 @@ +import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationOptions} from '@react-navigation/stack'; -import React from 'react'; +import React, {useState} from 'react'; import { CaptionScreen, CategorySelection, @@ -43,6 +44,14 @@ const MainStackScreen: React.FC = ({route}) => { const isSearchTab = screenType === ScreenType.Search; const isNotificationsTab = screenType === ScreenType.Notifications; + AsyncStorage.getItem('respondedToAccessContacts').then((value) => + setRespondedToAccessContacts(value ? value : 'false'), + ); + + const [respondedToAccessContacts, setRespondedToAccessContacts] = useState( + 'false', + ); + const initialRouteName = (() => { switch (screenType) { case ScreenType.Profile: @@ -55,7 +64,7 @@ const MainStackScreen: React.FC = ({route}) => { // If responded is true, show search screen // Else, show RequestContactsAccess // If user responds, update store and Async and remove popup - return 'RequestContactsAccess'; + return 'Search'; case ScreenType.Notifications: return 'Notifications'; } @@ -98,18 +107,20 @@ const MainStackScreen: React.FC = ({route}) => { screenType, }} /> - {isSearchTab && ( - // - - )} + {isSearchTab && + (respondedToAccessContacts && respondedToAccessContacts === 'true' ? ( + + ) : ( + + ))} {isNotificationsTab && (