import React, {useState} from 'react'; import {View} from 'react-native'; import {useTracked} from '../../provider'; import {useMenuStore} from '../../provider/stores'; import {ToastEvent} from '../../services/EventManager'; import {db} from '../../utils/database'; import {SIZE} from '../../utils/SizeUtils'; import {ActionIcon} from '../ActionIcon'; import {Button} from '../Button'; import Heading from '../Typography/Heading'; import Paragraph from '../Typography/Paragraph'; export const NotebookHeader = ({notebook, onPress, onEditNotebook}) => { const [state] = useTracked(); const {colors} = state; const [isPinnedToMenu, setIsPinnedToMenu] = useState( db.settings.isPinned(notebook.id) ); const setMenuPins = useMenuStore(state => state.setMenuPins); const onPinNotebook = async () => { try { if (isPinnedToMenu) { await db.settings.unpin(notebook.id); } else { await db.settings.pin(notebook.type, {id: notebook.id}); ToastEvent.show({ heading: 'Shortcut created', type: 'success' }); } setIsPinnedToMenu(db.settings.isPinned(notebook.id)); setMenuPins(); } catch (e) {} }; return ( {notebook.title} {notebook.description && ( {notebook.description} )} {/*