import * as React from 'react' import { StyleSheet, View } from 'react-native' import { DrawerContentScrollView } from '@react-navigation/drawer' import { Button, Card, Chip, Drawer, IconButton, Text, TouchableRipple, useTheme, } from 'react-native-paper' import Logo from '../Logo' import { useTranslation } from 'react-i18next' import { RelayPoolContext } from '../../Contexts/RelayPoolContext' import { UserContext } from '../../Contexts/UserContext' import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons' import { navigate } from '../../lib/Navigation' import NostrosAvatar from '../NostrosAvatar' import { formatPubKey, username } from '../../Functions/RelayFunctions/Users' export const MenuItems: React.FC = () => { const [drawerItemIndex, setDrawerItemIndex] = React.useState(-1) const { relays } = React.useContext(RelayPoolContext) const { nPub, publicKey, privateKey, user, contactsCount, followersCount, logout } = React.useContext(UserContext) const { t } = useTranslation('common') const theme = useTheme() const onPressLogout: () => void = () => { logout() } const onPressItem: (key: string, index: number) => void = (key, index) => { setDrawerItemIndex(index) if (key === 'relays') { navigate('Relays') } else if (key === 'config') { navigate('Feed', { page: 'Config' }) } else if (key === 'about') { navigate('About') } } return ( <> {nPub && ( navigate('Profile', { pubKey: publicKey, title: username(user) })} > {user?.name} {formatPubKey(publicKey ?? '')} {privateKey && ( navigate('ProfileConfig')} /> )} console.log('Pressed')} > {t('menuItems.following', { following: contactsCount })} console.log('Pressed')} > {t('menuItems.followers', { followers: followersCount })} )} {publicKey && ( } key='relays' active={drawerItemIndex === 0} onPress={() => onPressItem('relays', 0)} onTouchEnd={() => setDrawerItemIndex(-1)} right={() => relays.length < 1 ? ( {t('menuItems.notConnected')} ) : ( {t('menuItems.connectedRelays', { number: relays.length })} ) } /> {/* onPressItem('config', 1)} onTouchEnd={() => setDrawerItemIndex(-1)} /> */} )} onPressItem('about', 2)} onTouchEnd={() => setDrawerItemIndex(-1)} /> {publicKey && ( )} ) } const styles = StyleSheet.create({ logo: { justifyContent: 'center', flexDirection: 'row', }, drawerContent: { flex: 1, borderTopRightRadius: 28, }, cardContainer: { margin: 12, }, cardActions: { flexDirection: 'row', justifyContent: 'space-between', }, cardActionsChip: { width: '47%', }, cardAvatar: { marginRight: 14, }, cardContent: { width: '100%', flexDirection: 'row', }, cardEdit: { flexDirection: 'row', justifyContent: 'flex-end', flex: 1, }, bottomSection: { marginBottom: 0, borderBottomRightRadius: 28, padding: 24, }, }) export default MenuItems