-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddNoteComponent.js
67 lines (63 loc) · 1.68 KB
/
AddNoteComponent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React from 'react';
import {AppRegistry, TextInput, StyleSheet, Text, View, NativeModules, TouchableOpacity} from 'react-native';
import NoteItem from './components/NoteItem';
class AddNoteComponent extends React.Component {
state = {
title:'',
body:''
}
saveNote = async () => {
if(this.state.title === '') alert('please insert title')
else {
if(this.state.body === '') alert('please insert body')
else {
await NativeModules.DataModule.saveNote(this.state.title,this.state.body);
NativeModules.NavigatorModule.showListNotesActivity();
}
}
}
render() {
return (
<View style={styles.container}>
<Text>
Title
</Text>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(title) => this.setState({title})}
value={this.state.title}
/>
<Text>
Body
</Text>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(body) => this.setState({body})}
value={this.state.body}
/>
<TouchableOpacity
onPress={this.saveNote}
style={styles.buttonSave}>
<Text style={styles.buttonText}>Save</Text>
</TouchableOpacity>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
margin:10,
},
buttonText : {
textAlign:'center',
lineHeight:40,
color:'rgba(235, 237, 239, 1)',
},
buttonSave: {
marginTop:10,
width:'100%',
height:40,
backgroundColor : 'rgba(77, 171, 246, 1)'
},
});
AppRegistry.registerComponent('AddNoteComponent', () => AddNoteComponent);