2021-02-09 16:41:34 +05:00
|
|
|
import React, {createRef} from 'react';
|
2021-08-03 09:17:52 +05:00
|
|
|
import {Keyboard, StyleSheet, TouchableOpacity, View,TextInput} from 'react-native';
|
|
|
|
|
import {FlatList, ScrollView, } from 'react-native-gesture-handler';
|
2021-02-09 16:41:34 +05:00
|
|
|
import {notesnook} from '../../../e2e/test.ids';
|
2021-06-07 11:53:27 +05:00
|
|
|
import {useMenuStore} from '../../provider/stores';
|
2021-02-09 16:41:34 +05:00
|
|
|
import {DDS} from '../../services/DeviceDetection';
|
|
|
|
|
import {ToastEvent} from '../../services/EventManager';
|
2021-02-20 14:50:27 +05:00
|
|
|
import Navigation from '../../services/Navigation';
|
2021-10-02 10:26:29 +05:00
|
|
|
import {db} from '../../utils/database';
|
2021-02-09 16:41:34 +05:00
|
|
|
import {ph, pv, SIZE} from '../../utils/SizeUtils';
|
2021-02-20 14:50:27 +05:00
|
|
|
import {sleep} from '../../utils/TimeUtils';
|
2021-02-09 16:41:34 +05:00
|
|
|
import {ActionIcon} from '../ActionIcon';
|
2021-12-26 19:51:24 +05:00
|
|
|
import SheetWrapper from '../Sheet';
|
2021-07-20 14:27:18 +05:00
|
|
|
import {Button} from '../Button';
|
2020-11-14 15:46:26 +05:00
|
|
|
import DialogHeader from '../Dialog/dialog-header';
|
2020-12-17 15:42:55 +05:00
|
|
|
import Input from '../Input';
|
2021-07-20 14:27:18 +05:00
|
|
|
import Seperator from '../Seperator';
|
2021-02-09 16:41:34 +05:00
|
|
|
import {Toast} from '../Toast';
|
2019-12-03 18:12:50 +05:00
|
|
|
|
2019-12-06 11:09:45 +05:00
|
|
|
let refs = [];
|
2019-12-03 18:12:50 +05:00
|
|
|
|
2020-01-18 18:14:08 +05:00
|
|
|
export class AddNotebookDialog extends React.Component {
|
2020-11-02 09:22:26 +05:00
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
visible: false,
|
|
|
|
|
topics: [],
|
|
|
|
|
description: null,
|
|
|
|
|
titleFocused: false,
|
|
|
|
|
descFocused: false,
|
|
|
|
|
count: 0,
|
|
|
|
|
topicInputFocused: false,
|
|
|
|
|
editTopic: false,
|
2021-07-20 14:27:18 +05:00
|
|
|
loading: false
|
2020-10-18 15:14:46 +05:00
|
|
|
};
|
2020-11-02 09:22:26 +05:00
|
|
|
this.title = null;
|
|
|
|
|
this.description = null;
|
|
|
|
|
this.listRef;
|
|
|
|
|
this.prevItem = null;
|
|
|
|
|
this.prevIndex = null;
|
|
|
|
|
this.currentSelectedInput = null;
|
|
|
|
|
this.id = null;
|
|
|
|
|
this.backPressCount = 0;
|
|
|
|
|
this.currentInputValue = null;
|
|
|
|
|
this.titleRef;
|
|
|
|
|
this.descriptionRef;
|
|
|
|
|
this.topicsToDelete = [];
|
2020-12-31 18:53:05 +05:00
|
|
|
this.hiddenInput = createRef();
|
|
|
|
|
this.topicInputRef = createRef();
|
|
|
|
|
this.addingTopic = false;
|
2021-07-20 14:27:18 +05:00
|
|
|
this.actionSheetRef = createRef();
|
2020-11-02 09:22:26 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
open = () => {
|
2021-07-28 11:39:32 +05:00
|
|
|
console.log('opening called');
|
2020-11-02 09:22:26 +05:00
|
|
|
refs = [];
|
|
|
|
|
let {toEdit} = this.props;
|
|
|
|
|
if (toEdit && toEdit.type === 'notebook') {
|
|
|
|
|
let topicsList = [];
|
|
|
|
|
toEdit.topics.forEach((item, index) => {
|
|
|
|
|
topicsList.push(item.title);
|
|
|
|
|
});
|
|
|
|
|
this.id = toEdit.id;
|
|
|
|
|
this.title = toEdit.title;
|
|
|
|
|
this.description = toEdit.description;
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
topics: [...topicsList],
|
2021-07-20 14:27:18 +05:00
|
|
|
visible: true
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
visible: true
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
}
|
2021-07-20 14:27:18 +05:00
|
|
|
sleep(100).then(r => {
|
|
|
|
|
this.actionSheetRef.current?.show();
|
|
|
|
|
});
|
2020-11-02 09:22:26 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
close = () => {
|
2021-07-20 14:27:18 +05:00
|
|
|
this.actionSheetRef.current?.hide();
|
2020-11-02 09:22:26 +05:00
|
|
|
refs = [];
|
|
|
|
|
this.prevIndex = null;
|
|
|
|
|
this.prevItem = null;
|
|
|
|
|
this.currentSelectedInput = null;
|
|
|
|
|
this.title = null;
|
|
|
|
|
this.description = null;
|
2020-12-28 16:17:39 +05:00
|
|
|
this.currentInputValue = null;
|
2020-11-02 09:22:26 +05:00
|
|
|
this.id = null;
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-21 12:30:58 +05:00
|
|
|
onDelete = index => {
|
2020-11-02 09:22:26 +05:00
|
|
|
let {topics} = this.state;
|
|
|
|
|
let prevTopics = topics;
|
|
|
|
|
refs = [];
|
|
|
|
|
prevTopics.splice(index, 1);
|
|
|
|
|
let edit = this.props.toEdit;
|
|
|
|
|
if (edit && edit.id) {
|
2021-04-28 12:56:48 +05:00
|
|
|
let topicToDelete = edit.topics[index];
|
2020-11-23 15:57:31 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
if (topicToDelete) {
|
|
|
|
|
this.topicsToDelete.push(topicToDelete.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let nextTopics = [...prevTopics];
|
|
|
|
|
if (this.prevIndex === index) {
|
|
|
|
|
this.prevIndex = null;
|
|
|
|
|
this.prevItem = null;
|
|
|
|
|
this.currentInputValue = null;
|
2020-12-31 18:53:05 +05:00
|
|
|
this.topicInputRef.current?.setNativeProps({
|
2021-07-20 14:27:18 +05:00
|
|
|
text: null
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
topics: nextTopics
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
};
|
2020-05-13 01:46:02 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
addNewNotebook = async () => {
|
2021-02-09 16:41:34 +05:00
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
loading: true
|
2021-02-09 16:41:34 +05:00
|
|
|
});
|
2020-11-02 09:22:26 +05:00
|
|
|
let {topics} = this.state;
|
|
|
|
|
let edit = this.props.toEdit;
|
2020-05-12 14:27:22 +05:00
|
|
|
|
2021-02-20 14:50:27 +05:00
|
|
|
if (!this.title || this.title?.trim().length === 0) {
|
|
|
|
|
ToastEvent.show({
|
|
|
|
|
heading: 'Notebook title is required',
|
|
|
|
|
type: 'error',
|
2021-07-20 14:27:18 +05:00
|
|
|
context: 'local'
|
2021-02-20 14:50:27 +05:00
|
|
|
});
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
loading: false
|
2021-02-20 14:50:27 +05:00
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-09-14 22:59:19 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
let id = edit && edit.id ? edit.id : null;
|
2020-10-18 15:14:46 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
let toEdit;
|
|
|
|
|
if (id) {
|
|
|
|
|
toEdit = db.notebooks.notebook(edit.id).data;
|
|
|
|
|
}
|
2020-10-18 15:14:46 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
let prevTopics = [...topics];
|
2020-10-18 15:14:46 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
if (this.currentInputValue && this.currentInputValue.trim().length !== 0) {
|
|
|
|
|
if (this.prevItem != null) {
|
|
|
|
|
prevTopics[this.prevIndex] = this.currentInputValue;
|
|
|
|
|
} else {
|
|
|
|
|
prevTopics.push(this.currentInputValue);
|
|
|
|
|
this.currentInputValue = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (id) {
|
|
|
|
|
if (this.topicsToDelete?.length > 0) {
|
|
|
|
|
await db.notebooks
|
|
|
|
|
.notebook(toEdit.id)
|
|
|
|
|
.topics.delete(...this.topicsToDelete);
|
|
|
|
|
toEdit = db.notebooks.notebook(toEdit.id).data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await db.notebooks.add({
|
|
|
|
|
title: this.title,
|
|
|
|
|
description: this.description,
|
2021-07-20 14:27:18 +05:00
|
|
|
id: id
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let nextTopics = toEdit.topics.map((topic, index) => {
|
2021-04-28 12:56:48 +05:00
|
|
|
//if (index === 0) return topic;
|
2020-11-02 09:22:26 +05:00
|
|
|
let copy = {...topic};
|
2021-04-28 12:56:48 +05:00
|
|
|
copy.title = prevTopics[index];
|
2020-11-02 09:22:26 +05:00
|
|
|
return copy;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
prevTopics.forEach((title, index) => {
|
2021-04-28 12:56:48 +05:00
|
|
|
if (!nextTopics[index]) {
|
2020-11-02 09:22:26 +05:00
|
|
|
nextTopics.push(title);
|
2020-05-12 14:09:56 +05:00
|
|
|
}
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await db.notebooks.notebook(id).topics.add(...nextTopics);
|
|
|
|
|
} else {
|
|
|
|
|
await db.notebooks.add({
|
|
|
|
|
title: this.title,
|
|
|
|
|
description: this.description,
|
|
|
|
|
topics: prevTopics,
|
2021-07-20 14:27:18 +05:00
|
|
|
id: id
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
}
|
2021-06-05 21:10:20 +05:00
|
|
|
useMenuStore.getState().setMenuPins();
|
2021-02-20 14:50:27 +05:00
|
|
|
Navigation.setRoutesToUpdate([
|
|
|
|
|
Navigation.routeNames.Notebooks,
|
|
|
|
|
Navigation.routeNames.Notebook,
|
2021-07-20 14:27:18 +05:00
|
|
|
Navigation.routeNames.NotesPage
|
2021-02-20 14:50:27 +05:00
|
|
|
]);
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
loading: false
|
2021-02-20 14:50:27 +05:00
|
|
|
});
|
2020-11-02 09:22:26 +05:00
|
|
|
this.close();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onSubmit = (forward = true) => {
|
2020-12-31 18:53:05 +05:00
|
|
|
this.hiddenInput.current?.focus();
|
2021-04-28 12:56:48 +05:00
|
|
|
let willFocus = true;
|
2020-11-02 09:22:26 +05:00
|
|
|
let {topics} = this.state;
|
|
|
|
|
if (!this.currentInputValue || this.currentInputValue?.trim().length === 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
let prevTopics = [...topics];
|
|
|
|
|
if (this.prevItem === null) {
|
|
|
|
|
prevTopics.push(this.currentInputValue);
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
topics: prevTopics
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.listRef.scrollToEnd({animated: true});
|
|
|
|
|
}, 30);
|
|
|
|
|
this.currentInputValue = null;
|
|
|
|
|
} else {
|
|
|
|
|
prevTopics[this.prevIndex] = this.currentInputValue;
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
topics: prevTopics
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
|
|
|
|
this.currentInputValue = null;
|
2021-04-28 12:56:48 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
if (this.state.editTopic) {
|
2020-12-31 18:53:05 +05:00
|
|
|
this.topicInputRef.current?.blur();
|
2020-11-02 09:22:26 +05:00
|
|
|
Keyboard.dismiss();
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
editTopic: false
|
2020-11-02 09:22:26 +05:00
|
|
|
});
|
2021-04-28 12:56:48 +05:00
|
|
|
willFocus = false;
|
2020-11-02 09:22:26 +05:00
|
|
|
}
|
|
|
|
|
this.prevItem = null;
|
|
|
|
|
this.prevIndex = null;
|
|
|
|
|
this.currentInputValue = null;
|
|
|
|
|
|
|
|
|
|
if (forward) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.listRef.scrollToEnd({animated: true});
|
|
|
|
|
}, 30);
|
|
|
|
|
}
|
2020-01-06 19:03:21 +05:00
|
|
|
}
|
2021-01-13 13:23:01 +05:00
|
|
|
this.topicInputRef.current?.setNativeProps({
|
2021-07-20 14:27:18 +05:00
|
|
|
text: ''
|
2021-02-09 16:41:34 +05:00
|
|
|
});
|
2021-04-28 12:56:48 +05:00
|
|
|
willFocus && this.topicInputRef.current?.focus();
|
2020-11-02 09:22:26 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const {colors, toEdit} = this.props;
|
2021-02-20 14:50:27 +05:00
|
|
|
const {topics, visible, topicInputFocused} = this.state;
|
2020-11-23 12:32:33 +05:00
|
|
|
if (!visible) return null;
|
2020-01-18 18:14:08 +05:00
|
|
|
return (
|
2021-12-25 11:16:33 +05:00
|
|
|
<SheetWrapper
|
2021-07-20 14:27:18 +05:00
|
|
|
onOpen={async () => {
|
2020-11-02 09:22:26 +05:00
|
|
|
this.topicsToDelete = [];
|
2021-02-20 14:50:27 +05:00
|
|
|
await sleep(300);
|
2021-04-29 09:03:52 +05:00
|
|
|
this.props.toEdit?.type !== 'notebook' && this.titleRef?.focus();
|
2020-11-02 09:22:26 +05:00
|
|
|
}}
|
2021-07-20 14:27:18 +05:00
|
|
|
fwdRef={this.actionSheetRef}
|
|
|
|
|
onClose={() => {
|
|
|
|
|
this.close();
|
|
|
|
|
this.setState({
|
2021-10-26 11:04:49 +05:00
|
|
|
visible: false,
|
|
|
|
|
topics: [],
|
|
|
|
|
descFocused: false,
|
|
|
|
|
titleFocused: false,
|
|
|
|
|
editTopic: false
|
2021-07-20 14:27:18 +05:00
|
|
|
});
|
|
|
|
|
}}
|
2021-05-06 16:31:39 +05:00
|
|
|
statusBarTranslucent={false}
|
2020-11-02 09:22:26 +05:00
|
|
|
onRequestClose={this.close}>
|
2021-04-21 12:30:58 +05:00
|
|
|
<View
|
2021-07-24 13:15:53 +05:00
|
|
|
style={{
|
|
|
|
|
maxHeight: DDS.isTab ? '90%' : '100%',
|
|
|
|
|
borderRadius: DDS.isTab ? 5 : 0,
|
|
|
|
|
paddingHorizontal: 12
|
|
|
|
|
}}>
|
|
|
|
|
<TextInput
|
|
|
|
|
ref={this.hiddenInput}
|
|
|
|
|
style={{
|
|
|
|
|
width: 1,
|
|
|
|
|
height: 1,
|
|
|
|
|
opacity: 0,
|
|
|
|
|
position: 'absolute'
|
|
|
|
|
}}
|
|
|
|
|
blurOnSubmit={false}
|
|
|
|
|
/>
|
2021-04-21 12:30:58 +05:00
|
|
|
<DialogHeader
|
|
|
|
|
title={
|
|
|
|
|
toEdit && toEdit.dateCreated ? 'Edit Notebook' : 'New Notebook'
|
|
|
|
|
}
|
|
|
|
|
paragraph={
|
|
|
|
|
toEdit && toEdit.dateCreated
|
2021-04-28 12:56:48 +05:00
|
|
|
? 'You are editing ' + this.title + ' notebook.'
|
|
|
|
|
: 'Notebooks are the best way to organize your notes.'
|
2021-04-21 12:30:58 +05:00
|
|
|
}
|
|
|
|
|
/>
|
2021-07-20 14:27:18 +05:00
|
|
|
<Seperator half />
|
2021-04-21 12:30:58 +05:00
|
|
|
|
|
|
|
|
<Input
|
|
|
|
|
fwdRef={ref => (this.titleRef = ref)}
|
|
|
|
|
testID={notesnook.ids.dialogs.notebook.inputs.title}
|
|
|
|
|
onChangeText={value => {
|
|
|
|
|
this.title = value;
|
2020-12-31 18:53:05 +05:00
|
|
|
}}
|
2021-04-21 12:30:58 +05:00
|
|
|
placeholder="Enter a title"
|
|
|
|
|
onSubmit={() => {
|
|
|
|
|
this.descriptionRef.focus();
|
|
|
|
|
}}
|
|
|
|
|
returnKeyLabel="Next"
|
|
|
|
|
returnKeyType="next"
|
|
|
|
|
defaultValue={toEdit ? toEdit.title : null}
|
2020-12-31 18:53:05 +05:00
|
|
|
/>
|
2020-11-02 09:22:26 +05:00
|
|
|
|
2021-04-21 12:30:58 +05:00
|
|
|
<Input
|
|
|
|
|
fwdRef={ref => (this.descriptionRef = ref)}
|
|
|
|
|
testID={notesnook.ids.dialogs.notebook.inputs.description}
|
|
|
|
|
onChangeText={value => {
|
|
|
|
|
this.description = value;
|
|
|
|
|
}}
|
|
|
|
|
placeholder="Describe your notebook."
|
|
|
|
|
onSubmit={() => {
|
|
|
|
|
this.topicInputRef.current?.focus();
|
|
|
|
|
}}
|
|
|
|
|
returnKeyLabel="Next"
|
|
|
|
|
returnKeyType="next"
|
|
|
|
|
defaultValue={toEdit ? toEdit.description : null}
|
|
|
|
|
/>
|
2020-12-17 15:42:55 +05:00
|
|
|
|
2021-04-21 12:30:58 +05:00
|
|
|
<Input
|
|
|
|
|
fwdRef={this.topicInputRef}
|
|
|
|
|
testID={notesnook.ids.dialogs.notebook.inputs.topic}
|
|
|
|
|
onChangeText={value => {
|
|
|
|
|
this.currentInputValue = value;
|
|
|
|
|
if (this.prevItem !== null) {
|
|
|
|
|
refs[this.prevIndex].setNativeProps({
|
|
|
|
|
text: value,
|
|
|
|
|
style: {
|
2021-07-20 14:27:18 +05:00
|
|
|
borderBottomColor: colors.accent
|
|
|
|
|
}
|
2021-04-21 12:30:58 +05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
returnKeyLabel="Done"
|
|
|
|
|
returnKeyType="done"
|
|
|
|
|
onSubmit={() => {
|
|
|
|
|
this.onSubmit();
|
|
|
|
|
}}
|
|
|
|
|
blurOnSubmit={false}
|
|
|
|
|
button={{
|
|
|
|
|
icon: this.state.editTopic ? 'check' : 'plus',
|
|
|
|
|
onPress: this.onSubmit,
|
2021-07-20 14:27:18 +05:00
|
|
|
color: topicInputFocused ? colors.accent : colors.icon
|
2021-04-21 12:30:58 +05:00
|
|
|
}}
|
|
|
|
|
placeholder="Add a topic"
|
|
|
|
|
/>
|
2020-11-02 09:22:26 +05:00
|
|
|
|
2021-04-21 12:30:58 +05:00
|
|
|
<FlatList
|
|
|
|
|
data={topics}
|
|
|
|
|
ref={ref => (this.listRef = ref)}
|
2021-07-28 11:39:32 +05:00
|
|
|
nestedScrollEnabled
|
2021-04-21 12:30:58 +05:00
|
|
|
keyExtractor={(item, index) => item + index.toString()}
|
2021-07-28 11:39:32 +05:00
|
|
|
onMomentumScrollEnd={() => {
|
|
|
|
|
this.actionSheetRef.current?.handleChildScrollEnd();
|
|
|
|
|
}}
|
2021-12-31 09:06:48 +05:00
|
|
|
keyboardShouldPersistTaps="always"
|
|
|
|
|
keyboardDismissMode="none"
|
2021-09-02 12:01:59 +05:00
|
|
|
ListFooterComponent={<View style={{height:50}} />}
|
2021-04-21 12:30:58 +05:00
|
|
|
renderItem={({item, index}) => (
|
|
|
|
|
<TopicItem
|
|
|
|
|
item={item}
|
|
|
|
|
onPress={(item, index) => {
|
|
|
|
|
this.prevIndex = index;
|
|
|
|
|
this.prevItem = item;
|
|
|
|
|
this.topicInputRef.current?.setNativeProps({
|
2021-07-20 14:27:18 +05:00
|
|
|
text: item
|
2021-04-21 12:30:58 +05:00
|
|
|
});
|
|
|
|
|
this.topicInputRef.current?.focus();
|
|
|
|
|
this.currentInputValue = item;
|
|
|
|
|
this.setState({
|
2021-07-20 14:27:18 +05:00
|
|
|
editTopic: true
|
2021-04-21 12:30:58 +05:00
|
|
|
});
|
2020-12-17 15:42:55 +05:00
|
|
|
}}
|
2021-04-21 12:30:58 +05:00
|
|
|
onDelete={this.onDelete}
|
|
|
|
|
index={index}
|
|
|
|
|
colors={colors}
|
2020-12-17 15:42:55 +05:00
|
|
|
/>
|
2021-04-21 12:30:58 +05:00
|
|
|
)}
|
|
|
|
|
/>
|
2021-07-20 14:27:18 +05:00
|
|
|
<Seperator />
|
|
|
|
|
<Button
|
|
|
|
|
width="100%"
|
|
|
|
|
height={50}
|
|
|
|
|
fontSize={SIZE.md}
|
|
|
|
|
title={
|
|
|
|
|
toEdit && toEdit.dateCreated ? 'Save changes' : 'Create notebook'
|
|
|
|
|
}
|
|
|
|
|
type="accent"
|
|
|
|
|
onPress={this.addNewNotebook}
|
2021-04-21 12:30:58 +05:00
|
|
|
/>
|
2021-12-31 09:06:48 +05:00
|
|
|
|
|
|
|
|
{/* <View
|
2021-11-30 13:29:33 +05:00
|
|
|
style={{
|
|
|
|
|
height:35
|
|
|
|
|
}}
|
2021-12-31 09:06:48 +05:00
|
|
|
/> */}
|
2021-04-21 12:30:58 +05:00
|
|
|
</View>
|
2021-12-31 09:06:48 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
|
2021-04-21 12:30:58 +05:00
|
|
|
<Toast context="local" />
|
2021-12-25 11:16:33 +05:00
|
|
|
</SheetWrapper>
|
2020-01-18 18:14:08 +05:00
|
|
|
);
|
2020-11-02 09:22:26 +05:00
|
|
|
}
|
|
|
|
|
}
|
2019-12-03 18:12:50 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
const TopicItem = ({item, index, colors, onPress, onDelete}) => {
|
2021-04-21 12:30:58 +05:00
|
|
|
const topicRef = ref => (refs[index] = ref);
|
2020-09-07 13:12:41 +05:00
|
|
|
|
2020-11-02 09:22:26 +05:00
|
|
|
return (
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
2020-10-18 15:14:46 +05:00
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
2021-07-10 11:49:59 +05:00
|
|
|
backgroundColor: colors.nav,
|
|
|
|
|
borderRadius: 5,
|
2021-07-20 14:27:18 +05:00
|
|
|
marginVertical: 5
|
2020-11-02 09:22:26 +05:00
|
|
|
}}>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
style={{
|
|
|
|
|
width: '80%',
|
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
|
zIndex: 10,
|
|
|
|
|
position: 'absolute',
|
2021-07-20 14:27:18 +05:00
|
|
|
height: 30
|
2020-11-02 09:22:26 +05:00
|
|
|
}}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
onPress(item, index);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<TextInput
|
|
|
|
|
ref={topicRef}
|
|
|
|
|
editable={false}
|
|
|
|
|
style={[
|
|
|
|
|
styles.topicInput,
|
|
|
|
|
{
|
2021-07-20 14:27:18 +05:00
|
|
|
color: colors.pri
|
|
|
|
|
}
|
2020-11-02 09:22:26 +05:00
|
|
|
]}
|
|
|
|
|
defaultValue={item}
|
2021-12-30 10:42:03 +05:00
|
|
|
placeholderTextColor={colors.placeholder}
|
2020-11-02 09:22:26 +05:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<View
|
2020-11-02 20:45:56 +05:00
|
|
|
style={{
|
|
|
|
|
width: 80,
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
right: 0,
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
flexDirection: 'row',
|
2021-07-20 14:27:18 +05:00
|
|
|
justifyContent: 'flex-end'
|
2020-11-02 20:45:56 +05:00
|
|
|
}}>
|
|
|
|
|
<ActionIcon
|
|
|
|
|
onPress={() => {
|
2020-11-02 09:22:26 +05:00
|
|
|
onPress(item, index);
|
|
|
|
|
}}
|
|
|
|
|
name="pencil"
|
|
|
|
|
size={SIZE.lg - 5}
|
|
|
|
|
color={colors.icon}
|
2020-11-02 20:45:56 +05:00
|
|
|
/>
|
2020-11-02 09:22:26 +05:00
|
|
|
<ActionIcon
|
|
|
|
|
onPress={() => {
|
|
|
|
|
onDelete(index);
|
|
|
|
|
}}
|
|
|
|
|
name="minus"
|
|
|
|
|
size={SIZE.lg}
|
|
|
|
|
color={colors.icon}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
wrapper: {
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
backgroundColor: 'rgba(0,0,0,0.3)',
|
|
|
|
|
justifyContent: 'center',
|
2021-07-20 14:27:18 +05:00
|
|
|
alignItems: 'center'
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
overlay: {
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
2021-07-20 14:27:18 +05:00
|
|
|
position: 'absolute'
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
headingContainer: {
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'center',
|
2021-07-20 14:27:18 +05:00
|
|
|
alignItems: 'center'
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
headingText: {
|
|
|
|
|
marginLeft: 5,
|
2021-07-20 14:27:18 +05:00
|
|
|
fontSize: SIZE.xl
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
input: {
|
2020-11-14 15:46:26 +05:00
|
|
|
paddingRight: 12,
|
|
|
|
|
paddingHorizontal: 0,
|
2020-11-02 20:45:56 +05:00
|
|
|
borderRadius: 0,
|
2020-11-02 09:22:26 +05:00
|
|
|
minHeight: 45,
|
2020-11-14 15:46:26 +05:00
|
|
|
fontSize: SIZE.md,
|
2020-11-02 09:22:26 +05:00
|
|
|
padding: pv - 2,
|
2020-11-02 20:45:56 +05:00
|
|
|
borderBottomWidth: 1,
|
2020-11-02 09:22:26 +05:00
|
|
|
marginTop: 10,
|
2021-07-20 14:27:18 +05:00
|
|
|
marginBottom: 5
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
addBtn: {
|
|
|
|
|
width: '12%',
|
|
|
|
|
minHeight: 45,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
2020-11-02 20:45:56 +05:00
|
|
|
position: 'absolute',
|
2021-07-20 14:27:18 +05:00
|
|
|
right: 0
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
buttonContainer: {
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
width: '100%',
|
2021-07-20 14:27:18 +05:00
|
|
|
marginTop: 20
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
topicContainer: {
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
2021-07-20 14:27:18 +05:00
|
|
|
marginTop: 10
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
topicInput: {
|
|
|
|
|
padding: pv - 5,
|
|
|
|
|
fontSize: SIZE.sm,
|
2021-01-03 10:38:07 +05:00
|
|
|
//fontFamily: "sans-serif",
|
2020-11-02 09:22:26 +05:00
|
|
|
paddingHorizontal: ph,
|
|
|
|
|
paddingRight: 40,
|
|
|
|
|
paddingVertical: 10,
|
|
|
|
|
width: '100%',
|
2021-07-20 14:27:18 +05:00
|
|
|
maxWidth: '100%'
|
2020-11-02 09:22:26 +05:00
|
|
|
},
|
|
|
|
|
topicBtn: {
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
width: 40,
|
|
|
|
|
height: 40,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
position: 'absolute',
|
2021-07-20 14:27:18 +05:00
|
|
|
right: 0
|
|
|
|
|
}
|
2020-09-07 13:12:41 +05:00
|
|
|
});
|