import React from 'react'; import {TouchableOpacity, View} from 'react-native'; import {notesnook} from '../../../e2e/test.ids'; import {useTracked} from '../../provider'; import Navigation from '../../services/Navigation'; import {ph, pv, SIZE, WEIGHT} from '../../utils/SizeUtils'; import {ActionIcon} from '../ActionIcon'; import {ActionSheetEvent} from '../DialogManager/recievers'; import Seperator from '../Seperator'; import Heading from '../Typography/Heading'; import Paragraph from '../Typography/Paragraph'; export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, customStyle, }) => { const [state] = useTracked(); const {colors} = state; const showActionSheet = () => { let rowItems = isTrash ? ['Restore', 'Remove'] : [item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook', 'Delete']; let columnItems = item.type === 'topic' ? ['Pin to Menu', 'Unpin from Menu'] : ['Pin', 'Pin to Menu', 'Unpin from Menu']; ActionSheetEvent(item, false, false, rowItems, columnItems, { notebookID: notebookID, }); }; return ( {item.title} {isTopic || !item.description ? null : ( {item.description} )} {isTopic ? null : ( {item && item.topics ? ( item.topics.slice(1, 3).map((topic) => ( { Navigation.navigate('NotesPage', { ...topic, }); }} key={topic.dateCreated.toString() + topic.title} style={{ borderRadius: 2.5, backgroundColor: colors.accent, paddingHorizontal: ph / 1.5, paddingVertical: pv / 3, marginRight: 5, marginVertical: 2.5, }}> {topic.title} )) ) : ( This notebook has no topics. )} )} {isTrash ? ( {'Deleted on: ' + item && item.dateDeleted ? new Date(item.dateDeleted).toISOString().slice(0, 10) : null + ' '} {item.type[0].toUpperCase() + item.type.slice(1) + ' '} ) : null} {isTrash ? null : ( {new Date(item.dateCreated).toDateString().substring(4)} )} {item && item.totalNotes && item.totalNotes > 1 ? item.totalNotes + ' Notes' : item.totalNotes === 1 ? item.totalNotes + ' Note' : '0 Notes'} {item.title === 'General' && item.type === 'topic' ? null : ( )} ); };