React Native, Custom DrawerContent navigator issue - reactjs

I have a custom DrawerContent component and I am unable to navigate to a screen from it using navigator.navigate('DrawerHelp').
I am still getting this error and I really have no idea how to fix it.
I am trying to navigate from the Help button to its own component called DrawerHelp.
issue The action 'NAVIGATE' with payload {"name":"DrawerHelp"} was not handled by any navigator
This is my code below.
function DrawerComponent() {
return (
<Drawer.Navigator
drawerContentOptions={{activeBackgroundColor: '#efefef', activeTintColor: '#000000'}}
initialRouteName="Tabs"
drawerStyle={{ backgroundColor:'#ffffff', width:'85%', paddingBottom: 50 }}
drawerContent={
props => ( <CustomDrawerContent {...props} /> )
}>
<Drawer.Screen name="Dashboard" component={Tabs} options={{
drawerIcon: config => <Ionicons name={'ios-home'} size={18} color={'#444'} headerTitle="AAA" />,
}} />
<Drawer.Screen name="Help" component={DrawerHelp}
options={{
drawerIcon: config => <Ionicons name={'ios-people-circle-outline'} size={18} color={'#444'}/>,
}}
/>
</Drawer.Navigator>
);
}
export function CustomDrawerContent (props) {
const [ tabs, setTabs ] = useState([
{
name: 'Help',
icon: 'ios-call',
borderColor: '#e7c53f',
backgroundColor: '#fff',
color: '#e7c53f',
fontWeight: '500'
},{
name: 'Share',
icon: 'ios-megaphone',
borderColor: '#e7c53f',
backgroundColor: '#fff',
color: '#e7c53f',
fontWeight: '500'
},{
name: 'Logout',
icon: 'ios-log-out',
borderColor: '#e7c53f',
backgroundColor: '#fff',
color: '#e7c53f',
fontWeight: '500'
}
]);
return (
<DrawerContentScrollView {...props}>
<DrawerItemList {...props} />
<View style={{ padding: 15 }}>
<View style={{
flexDirection: 'row',
justifyContent: 'space-between',
height: 50,
alignItems: 'center'
}}>
{
tabs.map((tab) => {
return (
<TouchableOpacity
key={tab.name}
style={{
height: '100%',
flex: .32,
alignItems: 'center',
borderWidth: .5,
borderColor: tab.borderColor,
backgroundColor: tab.backgroundColor,
borderRadius: 10,
flexDirection: 'row',
justifyContent: 'space-evenly'
}}
onPress={() => {
if(tab.name == 'Logout') {
// navigation.toggleDrawer();
}
if(tab.name == 'Share') {
// onShare();
}
if(tab.name == 'Help') {
props.navigation.navigate('DrawerHelp');
}
}}>
<Ionicons name={tab.icon} size={18} style={{ color: tab.color }} />
<Text style={{ color: tab.color, fontWeight: tab.fontWeight }}>{trans(tab.name, cntx.lang)}</Text>
</TouchableOpacity>
)
})
}
</View>
</View>
</DrawerContentScrollView>
);
}

