Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

create wrapper for NoteItem

ammarahm-edb4e5dd831215
diff --git a/apps/mobile/src/components/SimpleList/NoteItemWrapper.js b/apps/mobile/src/components/SimpleList/NoteItemWrapper.js
new file mode 100644
index 000000000..86ac5891b
--- /dev/null
+++ b/apps/mobile/src/components/SimpleList/NoteItemWrapper.js
@@ -0,0 +1,52 @@
+import React from 'react';
+import NoteItem from '../../components/NoteItem';
+import SelectionWrapper from '../../components/SelectionWrapper';
+import { useTracked } from '../../provider';
+import { ACTIONS } from '../../provider/actions';
+
+
+export const NoteItemWrapper = ({item,index,isTrash = false, pinned = false }) => {
+ const [state, dispatch] = useTracked();
+ const {colors,currentEditingNote,selectionMode} = state;
+
+ return <SelectionWrapper
+ index={index}
+ pinned={pinned}
+ currentEditingNote={
+ currentEditingNote === item.id ? currentEditingNote : null
+ }
+ item={item}>
+ <NoteItem
+ colors={colors}
+ pinned={pinned}
+ customStyle={pinned? {
+ width: selectionMode ? '90%' : '100%',
+ marginHorizontal: 0,
+ paddingTop: 10,
+ paddingRight: 6,
+ marginBottom: 5,
+ marginTop: 15,
+ borderBottomWidth: 0,
+ } :{
+ width: selectionMode ? '90%' : '100%',
+ marginHorizontal: 0,
+ }}
+ currentEditingNote={
+ currentEditingNote === item.id ? currentEditingNote : null
+ }
+ selectionMode={selectionMode}
+ onLongPress={() => {
+ if (!selectionMode) {
+ dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
+ }
+ dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
+ }}
+ update={() => {
+ dispatch({type: ACTIONS.NOTES});
+ }}
+ item={item}
+ index={index}
+ isTrash={isTrash}
+ />
+ </SelectionWrapper>
+};