mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
create wrapper for NotebookItem
This commit is contained in:
55
apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
Normal file
55
apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import React from 'react';
|
||||
import { NotebookItem } from '../../components/NotebookItem';
|
||||
import SelectionWrapper from '../../components/SelectionWrapper';
|
||||
import { useTracked } from '../../provider';
|
||||
import { ACTIONS } from '../../provider/actions';
|
||||
|
||||
export const NotebookItemWrapper = ({item, index,isTrash = false, pinned = false}) => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const {selectionMode,preventDefaultMargins} = state;
|
||||
let headerState = preventDefaultMargins? state.indHeaderState : state.headerState;
|
||||
let params = headerState.route.params? headerState.route.params : {};
|
||||
|
||||
|
||||
return (
|
||||
<SelectionWrapper pinned={pinned} index={index} item={item}>
|
||||
<NotebookItem
|
||||
hideMore={preventDefaultMargins}
|
||||
navigation={headerState.navigation}
|
||||
route={headerState.route}
|
||||
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,
|
||||
}}
|
||||
isMove={preventDefaultMargins}
|
||||
selectionMode={selectionMode}
|
||||
onLongPress={() => {
|
||||
if (!selectionMode) {
|
||||
dispatch({
|
||||
type: ACTIONS.SELECTION_MODE,
|
||||
enabled: !selectionMode,
|
||||
});
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.SELECTED_ITEMS,
|
||||
item: item,
|
||||
});
|
||||
}}
|
||||
noteToMove={params.note}
|
||||
item={item}
|
||||
index={index}
|
||||
isTrash={isTrash}
|
||||
/>
|
||||
</SelectionWrapper>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user