It is not working because you have defined DrawerComponent with name 'Help'
<Drawer.Screen name="Help" component={DrawerHelp}
options={{drawerIcon: config => <Ionicons name={'ios-people-circle-outline'} size={18} color={'#444'}/>
if(tab.name == 'Help') {
props.navigation.navigate('DrawerHelp'); <== Change here to Help not DrawerHelp
}

Related

useEffect not firing on state update

I am updating some state with useState() in my react native component. Once I have that state set I want to save the details to the server, so I have set that up in an useEffect() hook. To be clear, the setting of the state IS working, and I see the value print to the screen.
However, what I'm noticing is, even though I've set note as a dependency in the dependency array of the useEffect() hook, the function never fires when the state updates. What am I missing here?
const [note, setNote] = useState('');
const dispatch = useDispatch();
useEffect(() => {
if (note) {
console.log('updating note...');
dispatch(updateNote(props.client.id, note));
}
}, [note]);
FYI, I am updating the state inside a TextInput, like so (I had to use onBlur to avoid the issue of react loosing focus on the first character type because I am passing a component within screenOptions of a TabNavigator):
<TextInput
key='note'
style={{
color: '#fff',
fontSize: 16,
width: '100%',
textAlign: 'center',
}}
placeholder='Tap here to share something...'
placeholderTextColor={styles.colors.textPlaceholder}
maxLength={50}
onBlur={(text) => setNote(text)}
defaultValue={note || props?.client?.note?.value}
/>
As I mentioned, this has been a tricky situation because I had to get around react's loss of focus when I rely on onChangeText() or onChange(). I am passing in a CustomHeader - which is a function inside the parent, to a TabNavigator within screenOptions like so:
screenOptions={{
headerShown: true,
headerStyle: {
backgroundColor: Colors.primary,
elevation: 0,
shadowOpacity: 0,
shadowColor: 'transparent',
height: 170,
},
key: 'patient-tab',
headerShadowVisible: false,
tabBarStyle: { backgroundColor: Colors.primary },
headerTintColor: Colors.light,
headerTitle: (props) => <CustomHeader {...props} />, // Passed in here
tabBarActiveTintColor: Colors.light,
tabBarInactiveTintColor: Colors.lightInactive,
tabBarActiveBackgroundColor: Colors.primary,
tabBarInactiveBackgroundColor: Colors.primary,
}}
The full code looks like this:
export const ClientBottomTabNavigator = (props) => {
const [note, setNote] = useState('');
const dispatch = useDispatch();
useEffect(() => {
if (props.client.id && note) {
console.log('updating note...');
dispatch(updateNote(props.client.id, note));
}
}, [props.client.id, note]);
const CustomHeader = () => {
return (
<View>
<View style={{ width: '100%', flexDirection: 'row', justifyContent: 'space-between', marginBottom: 6 }}>
<Feather
name='chevron-left'
size={24}
onPress={() => props.navigation.goBack()}
color={styles.colors.textInverse}
style={{ justifySelf: 'flex-start', alignSelf: 'flex-start', width: '32%', marginBottom: 6 }}
/>
<Text
style={{
color: '#fff',
fontSize: 18,
alignSelf: 'center',
justifySelf: 'center',
fontWeight: 'bold',
}}
>
{props?.client?.firstName} {props?.client?.lastName}
</Text>
<Feather
name='' // Leave this blank
style={{ justifySelf: 'flex-end', alignSelf: 'flex-end', width: '32%' }}
/>
</View>
<View style={{ alignItems: 'center', marginBottom: 6 }}>
<Text style={{ color: '#fff', fontSize: 18, marginBottom: 6 }}>
{convertDiscipline(props?.client?.discipline)}
</Text>
<View>
<TextInput
key='note'
style={{
color: '#fff',
fontSize: 16,
width: '100%',
textAlign: 'center',
}}
placeholder='Tap here to share something…’
placeholderTextColor={styles.colors.textPlaceholder}
maxLength={50}
onBlur={(text) => setNote(text)}
defaultValue={note || props?.client?.note?.value}
/>
</View>
</View>
</View>
);
};
const Tab = createBottomTabNavigator();
return (
<Tab.Navigator
screenOptions={{
headerShown: true,
headerStyle: {
backgroundColor: Colors.primary,
elevation: 0,
shadowOpacity: 0,
shadowColor: 'transparent',
height: 170,
},
key: 'client-tab',
headerShadowVisible: false,
tabBarStyle: { backgroundColor: Colors.primary },
headerTintColor: Colors.light,
headerTitle: (props) => <CustomHeader {...props} />, // Passed in here
tabBarActiveTintColor: Colors.light,
tabBarInactiveTintColor: Colors.lightInactive,
tabBarActiveBackgroundColor: Colors.primary,
tabBarInactiveBackgroundColor: Colors.primary,
}}
initialRouteName={'Visits'}
>
<Tab.Screen
name='Visits'
component={VisitsTab}
options={{
tabBarLabel: 'VISITS',
tabBarIcon: ({ color, size }) => <FontAwesome name='street-view' color={color} size={size} />,
}}
/>
<Tab.Screen
name='Chart'
component={ChartTab}
options={{
tabBarLabel: 'CHARTS',
tabBarIcon: ({ color, size }) => <FontAwesome name='id-badge' color={color} size={size} />,
}}
/>
<Tab.Screen
name='Goals'
component={GoalsTab}
options={{
tabBarLabel: 'EDIT GOALS',
tabBarIcon: ({ color, size }) => <FontAwesome name='trophy' color={color} size={size} />,
}}
/>
</Tab.Navigator>
);
};
See here https://playcode.io/1106437, it works, but you have onBlur, you need to blur to trigger the action, maybe you need to use onChangeText insted.

React native - dispatching action gets me back to first screen, but it shouldnt

I'been having this odd issue for quite a while. Whenever I dispatch any of action from my context API i get send back to the first screen in Stack Navigation (expo react native).
Is there a way to fix this ?
Files:
context.js
import { createContext } from 'react';
export const AppContext = createContext();
App.js
export default function App() {
const Stack = createNativeStackNavigator();
// GLOBAL STATE
const [alarms, setAlarms] = useState([]);
const dispatchAlarmEvent = (actionType, payload) => {
switch (actionType) {
case 'ADD_ALARM':
setAlarms([ ...alarms, payload ]);
break; // return;
case 'REMOVE_ALARM':
setAlarms([...alarms.filter(alarm => alarm.id !== payload.id)]);
break; // return;
case 'EDIT_ALARM':
setAlarms([...alarms.filter(alarm => alarm.id !== payload.id), payload]);
break; // return;
default:
break; // return;
}
};
const log = (x)=> console.log(x)
return (
<AppContext.Provider value={ { alarms , dispatchAlarmEvent, log} }>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Start" component={Start} options={{
headerShown: false,
title: 'Start',
}} />
<Stack.Screen name="Home" component={Home} options={{
headerStyle: { backgroundColor: Theme.primary },
headerTintColor: 'rgb(243,243,243)',
headerTitleStyle: { fontWeight: 'bold' },
title: 'Alarms List',
}} />
<Stack.Screen name="AddAlarm" component={AddAlarmForm} options={{
headerStyle: { backgroundColor: Theme.primary },
headerTintColor: 'rgb(243,243,243)',
headerTitleStyle: { fontWeight: 'bold' },
title: 'Add Alarm',
}} />
</Stack.Navigator>
</NavigationContainer>
</AppContext.Provider>
)
}
and example of place where I dispatch action:
Item.js
const AlarmItem = (props) => {
const [isEnabled, setIsEnabled] = useState(props.ring);
const [ expanded, toggleExpanded ] = useBool(false);
const [ arrowUpyDowny, setArrowUpyDowny ] = useState(faChevronDown);
const [ height, setHeight ] = useState(new Animated.Value(0))
const { dispatchAlarmEvent } = useContext(AppContext)
const week = ["Mon.", "Tues.", "Wed.", "Thurs.", "Fri.", "Sat.", "Sun."]
const toggle = () => {
const toPos = ( !expanded )? 140 : 0;
Animated.spring(height, {
toValue: toPos,
useNativeDriver: false,
}).start();
toggleExpanded()
}
const deleteItem = () =>{
console.log( props.id )
dispatchAlarmEvent('REMOVE_ALARM', { id: props.id });
Database.remove(props.id)
}
useEffect( ()=> {
}, [isEnabled])
return (
<View style={styles.container}>
<View style={styles.row}>
<Text style={styles.time}> { props.hours } : { props.minutes } </Text>
<Switch
trackColor={{ false: "#767577", true: Theme.primary+'5d' }}
thumbColor={isEnabled ? Theme.primary : "#f4f3f4"}
ios_backgroundColor="#3e3e3e"
onValueChange={()=> setIsEnabled(!isEnabled)}
value={isEnabled}
style={{ flex: 1 }}
/>
</View>
<View style={[styles.row, { borderTopWidth: 0 }]}>
<TouchableNativeFeedback
background={TouchableNativeFeedback.Ripple('rgba(255,255,255,1)', true)}
onPress={() => deleteItem()}
style={{
width: 60,
height: 60,
}}
>
<View style={{ margin: 10, width: 50, height: 50, background: "red", justifyContent: 'center', alignItems: 'center', backgroundColor: Theme.primary, borderRadius: 50 }}>
<FontAwesomeIcon icon={ faTrash } color={'#fff'}/>
</View>
</TouchableNativeFeedback>
<TouchableNativeFeedback
background={TouchableNativeFeedback.Ripple('rgba(255,255,255,1)', true)}
onPress={() => toggle()}
style={{
width: 60,
height: 60,
}}
>
<View style={{ margin: 10, width: 50, height: 50, background: "red", justifyContent: 'center', alignItems: 'center', backgroundColor: Theme.primary, borderRadius: 50 }}>
<FontAwesomeIcon icon={ (!expanded)? faChevronDown: faChevronUp } color={'#fff'}/>
</View>
</TouchableNativeFeedback>
</View>
<Animated.View style={{
height: height, // animowany styl, tutaj wysokość View
// backgroundColor: "#FF0000",
}} >
{
(expanded) && (<View style={styles.unfolded}>
{
props.days.map( (day,i)=> ( <TouchableNativeFeedback
key={i}
background={TouchableNativeFeedback.Ripple('rgba(255,255,255,1)', true)}
onPress={() => alert('xx')}
style={{
width: 30,
height: 30,
}}
>
<View style={{ margin: 3, width: 50, height: 50, justifyContent: 'center', alignItems: 'center', color: '#fff', backgroundColor: (day)? Theme.lighter: 'rgba(255,255,255,.3)', borderRadius: 50, }}>
<Text style={{color: '#fff'}}> { week[i] } </Text>
</View>
</TouchableNativeFeedback> ))
}
</View>)
}
</Animated.View>
</View>
)
}
Please if you have any clues? or perhaps i am doing sth wrong. Thx in advance

