show loading on add notebook and topic dialog

This commit is contained in:
ammarahm-ed
2021-02-09 16:41:34 +05:00
parent dd9d4853a4
commit fdcaaeef9e
2 changed files with 22 additions and 15 deletions

View File

@@ -7,7 +7,7 @@ import {
SafeAreaView,
StyleSheet,
TouchableOpacity,
View
View,
} from 'react-native';
import {FlatList, TextInput} from 'react-native-gesture-handler';
import {notesnook} from '../../../e2e/test.ids';
@@ -38,6 +38,7 @@ export class AddNotebookDialog extends React.Component {
count: 0,
topicInputFocused: false,
editTopic: false,
loading: false,
};
this.title = null;
this.description = null;
@@ -54,7 +55,6 @@ export class AddNotebookDialog extends React.Component {
this.hiddenInput = createRef();
this.topicInputRef = createRef();
this.addingTopic = false;
}
open = () => {
@@ -129,6 +129,9 @@ export class AddNotebookDialog extends React.Component {
};
addNewNotebook = async () => {
this.setState({
loading: true,
});
let {topics} = this.state;
let edit = this.props.toEdit;
@@ -233,8 +236,8 @@ export class AddNotebookDialog extends React.Component {
}
}
this.topicInputRef.current?.setNativeProps({
text:''
})
text: '',
});
this.topicInputRef.current?.focus();
};
@@ -377,6 +380,7 @@ export class AddNotebookDialog extends React.Component {
positiveTitle={toEdit && toEdit.dateCreated ? 'Save' : 'Add'}
onPressPositive={this.addNewNotebook}
onPressNegative={this.close}
loading={this.state.loading}
/>
</View>
</KeyboardAvoidingView>

View File

@@ -26,6 +26,7 @@ export class AddTopicDialog extends React.Component {
this.state = {
visible: false,
titleFocused: false,
loading:false
};
this.title;
@@ -34,6 +35,7 @@ export class AddTopicDialog extends React.Component {
}
addNewTopic = async () => {
this.setState({loading:true})
if (!this.title)
return ToastEvent.show('Title is required', 'error', 'local');
@@ -112,6 +114,7 @@ export class AddTopicDialog extends React.Component {
positiveTitle={toEdit ? 'Save' : 'Add'}
onPressNegative={() => this.close()}
onPressPositive={() => this.addNewTopic()}
loading={this.state.loading}
/>
</DialogContainer>
<Toast context="local" />