import React, {useEffect, useState} from 'react'; import {View, Text, TouchableOpacity} from 'react-native'; import NavigationService from '../../services/NavigationService'; import Menu, {MenuItem, MenuDivider} from 'react-native-material-menu'; import { COLOR_SCHEME, SIZE, br, ph, pv, opacity, FONT, WEIGHT, } from '../../common/common'; import Icon from 'react-native-vector-icons/Feather'; import {w} from '../../utils/utils'; export const NotebookItem = ({ item, index, colors, hideMore, topic, isTopic = false, }) => { let setMenuRef = {}; return ( { NavigationService.navigate('Notebook', { notebook: item, title: hideMore ? 'Choose topic' : item.title, isMove: hideMore ? true : false, hideMore: hideMore ? true : false, }); }} style={{ paddingHorizontal: ph, marginHorizontal: '5%', borderBottomWidth: 1, borderBottomColor: colors.nav, paddingVertical: pv, }}> {item.title} {isTopic ? null : ( {item.description} )} {isTopic ? null : ( {Object.keys(item.topics) .slice(0, 3) .map(topic => ( {topic} ))} )} {isTopic ? null : ( {new Date(item.dateCreated).toDateString().substring(4)} )} {hideMore ? null : ( (setMenuRef[index] = ref)} button={ setMenuRef[index].show()}> }> {' '}Pin { setMenuRef[props.index].hide(); ToastEvent.show( 'Note added to favorites.', 'success', 3000, () => {}, 'Ok', ); }} textStyle={{ color: colors.pri, fontFamily: WEIGHT.regular, fontSize: SIZE.sm, }}> {' '}Favorite { setVisible(true); setMenuRef[index].hide(); }} textStyle={{ color: colors.pri, fontFamily: WEIGHT.regular, fontSize: SIZE.sm, }}> {' '}Delete )} {hideMore && isTopic ? ( { NavigationService.navigate('Home'); }} style={{ borderWidth: 1, borderRadius: 5, width: '20%', paddingHorizontal: ph - 5, borderColor: colors.nav, paddingVertical: pv, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', backgroundColor: colors.accent, }}> Move ) : null} ); };