mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
fix notebook adding dialog
This commit is contained in:
@@ -89,12 +89,14 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
this.currentSelectedInput = null;
|
this.currentSelectedInput = null;
|
||||||
this.title = null;
|
this.title = null;
|
||||||
this.description = null;
|
this.description = null;
|
||||||
|
this.currentInputValue = null;
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.setState({
|
this.setState({
|
||||||
visible: false,
|
visible: false,
|
||||||
topics: [],
|
topics: [],
|
||||||
descFocused: false,
|
descFocused: false,
|
||||||
titleFocused: false,
|
titleFocused: false,
|
||||||
|
editTopic: false,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -191,6 +193,9 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onSubmit = (forward = true) => {
|
onSubmit = (forward = true) => {
|
||||||
|
this.topicInputRef.setNativeProps({
|
||||||
|
text: null,
|
||||||
|
});
|
||||||
let {topics} = this.state;
|
let {topics} = this.state;
|
||||||
if (!this.currentInputValue || this.currentInputValue?.trim().length === 0)
|
if (!this.currentInputValue || this.currentInputValue?.trim().length === 0)
|
||||||
return;
|
return;
|
||||||
@@ -201,9 +206,6 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
topics: prevTopics,
|
topics: prevTopics,
|
||||||
});
|
});
|
||||||
this.topicInputRef.setNativeProps({
|
|
||||||
text: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.listRef.scrollToEnd({animated: true});
|
this.listRef.scrollToEnd({animated: true});
|
||||||
@@ -215,6 +217,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
topics: prevTopics,
|
topics: prevTopics,
|
||||||
});
|
});
|
||||||
this.currentInputValue = null;
|
this.currentInputValue = null;
|
||||||
|
console.log('edit topic is', this.state.editTopic);
|
||||||
if (this.state.editTopic) {
|
if (this.state.editTopic) {
|
||||||
this.topicInputRef.blur();
|
this.topicInputRef.blur();
|
||||||
Keyboard.dismiss();
|
Keyboard.dismiss();
|
||||||
@@ -225,9 +228,6 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
this.prevItem = null;
|
this.prevItem = null;
|
||||||
this.prevIndex = null;
|
this.prevIndex = null;
|
||||||
this.currentInputValue = null;
|
this.currentInputValue = null;
|
||||||
this.topicInputRef.setNativeProps({
|
|
||||||
text: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (forward) {
|
if (forward) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -289,7 +289,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
onChangeText={(value) => {
|
onChangeText={(value) => {
|
||||||
this.title = value;
|
this.title = value;
|
||||||
}}
|
}}
|
||||||
placeholder="Title"
|
placeholder="Enter a Title"
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
this.descriptionRef.focus();
|
this.descriptionRef.focus();
|
||||||
}}
|
}}
|
||||||
@@ -298,43 +298,41 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
|
|
||||||
<Input
|
<Input
|
||||||
fwdRef={(ref) => (this.descriptionRef = ref)}
|
fwdRef={(ref) => (this.descriptionRef = ref)}
|
||||||
testID={notesnook.ids.dialogs.notebook.inputs.title}
|
testID={notesnook.ids.dialogs.notebook.inputs.description}
|
||||||
onChangeText={(value) => {
|
onChangeText={(value) => {
|
||||||
this.description = value;
|
this.description = value;
|
||||||
|
}}
|
||||||
|
placeholder="Describe your notebook."
|
||||||
|
onSubmit={() => {
|
||||||
|
this.topicInputRef.focus();
|
||||||
|
}}
|
||||||
|
defaultValue={toEdit ? toEdit.description : null}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
fwdRef={(ref) => (this.topicInputRef = ref)}
|
||||||
|
testID={notesnook.ids.dialogs.notebook.inputs.topic}
|
||||||
|
onChangeText={(value) => {
|
||||||
this.currentInputValue = value;
|
this.currentInputValue = value;
|
||||||
if (this.prevItem !== null) {
|
if (this.prevItem !== null) {
|
||||||
refs[this.prevIndex].setNativeProps({
|
refs[this.prevIndex].setNativeProps({
|
||||||
text: this.prevIndex + 1 + '. ' + value,
|
text: value,
|
||||||
style: {
|
style: {
|
||||||
borderBottomColor: colors.accent,
|
borderBottomColor: colors.accent,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder="Describe your notebook."
|
|
||||||
onSubmit={() => {
|
|
||||||
this.topicInputRef.focus();
|
|
||||||
}}
|
|
||||||
defaultValue={toEdit ? toEdit.title : null}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Input
|
|
||||||
fwdRef={(ref) => (this.topicInputRef = ref)}
|
|
||||||
testID={notesnook.ids.dialogs.notebook.inputs.title}
|
|
||||||
onChangeText={(value) => {
|
|
||||||
this.description = value;
|
|
||||||
}}
|
|
||||||
placeholder="Describe your notebook."
|
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
this.onSubmit();
|
this.onSubmit();
|
||||||
}}
|
}}
|
||||||
|
blurOnSubmit={false}
|
||||||
button={{
|
button={{
|
||||||
icon: this.state.editTopic ? 'check' : 'plus',
|
icon: this.state.editTopic ? 'check' : 'plus',
|
||||||
onPress: this.onSubmit,
|
onPress: this.onSubmit,
|
||||||
color: topicInputFocused ? colors.accent : colors.icon,
|
color: topicInputFocused ? colors.accent : colors.icon,
|
||||||
}}
|
}}
|
||||||
placeholder="Add a topic"
|
placeholder="Add a topic"
|
||||||
defaultValue={toEdit ? toEdit.title : null}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FlatList
|
<FlatList
|
||||||
|
|||||||
Reference in New Issue
Block a user