Add submenu on drawer react native

I am using below code to show a menu on react native. I need to show a submenu but I cannot figure out how.
<Drawer.Navigator
drawerContentOptions={{
activeTintColor: '#cee1f2',
color: '#cee1f2',
itemStyle: {marginVertical: 5, color: 'white'},
labelStyle: {
color: '#d8d8d8',
},
}}
screenOptions={{headerShown: false}}
drawerContent={CustomSidebarMenu}>
<Drawer.Screen
name="homeScreenStack"
options={{drawerLabel: 'Home Screen'}}
component={homeScreenStack}
/>
<Drawer.Screen
name="settingScreenStack"
options={{drawerLabel: 'Setting Screen'}}
component={settingScreenStack}
/>
</Drawer.Navigator>
Here is Customesidebar code.
// Import React and Component
import React from 'react';
import {View, Text, Alert, StyleSheet} from 'react-native';
import {
DrawerContentScrollView,
DrawerItemList,
DrawerItem,
} from '#react-navigation/drawer';
import AsyncStorage from '#react-native-community/async-storage';
const CustomSidebarMenu = (props) => {
return (
<View style={stylesSidebar.sideMenuContainer}>
<View style={stylesSidebar.profileHeader}>
<View style={stylesSidebar.profileHeaderPicCircle}>
<Text style={{fontSize: 25, color: '#307ecc'}}>
{'DishUp'.charAt(0)}
</Text>
</View>
<Text style={stylesSidebar.profileHeaderText}>
DishUp
</Text>
</View>
<View style={stylesSidebar.profileHeaderLine} />
<DrawerContentScrollView {...props}>
<DrawerItemList {...props} />
<DrawerItem
label={({color}) =>
<Text style={{color: '#d8d8d8'}}>
Logout
</Text>
}
onPress={() => {
props.navigation.toggleDrawer();
Alert.alert(
'Logout',
'Are you sure? You want to logout?',
[
{
text: 'Cancel',
onPress: () => {
return null;
},
},
{
text: 'Confirm',
onPress: () => {
AsyncStorage.clear();
props.navigation.replace('Auth');
},
},
],
{cancelable: false},
);
}}
/>
</DrawerContentScrollView>
</View>
);
};
export default CustomSidebarMenu;
const stylesSidebar = StyleSheet.create({
sideMenuContainer: {
width: '100%',
height: '100%',
backgroundColor: '#307ecc',
paddingTop: 40,
color: 'white',
},
profileHeader: {
flexDirection: 'row',
backgroundColor: '#307ecc',
padding: 15,
textAlign: 'center',
},
profileHeaderPicCircle: {
width: 60,
height: 60,
borderRadius: 60 / 2,
color: 'white',
backgroundColor: '#ffffff',
textAlign: 'center',
justifyContent: 'center',
alignItems: 'center',
},
profileHeaderText: {
color: 'white',
alignSelf: 'center',
paddingHorizontal: 10,
fontWeight: 'bold',
},
profileHeaderLine: {
height: 1,
marginHorizontal: 20,
backgroundColor: '#e2e2e2',
marginTop: 15,
},
});
Here is what it looks like right now. But I want to add a submenu inside Home and Screen. How can I achieve this?

