I want to assign a ‘Logout’ button to the value ‘cikisYap’ inside the DropDownMenu, but my code seems a bit tangled. Can you help me with this?`
const Tabs = () => {
const navigation = useNavigation();
const authCtx = useContext(AuthContext);
const [open, setOpen] = useState(false);
const [value, setValue] = useState(null);
const items = [
{ label: 'Ayarlar', value: 'ayarlar' },
{ label: 'Yardım', value: 'yardim' },
{ label: 'Çıkış Yap', value: 'cikisYap' }
];
const Tab = createBottomTabNavigator();
const handleDropdownChange = (item) => {
if (item.value === 'cikisYap') {
authCtx.logout();
setOpen(false);
}
};
const renderDropDownButton = () => (
<TouchableOpacity onPress={() => setOpen(!open)}>
<Image
source={require('../../assets/profile-default.jpg')}
style={styles.customButton}
/>
</TouchableOpacity>
);
return (
<Tab.Navigator
headerStyle={{ backgroundColor: Colors.dark100 }}
screenOptions={{
tabBarShowLabel: false,
tabBarStyle: { ...styles.container },
headerRight: () => (
<View
style={{ display: "flex", flexDirection: "row", marginRight: 0 }}
>
<DropDownPicker
open={open}
items={items}
defaultValue={null}
style={{
display: 'none',
backgroundColor: '#fafafa',
borderRadius: 45,
width: 15,
height: 0,
}}
itemStyle={{
justifyContent: 'flex-start',
}}
dropDownStyle={{ backgroundColor: '#fafafa' }}
onChangeItem={(item) => handleDropdownChange(item)}
renderDropDownButton={renderDropDownButton}
/>
<TouchableOpacity onPress={() => setOpen(!open)}>
<View
style={{
marginRight: 10,
paddingRight: 10,
flexDirection: 'row',
alignItems: 'center',
}}
>
<Image
source={require("../../assets/profile-default.jpg")}
style={{ width: 32, height: 32, borderRadius: 32 }}
/>
</View>
</TouchableOpacity>
</View>
),
}}
style={styles.shadow}
>
I have tried everything I can think of, but I couldn’t find a solution. I need urgent help, thank you.’