10.9 C
London
Sunday, December 17, 2023

ios – I wish to assign a ‘Logout’ button to the worth ‘cikisYap’ contained in the DropDownMenu


I wish to assign a ‘Logout’ button to the worth ‘cikisYap’ contained in the DropDownMenu, however my code appears a bit tangled. Are you able to assist me with this?`

const Tabs = () => {

  const navigation = useNavigation();
  const authCtx = useContext(AuthContext);
  const [open, setOpen] = useState(false);
  const [value, setValue] = useState(null);
  const objects = [
    { label: 'Ayarlar', value: 'ayarlar' },
    { label: 'Yardım', value: 'yardim' },
    { label: 'Çıkış Yap', value: 'cikisYap' }
  ];
  
    const Tab = createBottomTabNavigator();
    const handleDropdownChange = (merchandise) => {
      if (merchandise.worth === 'cikisYap') {
        authCtx.logout();
        setOpen(false);
      }
    };
  
    const renderDropDownButton = () => (
      <TouchableOpacity onPress={() => setOpen(!open)}>
        <Picture
          supply={require('../../belongings/profile-default.jpg')}
          fashion={kinds.customButton}
        />
      </TouchableOpacity>
    );
  
  
    return (
      <Tab.Navigator
        headerStyle={{ backgroundColor: Colours.dark100 }}
        screenOptions={{
          tabBarShowLabel: false,
          tabBarStyle: { ...kinds.container },
          headerRight: () => (
            <View
              fashion={{ show: "flex", flexDirection: "row", marginRight: 0 }}
            >
              <DropDownPicker
              open={open}
              objects={objects}
              defaultValue={null}
              fashion={{
                show: 'none',
                backgroundColor: '#fafafa',
                borderRadius: 45,
                width: 15,
                peak: 0,
              }}
              itemStyle={{
                justifyContent: 'flex-start',
           }}
              dropDownStyle={{ backgroundColor: '#fafafa' }}
              onChangeItem={(merchandise) => handleDropdownChange(merchandise)}
              renderDropDownButton={renderDropDownButton}
              />
              <TouchableOpacity onPress={() => setOpen(!open)}>
                <View
                  fashion={{
                    marginRight: 10,
                    paddingRight: 10,
                    flexDirection: 'row',
                    alignItems: 'middle',
                  }}
                >
                  <Picture
                    supply={require("../../belongings/profile-default.jpg")}
                    fashion={{ width: 32, peak: 32, borderRadius: 32 }}
                  />
                </View>
              </TouchableOpacity>
            </View>
          ),
        }}
        fashion={kinds.shadow}
      >

I’ve tried every little thing I can consider, however I could not discover a answer. I want pressing assist, thanks.’

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here