not able to logging out from the app in react native?

i am working on a react native project using redux. i have one stack navigator and one drawer navigator.
i am not able to logout from the app. i want to change store value while logging out. when i am dispatching the action from the logout onPress. it throws error: props.dispatch is not a function. how do i call. i tried many ways it always throwing an error. and how to set all reducers value to intial state while logout? Thank you in advance
App.js
<RootStack.Navigator screenOptions={{
headerShown: false
}}>
{/* <StatusBar backgroundColor={isLoading ? '#000000' : '#F3F3F3'} /> */}
{this.props.data.splashScreen.loading ?
(<RootStack.Screen name={'SplashScreen'} component={SplashScreen} />) :
this.props.data.login.isAuthorized ?
(<RootStack.Screen name="MainNavigator" component={MainNavigator} />)
:
(
<RootStack.Screen name="Login" component={MainStack} />)}
</RootStack.Navigator>
splashScreen and login are reducer store value
MainNavigator.js
const GradientHeader = (props) => (
<View style={{ backgroundColor: "transparent" }}>
<LinearGradient
colors={["#6CCFF6", "#596AB2"]}
start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }}
style={
{
/* height: 128 */
/* height: Header.HEIGHT */
}
}
>
<Header {...props} />
</LinearGradient>
</View>
);
const DashboardStackScreen = ({ navigation }) => {
return (
<DashboardStack.Navigator
screenOptions={{
headerTitle: "Good Morning, John",
header: (props) => <GradientHeader {...props} />,
headerLeft: () => (
<TouchableOpacity onPress={navigation.openDrawer} style={{ padding: 20 }}>
<Image source={require("../assets/images/menu_bar.png")} style={{ width: 18, height: 12 }} />
</TouchableOpacity>
),
headerTransparent: true,
headerStyle: {
backgroundColor: "transparent",
},
headerTintColor: "#fff",
headerTitleStyle: { fontFamily: "OpenSans-SemiBold", fontSize: 20 },
}}
>
<DashboardStack.Screen name="Dashboard" component={Dashboard} />
</DashboardStack.Navigator>
);
};
export default ({ navigation }) => {
return (
<Drawer.Navigator
initialRouteName="Dashboard"
drawerContent={(props) => <DrawerContent {...props} />}
hideStatusBar={false}
focused={true}
labelStyle={{ fontSize: 14, fontFamily: "OpenSans-SemiBold" }}
drawerContentOptions={{ activeBackgroundColor: "#F1F1F1", activeTintColor: "#000000", inactiveTintColor: "#818181", itemStyle: { marginLeft: 0, paddingHorizontal: 10, width: "100%", borderRadius: 0 } }}
>
<Drawer.Screen
name="Dashboard"
component={DashboardStackScreen}
options={{
drawerIcon: ({ focused, size }) => <Image source={require("../assets/images/dashboard.png")} style={{ height: 17.78, width: 16 }} resizeMode="contain" />,
}}
/>
<Drawer.Screen
name="My Profile"
component={MyProfileStackScreen}
options={{
drawerIcon: ({ focused, size }) => <Image source={require("../assets/images/profile.png")} style={{ height: 16, width: 16 }} resizeMode="contain" />,
}}
/>
</Drawer.Navigator>
);
};
DrawerContent.js
import { resetData } from "../Storage/Storage";
export function DrawerContent(props) {
return (
<SafeAreaView style={styles.baseContainer}>
<KeyboardAvoidingView behaviour="padding" style={styles.baseContainer}>
<TouchableWithoutFeedback style={styles.baseContainer} onPress={Keyboard.dismiss}>
<View style={styles.baseContainer}>
<TouchableOpacity
style={{ flex: 2, alignItems: "center", justifyContent: "center" }}
onPress={() => {
props.navigation.navigate("Dashboard");
}}
>
<Image source={require("../assets/images/MJB_Logo.png")} style={{ width: 197, height: 59 }} />
</TouchableOpacity>
<View style={{ flex: 5 }}>
<DrawerContentScrollView {...props}>
<DrawerItemList {...props} />
<DrawerItem
labelStyle={{ fontSize: 14, fontFamily: "OpenSans-SemiBold" }}
activeBackgroundColor="#F1F1F1"
activeTintColor="#000000"
inactiveTintColor="#818181"
label="Logout"
icon={({ focused, color, size }) => {
return <Image source={require("../assets/images/logout.png")} style={{ height: 14.36, width: 14.36 }} resizeMode="contain" />;
}}
onPress={() => resetData()}
/>
</DrawerContentScrollView>
</View>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</SafeAreaView>
);
}
Storage.js
export const resetData = async () => {
try {
//await AsyncStorage.removeItem('isRemembered')
await AsyncStorage.removeItem("userDetails");
} catch (e) {
// saving error
}
};

