2021-01-02 15:23:38 +05:00
|
|
|
import React, { createRef, useEffect, useState } from 'react';
|
|
|
|
|
import { Keyboard, TextInput, TouchableOpacity, View } from 'react-native';
|
|
|
|
|
import { FlatList } from 'react-native-gesture-handler';
|
2020-09-14 16:45:41 +05:00
|
|
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
2021-01-02 15:23:38 +05:00
|
|
|
import { notesnook } from '../../../e2e/test.ids';
|
|
|
|
|
import { useTracked } from '../../provider';
|
|
|
|
|
import { Actions } from '../../provider/Actions';
|
2020-11-20 01:23:05 +05:00
|
|
|
import {
|
2020-12-14 15:57:50 +05:00
|
|
|
eSendEvent,
|
2020-11-20 01:23:05 +05:00
|
|
|
eSubscribeEvent,
|
|
|
|
|
eUnSubscribeEvent,
|
2020-12-29 17:19:32 +05:00
|
|
|
sendNoteEditedEvent,
|
2021-01-02 15:23:38 +05:00
|
|
|
ToastEvent
|
2020-11-20 01:23:05 +05:00
|
|
|
} from '../../services/EventManager';
|
2021-01-02 15:23:38 +05:00
|
|
|
import { db } from '../../utils/DB';
|
2020-12-14 15:57:50 +05:00
|
|
|
import {
|
|
|
|
|
eOnNewTopicAdded,
|
|
|
|
|
eOpenMoveNoteDialog,
|
2021-01-02 15:23:38 +05:00
|
|
|
refreshNotesPage
|
2020-12-14 15:57:50 +05:00
|
|
|
} from '../../utils/Events';
|
2021-01-02 15:23:38 +05:00
|
|
|
import { pv, SIZE } from '../../utils/SizeUtils';
|
2020-12-19 13:15:34 +05:00
|
|
|
import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';
|
2020-11-23 15:57:31 +05:00
|
|
|
import DialogHeader from '../Dialog/dialog-header';
|
2021-01-02 15:23:38 +05:00
|
|
|
import { PressableButton } from '../PressableButton';
|
|
|
|
|
import { Toast } from '../Toast';
|
2020-11-20 01:23:05 +05:00
|
|
|
import Heading from '../Typography/Heading';
|
|
|
|
|
import Paragraph from '../Typography/Paragraph';
|
2020-09-14 22:59:35 +05:00
|
|
|
|
|
|
|
|
let newNotebookTitle = null;
|
|
|
|
|
let newTopicTitle = null;
|
|
|
|
|
const notebookInput = createRef();
|
|
|
|
|
const topicInput = createRef();
|
2020-12-16 11:02:40 +05:00
|
|
|
const actionSheetRef = createRef();
|
2020-09-14 16:45:41 +05:00
|
|
|
const MoveNoteDialog = () => {
|
2020-12-19 13:15:34 +05:00
|
|
|
const [, dispatch] = useTracked();
|
2020-09-14 17:10:02 +05:00
|
|
|
const [visible, setVisible] = useState(false);
|
2020-12-14 15:57:50 +05:00
|
|
|
const [note, setNote] = useState(null);
|
2020-12-16 09:31:20 +05:00
|
|
|
function open(note) {
|
|
|
|
|
setNote(note);
|
2020-09-14 16:45:41 +05:00
|
|
|
setVisible(true);
|
2020-12-29 11:24:34 +05:00
|
|
|
actionSheetRef.current?.setModalVisible(true);
|
2020-09-14 16:45:41 +05:00
|
|
|
}
|
|
|
|
|
const close = () => {
|
2020-12-29 11:24:34 +05:00
|
|
|
actionSheetRef.current?.setModalVisible(false);
|
2020-12-16 09:31:20 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
eSubscribeEvent(eOpenMoveNoteDialog, open);
|
|
|
|
|
return () => {
|
|
|
|
|
eUnSubscribeEvent(eOpenMoveNoteDialog, open);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const _onClose = () => {
|
2020-09-14 16:45:41 +05:00
|
|
|
setVisible(false);
|
2020-09-14 22:59:35 +05:00
|
|
|
newTopicTitle = null;
|
|
|
|
|
newNotebookTitle = null;
|
2020-12-14 15:57:50 +05:00
|
|
|
setNote(null);
|
|
|
|
|
eSendEvent(refreshNotesPage);
|
|
|
|
|
eSendEvent(eOnNewTopicAdded);
|
|
|
|
|
dispatch({type: Actions.CLEAR_SELECTION});
|
|
|
|
|
dispatch({type: Actions.NOTEBOOKS});
|
|
|
|
|
dispatch({type: Actions.NOTES});
|
2020-09-14 16:45:41 +05:00
|
|
|
};
|
2020-01-18 18:13:34 +05:00
|
|
|
|
2020-12-16 11:02:40 +05:00
|
|
|
const update = (note) => {
|
|
|
|
|
console.log(note.notebooks.length);
|
|
|
|
|
setNote(note);
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-16 09:31:20 +05:00
|
|
|
return !visible ? null : (
|
2020-12-19 13:15:34 +05:00
|
|
|
<ActionSheetWrapper fwdRef={actionSheetRef} onClose={_onClose}>
|
|
|
|
|
<MoveNoteComponent close={close} note={note} setNote={update} />
|
|
|
|
|
</ActionSheetWrapper>
|
2020-12-16 09:31:20 +05:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default MoveNoteDialog;
|
|
|
|
|
|
2020-12-19 13:15:34 +05:00
|
|
|
const MoveNoteComponent = ({close, note, setNote}) => {
|
2020-12-16 09:31:20 +05:00
|
|
|
const [state, dispatch] = useTracked();
|
|
|
|
|
const {colors, selectedItemsList} = state;
|
|
|
|
|
const [expanded, setExpanded] = useState('');
|
|
|
|
|
const [notebookInputFocused, setNotebookInputFocused] = useState(false);
|
|
|
|
|
const [topicInputFocused, setTopicInputFocused] = useState(false);
|
2020-01-18 18:13:34 +05:00
|
|
|
|
2020-09-14 16:45:41 +05:00
|
|
|
const addNewNotebook = async () => {
|
|
|
|
|
if (!newNotebookTitle || newNotebookTitle.trim().length === 0)
|
|
|
|
|
return ToastEvent.show('Title is required', 'error', 'local');
|
2020-01-18 18:13:34 +05:00
|
|
|
|
2020-09-14 16:45:41 +05:00
|
|
|
await db.notebooks.add({
|
|
|
|
|
title: newNotebookTitle,
|
2020-12-16 09:31:20 +05:00
|
|
|
description: null,
|
2020-09-14 16:45:41 +05:00
|
|
|
topics: [],
|
|
|
|
|
id: null,
|
2020-01-18 18:13:34 +05:00
|
|
|
});
|
2020-09-14 22:59:35 +05:00
|
|
|
notebookInput.current?.clear();
|
|
|
|
|
notebookInput.current?.blur();
|
2020-10-13 17:02:14 +05:00
|
|
|
dispatch({type: Actions.NOTEBOOKS});
|
2020-09-14 16:45:41 +05:00
|
|
|
};
|
2020-01-18 18:13:34 +05:00
|
|
|
|
2020-09-14 16:45:41 +05:00
|
|
|
const addNewTopic = async () => {
|
2020-09-14 22:59:35 +05:00
|
|
|
if (!newTopicTitle || newTopicTitle.trim().length === 0) {
|
2020-09-14 16:45:41 +05:00
|
|
|
return ToastEvent.show('Title is required', 'error', 'local');
|
2020-09-14 22:59:35 +05:00
|
|
|
}
|
2020-12-16 09:31:20 +05:00
|
|
|
await db.notebooks.notebook(expanded).topics.add(newTopicTitle);
|
2020-10-13 17:02:14 +05:00
|
|
|
dispatch({type: Actions.NOTEBOOKS});
|
2020-09-14 22:59:35 +05:00
|
|
|
topicInput.current?.clear();
|
|
|
|
|
topicInput.current?.blur();
|
|
|
|
|
newTopicTitle = null;
|
2020-09-14 16:45:41 +05:00
|
|
|
};
|
|
|
|
|
|
2020-12-19 13:15:34 +05:00
|
|
|
const handlePress = async (item, index) => {
|
2020-12-16 11:08:58 +05:00
|
|
|
if (
|
|
|
|
|
note?.notebooks?.findIndex(
|
|
|
|
|
(o) =>
|
|
|
|
|
o.topics.findIndex((i) => {
|
|
|
|
|
return i === item.id;
|
|
|
|
|
}) > -1,
|
|
|
|
|
) > -1
|
|
|
|
|
) {
|
|
|
|
|
await db.notebooks
|
|
|
|
|
.notebook(item.notebookId)
|
|
|
|
|
.topics.topic(item.id)
|
|
|
|
|
.delete(note.id);
|
|
|
|
|
|
|
|
|
|
if (note && note.id) {
|
|
|
|
|
setNote({...db.notes.note(note.id).data});
|
2021-01-01 18:55:26 +05:00
|
|
|
sendNoteEditedEvent({
|
|
|
|
|
id: note.id,
|
|
|
|
|
forced: true,
|
|
|
|
|
});
|
2020-12-16 11:08:58 +05:00
|
|
|
}
|
|
|
|
|
dispatch({type: Actions.NOTEBOOKS});
|
2020-12-29 17:19:32 +05:00
|
|
|
|
2020-12-16 11:08:58 +05:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let noteIds = [];
|
|
|
|
|
selectedItemsList.forEach((i) => noteIds.push(i.id));
|
|
|
|
|
console.log(noteIds, 'NOTE IDS');
|
|
|
|
|
await db.notes.move(
|
|
|
|
|
{
|
|
|
|
|
topic: item.id,
|
|
|
|
|
id: item.notebookId,
|
|
|
|
|
},
|
|
|
|
|
...noteIds,
|
|
|
|
|
);
|
|
|
|
|
if (note && note.id) {
|
|
|
|
|
setNote({...db.notes.note(note.id).data});
|
2020-12-29 17:19:32 +05:00
|
|
|
|
2021-01-01 18:55:26 +05:00
|
|
|
sendNoteEditedEvent({
|
|
|
|
|
id: note.id,
|
|
|
|
|
forced: true,
|
|
|
|
|
});
|
2020-12-16 11:08:58 +05:00
|
|
|
}
|
|
|
|
|
dispatch({type: Actions.NOTEBOOKS});
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-16 09:31:20 +05:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<View>
|
|
|
|
|
<TouchableOpacity
|
2020-01-18 18:13:34 +05:00
|
|
|
style={{
|
2020-01-23 23:19:06 +05:00
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
2020-12-16 09:31:20 +05:00
|
|
|
position: 'absolute',
|
|
|
|
|
}}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
2020-09-14 16:45:41 +05:00
|
|
|
}}>
|
2020-12-16 09:31:20 +05:00
|
|
|
<DialogHeader
|
|
|
|
|
title="Add to notebook"
|
|
|
|
|
paragraph={`Add your notes in notebooks to find them easily.`}
|
2020-11-23 15:57:31 +05:00
|
|
|
/>
|
2020-12-16 09:31:20 +05:00
|
|
|
</View>
|
2020-11-23 15:57:31 +05:00
|
|
|
|
2020-12-29 11:24:34 +05:00
|
|
|
<FlatList
|
|
|
|
|
nestedScrollEnabled={true}
|
2020-12-16 11:02:40 +05:00
|
|
|
onScrollEndDrag={() => {
|
2020-12-29 17:19:32 +05:00
|
|
|
actionSheetRef.current?.handleChildScrollEnd();
|
2020-12-16 11:02:40 +05:00
|
|
|
}}
|
|
|
|
|
onMomentumScrollEnd={() => {
|
2020-12-29 17:19:32 +05:00
|
|
|
actionSheetRef.current?.handleChildScrollEnd();
|
2020-12-16 11:02:40 +05:00
|
|
|
}}
|
|
|
|
|
onScrollAnimationEnd={() => {
|
2020-12-29 17:19:32 +05:00
|
|
|
actionSheetRef.current?.handleChildScrollEnd();
|
2020-12-16 11:02:40 +05:00
|
|
|
}}
|
2020-12-29 11:24:34 +05:00
|
|
|
keyboardShouldPersistTaps="always"
|
|
|
|
|
keyboardDismissMode="none"
|
|
|
|
|
data={state.notebooks}
|
|
|
|
|
ListFooterComponent={
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
height: 100,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
ListHeaderComponent={
|
2020-11-23 15:57:31 +05:00
|
|
|
<View
|
2020-09-14 16:45:41 +05:00
|
|
|
style={{
|
2020-12-16 09:31:20 +05:00
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
marginBottom: 10,
|
|
|
|
|
width: '100%',
|
|
|
|
|
borderBottomWidth: 1,
|
|
|
|
|
borderColor: colors.nav,
|
2020-11-23 15:57:31 +05:00
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
}}>
|
2020-12-16 09:31:20 +05:00
|
|
|
<TextInput
|
|
|
|
|
ref={notebookInput}
|
|
|
|
|
onChangeText={(value) => {
|
|
|
|
|
newNotebookTitle = value;
|
|
|
|
|
}}
|
|
|
|
|
testID={notesnook.ids.dialogs.addTo.addNotebook}
|
|
|
|
|
blurOnSubmit={false}
|
|
|
|
|
onFocus={() => {
|
|
|
|
|
setNotebookInputFocused(true);
|
|
|
|
|
}}
|
|
|
|
|
onBlur={() => {
|
|
|
|
|
setNotebookInputFocused(false);
|
|
|
|
|
}}
|
|
|
|
|
onSubmitEditing={addNewNotebook}
|
|
|
|
|
style={[
|
|
|
|
|
{
|
|
|
|
|
color: colors.pri,
|
|
|
|
|
width: '90%',
|
|
|
|
|
maxWidth: '90%',
|
|
|
|
|
paddingHorizontal: 0,
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
minHeight: 45,
|
|
|
|
|
fontSize: SIZE.md,
|
2021-01-03 10:38:07 +05:00
|
|
|
//fontFamily: "sans-serif",
|
2020-12-16 09:31:20 +05:00
|
|
|
padding: pv - 2,
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
placeholder="Create a new notebook"
|
|
|
|
|
placeholderTextColor={colors.icon}
|
2020-11-23 15:57:31 +05:00
|
|
|
/>
|
2020-12-16 09:31:20 +05:00
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={addNewNotebook}
|
|
|
|
|
testID={notesnook.ids.dialogs.addTo.addNotebook}
|
|
|
|
|
style={[
|
|
|
|
|
{
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
minHeight: 45,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
},
|
|
|
|
|
]}>
|
|
|
|
|
<Icon
|
|
|
|
|
name="plus"
|
|
|
|
|
size={SIZE.lg}
|
|
|
|
|
color={notebookInputFocused ? colors.accent : colors.icon}
|
|
|
|
|
/>
|
|
|
|
|
</TouchableOpacity>
|
2020-11-23 15:57:31 +05:00
|
|
|
</View>
|
2020-12-29 11:24:34 +05:00
|
|
|
}
|
|
|
|
|
renderItem={({item, index}) => (
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
height: expanded === item.id ? null : 60,
|
|
|
|
|
}}>
|
2020-12-16 09:31:20 +05:00
|
|
|
<PressableButton
|
|
|
|
|
onPress={() => {
|
|
|
|
|
setExpanded(item.id === expanded ? null : item.id);
|
|
|
|
|
setTopicInputFocused(false);
|
|
|
|
|
setNotebookInputFocused(false);
|
|
|
|
|
}}
|
|
|
|
|
type="gray"
|
|
|
|
|
customStyle={{
|
|
|
|
|
height: 50,
|
|
|
|
|
width: '100%',
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
alignItems: 'flex-start',
|
|
|
|
|
marginBottom: 5,
|
|
|
|
|
borderBottomWidth: 1,
|
|
|
|
|
borderBottomColor:
|
|
|
|
|
expanded === item.id ? colors.accent : colors.nav,
|
|
|
|
|
}}>
|
2020-09-14 16:45:41 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2020-12-16 09:31:20 +05:00
|
|
|
width: '100%',
|
|
|
|
|
height: 50,
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
alignItems: 'center',
|
2020-09-14 16:45:41 +05:00
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
}}>
|
2020-12-16 09:31:20 +05:00
|
|
|
<View>
|
|
|
|
|
<Heading
|
|
|
|
|
color={expanded === item.id ? colors.accent : null}
|
|
|
|
|
size={SIZE.md}>
|
|
|
|
|
{item.title}
|
|
|
|
|
</Heading>
|
|
|
|
|
<Paragraph size={SIZE.xs} color={colors.icon}>
|
|
|
|
|
Notebook{' '}
|
|
|
|
|
{item.totalNotes +
|
|
|
|
|
' notes' +
|
|
|
|
|
' & ' +
|
|
|
|
|
item.topics.length +
|
|
|
|
|
' topics'}
|
|
|
|
|
</Paragraph>
|
2020-09-14 16:45:41 +05:00
|
|
|
</View>
|
2020-12-16 09:31:20 +05:00
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
|
name={expanded === item.id ? 'chevron-up' : 'chevron-down'}
|
|
|
|
|
color={colors.pri}
|
|
|
|
|
size={SIZE.lg}
|
|
|
|
|
/>
|
2020-11-23 15:57:31 +05:00
|
|
|
</View>
|
2020-12-16 09:31:20 +05:00
|
|
|
</PressableButton>
|
2020-09-14 16:45:41 +05:00
|
|
|
|
2020-12-16 09:31:20 +05:00
|
|
|
{expanded === item.id ? (
|
|
|
|
|
<FlatList
|
2020-12-29 11:24:34 +05:00
|
|
|
nestedScrollEnabled
|
2020-12-16 09:31:20 +05:00
|
|
|
data={item.topics}
|
|
|
|
|
keyboardShouldPersistTaps="always"
|
|
|
|
|
keyboardDismissMode="none"
|
2020-12-29 11:24:34 +05:00
|
|
|
onScrollEndDrag={() => {
|
2020-12-29 17:19:32 +05:00
|
|
|
actionSheetRef.current?.handleChildScrollEnd();
|
2020-12-29 11:24:34 +05:00
|
|
|
}}
|
|
|
|
|
onMomentumScrollEnd={() => {
|
2020-12-29 17:19:32 +05:00
|
|
|
actionSheetRef.current?.handleChildScrollEnd();
|
2020-12-29 11:24:34 +05:00
|
|
|
}}
|
|
|
|
|
onScrollAnimationEnd={() => {
|
2020-12-29 17:19:32 +05:00
|
|
|
actionSheetRef.current?.handleChildScrollEnd();
|
2020-12-29 11:24:34 +05:00
|
|
|
}}
|
2020-12-20 18:24:33 +05:00
|
|
|
style={{
|
2020-12-29 11:24:34 +05:00
|
|
|
width: '90%',
|
|
|
|
|
alignSelf: 'flex-end',
|
|
|
|
|
maxHeight: 500,
|
2020-12-20 18:24:33 +05:00
|
|
|
}}
|
2020-12-16 09:31:20 +05:00
|
|
|
ListHeaderComponent={
|
|
|
|
|
<View>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
width: '100%',
|
|
|
|
|
alignSelf: 'flex-end',
|
|
|
|
|
marginBottom: 5,
|
|
|
|
|
marginTop: 5,
|
|
|
|
|
borderBottomWidth: 1,
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
borderColor: colors.nav,
|
|
|
|
|
}}>
|
|
|
|
|
<TextInput
|
|
|
|
|
ref={topicInput}
|
|
|
|
|
onChangeText={(value) => {
|
|
|
|
|
newTopicTitle = value;
|
|
|
|
|
}}
|
|
|
|
|
testID={notesnook.ids.dialogs.addTo.addTopic}
|
|
|
|
|
blurOnSubmit={false}
|
|
|
|
|
onFocus={() => {
|
|
|
|
|
setTopicInputFocused(true);
|
|
|
|
|
}}
|
|
|
|
|
onBlur={() => {
|
|
|
|
|
setTopicInputFocused(false);
|
|
|
|
|
}}
|
|
|
|
|
onSubmitEditing={addNewTopic}
|
|
|
|
|
style={[
|
|
|
|
|
{
|
|
|
|
|
color: colors.pri,
|
2020-11-23 15:57:31 +05:00
|
|
|
width: '90%',
|
2020-12-16 09:31:20 +05:00
|
|
|
maxWidth: '90%',
|
|
|
|
|
paddingHorizontal: 0,
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
height: 40,
|
|
|
|
|
fontSize: SIZE.sm,
|
2021-01-03 10:38:07 +05:00
|
|
|
//fontFamily: "sans-serif",
|
2020-12-16 09:31:20 +05:00
|
|
|
padding: pv - 2,
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
placeholder="Add a topic"
|
|
|
|
|
placeholderTextColor={colors.icon}
|
|
|
|
|
/>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={addNewTopic}
|
|
|
|
|
testID={notesnook.ids.dialogs.addTo.btnTopic}
|
|
|
|
|
style={[
|
|
|
|
|
{
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
height: 40,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
},
|
|
|
|
|
]}>
|
|
|
|
|
<Icon
|
|
|
|
|
name="plus"
|
|
|
|
|
size={SIZE.lg}
|
|
|
|
|
color={
|
|
|
|
|
topicInputFocused ? colors.accent : colors.icon
|
2020-12-14 15:57:50 +05:00
|
|
|
}
|
2020-12-16 09:31:20 +05:00
|
|
|
/>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
}
|
|
|
|
|
renderItem={({item, index}) => (
|
|
|
|
|
<PressableButton
|
2020-12-19 13:15:34 +05:00
|
|
|
onPress={() => handlePress(item, index)}
|
2020-12-16 09:31:20 +05:00
|
|
|
type="gray"
|
|
|
|
|
customStyle={{
|
|
|
|
|
height: 50,
|
|
|
|
|
borderTopWidth: index === 0 ? 0 : 1,
|
|
|
|
|
borderTopColor: colors.nav,
|
|
|
|
|
width: '100%',
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
}}>
|
|
|
|
|
<View>
|
|
|
|
|
<Paragraph color={colors.heading}>
|
|
|
|
|
{item.title}
|
|
|
|
|
{'\n'}
|
|
|
|
|
<Paragraph color={colors.icon} size={SIZE.xs}>
|
|
|
|
|
{item.totalNotes + ' notes'}
|
|
|
|
|
</Paragraph>
|
|
|
|
|
</Paragraph>
|
|
|
|
|
</View>
|
|
|
|
|
{note?.notebooks?.findIndex(
|
|
|
|
|
(o) => o.topics.indexOf(item.id) > -1,
|
|
|
|
|
) > -1 ? (
|
|
|
|
|
<Paragraph size={SIZE.sm} color={colors.errorText}>
|
|
|
|
|
Remove Note
|
|
|
|
|
</Paragraph>
|
|
|
|
|
) : null}
|
|
|
|
|
</PressableButton>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
2020-12-01 11:19:29 +05:00
|
|
|
</View>
|
2020-12-29 11:24:34 +05:00
|
|
|
)}
|
|
|
|
|
/>
|
2020-12-16 09:31:20 +05:00
|
|
|
</View>
|
|
|
|
|
<Toast context="local" />
|
|
|
|
|
</>
|
2020-09-14 16:45:41 +05:00
|
|
|
);
|
|
|
|
|
};
|