get index from flatlist react native

So I am basically looking for the error and what I am doing wrong,
I got a data with diffrent key for each, and I am trying to get the data of the activeRow,
for some reason I got undefined for some reason, what is going on? Thanks!
I am getting undefined after trying to log the "this.props.index" I already called constructor(props) and super(props), So I have no idea why why I am trying to log my prop it says undefined instead of giving me the index or the item...
there is my render!
render() {
const swipeSettings = {
autoClose: true,
buttonWidth: 130,
onClose: (secId, rowId, direction) => {
if (this.state.activeRowKey != null) {
this.setState({ activeRowKey: null })
}
},
onOpen: (secId, rowId, direction) => {
this.setState({ activeRowKey: this.props.index })
console.log(this.state.activeRowKey)
},
right: [
{
onPress: () => {
},
text: 'Verify', type: 'default', backgroundColor: 'lime', color: 'black', component: (
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
}}
>
<Ionicons name="md-checkmark" size={40} />
</View>
)
}
],
left: [
{
onPress: () => {
},
text: '', type: 'default', backgroundColor: '#e6e6e6', color: 'black', component: (
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
}}
>
<Ionicons style={{ color: 'green' }} name="ios-call" size={40} />
</View>
)
}
],
rowId: this.props.index,
sectionId: 1
};
if (this.state.loading) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<ActivityIndicator />
</View>
);
}
return (
<View style={{ flex: 1, backgroundColor: 'grey' }}>
<SearchBar
placeholder="Type Here..."
lightTheme
round
height={60}
onChangeText={text => this.searchFilterFunction(text)}
autoCorrect={false}
value={this.state.value}
/>
<FlatList
data={this.state.data}
renderItem={({ item,index }) => (
<Swipeout {...swipeSettings}>
<ListItem
keyExtractor={this.keyExtractor}
index={index}
titleStyle={{ textAlign: 'center', fontWeight: 'bold', color: 'black', fontSize: 20, height: 60, maxHeight: 35, justifyContent: 'center' }}
title={`${item.guestname}`}
/>
</Swipeout>
)}
keyExtractor={item => item.key}
contentContainerStyle={{ margin: 5, textAlign: 'center', }}
ItemSeparatorComponent={this.renderSeparator}
/>
<SafeAreaView style={{ height: 100, backgroundColor: '#3271e7', justifyContent: 'center', alignItems: 'center' }}>
<TouchableOpacity style={{ justifyContent: 'center', alignItems: 'center' }}>
<Ionicons style={styles.imagestyle} size={60} name="ios-barcode" />
</TouchableOpacity>
</SafeAreaView>
</View>
);
}
At the place your are trying to recover this.props.index you don't have the value yet i recomend passing the open and rowid props to your Swipeout and recover the index as it is:
render() {
const swipeSettings = {
autoClose: true,
buttonWidth: 130,
onClose: (secId, rowId, direction) => {
if (this.state.activeRowKey != null) {
this.setState({ activeRowKey: null })
}
},
right: [
{
onPress: () => {
},
text: 'Verify', type: 'default', backgroundColor: 'lime', color: 'black', component: (
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
}}
>
<Ionicons name="md-checkmark" size={40} />
</View>
)
}
],
left: [
{
onPress: () => {
},
text: '', type: 'default', backgroundColor: '#e6e6e6', color: 'black', component: (
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
}}
>
<Ionicons style={{ color: 'green' }} name="ios-call" size={40} />
</View>
)
}
],
sectionId: 1
};
if (this.state.loading) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<ActivityIndicator />
</View>
);
}
return (
<View style={{ flex: 1, backgroundColor: 'grey' }}>
<SearchBar
placeholder="Type Here..."
lightTheme
round
height={60}
onChangeText={text => this.searchFilterFunction(text)}
autoCorrect={false}
value={this.state.value}
/>
<FlatList
data={this.state.data}
renderItem={({ item, index }) => (
<Swipeout
{...swipeSettings}
onOpen={(secId, rowId, direction) => {
this.setState({ activeRowKey: index })
console.log(this.state.activeRowKey)
}
}
rowId={index}
>
<ListItem
keyExtractor={this.keyExtractor}
index={index}
titleStyle={{ textAlign: 'center', fontWeight: 'bold', color: 'black', fontSize: 20, height: 60, maxHeight: 35, justifyContent: 'center' }}
title={`${item.guestname}`}
/>
</Swipeout>
)}
keyExtractor={item => item.key}
contentContainerStyle={{ margin: 5, textAlign: 'center', }}
ItemSeparatorComponent={this.renderSeparator}
/>
<SafeAreaView style={{ height: 100, backgroundColor: '#3271e7', justifyContent: 'center', alignItems: 'center' }}>
<TouchableOpacity style={{ justifyContent: 'center', alignItems: 'center' }}>
<Ionicons style={styles.imagestyle} size={60} name="ios-barcode" />
</TouchableOpacity>
</SafeAreaView>
</View>
);
}

Resources