22 * @format
33 * @flow strict-local
44 */
5-
65import React from 'react' ;
76import {
87 Alert ,
@@ -13,17 +12,16 @@ import {
1312 View ,
1413 Button ,
1514} from 'react-native' ;
16-
17-
15+ import Colors from './Resources/Colors' ;
1816
1917class CreateNotePanel extends React . Component {
2018 constructor ( props ) {
2119 super ( props ) ;
2220 this . state = {
23- title : "" ,
24- message : "" ,
25- }
26- } ;
21+ title : '' ,
22+ message : '' ,
23+ } ;
24+ }
2725
2826 titleOnChange = ( text ) => {
2927 this . setState ( { title : text } ) ;
@@ -34,98 +32,99 @@ class CreateNotePanel extends React.Component {
3432 } ;
3533
3634 cancelButtonPressed = ( ) => {
37- if ( this . state . title !== "" || this . state . message !== "" ) {
38- Alert . alert ( "Are you sure?" , "It looks like you still have unsaved changes, which are going to be lost." ,
39- [
40- {
41- text : "Cancel" ,
42- style : "cancel"
43- } ,
44- {
45- text : "Discard" ,
46- onPress : ( ) => NativeModules . NoteWidgetClickHandler . goToNotesScreen ( )
47- }
48- ] )
49- }
50- else {
35+ if ( this . state . title !== '' || this . state . message !== '' ) {
36+ Alert . alert (
37+ 'Are you sure?' ,
38+ 'It looks like you still have unsaved changes, which are going to be lost.' ,
39+ [
40+ {
41+ text : 'Cancel' ,
42+ style : 'cancel' ,
43+ } ,
44+ {
45+ text : 'Discard' ,
46+ onPress : ( ) =>
47+ NativeModules . NoteWidgetClickHandler . goToNotesScreen ( ) ,
48+ } ,
49+ ] ,
50+ ) ;
51+ } else {
5152 NativeModules . NoteWidgetClickHandler . goToNotesScreen ( ) ;
5253 }
5354 } ;
5455
5556 createButtonPressed = ( ) => {
56- NativeModules . Database . writeNote ( this . state . title , false , this . state . message ) ;
57+ NativeModules . Database . writeNote (
58+ this . state . title ,
59+ false ,
60+ this . state . message ,
61+ ) ;
5762 NativeModules . NoteWidgetClickHandler . goToNotesScreen ( ) ;
58- }
59-
63+ } ;
6064
6165 render ( ) {
6266 return (
6367 < View style = { styles . mainPanel } >
64-
65- < TextInput style = { styles . titleBox }
66- onChangeText = { this . titleOnChange }
67- value = { this . state . title }
68- autoFocus = { true }
69- clearButtonMode = { "while-editing" }
70- placeholder = { "Title" }
71- />
72-
73- < TextInput style = { styles . noteMessageBox }
74- multiline = { true }
75- onChangeText = { this . messageOnChange }
76- value = { this . state . message }
77- placeholder = { "Note content" }
78- />
68+ < TextInput
69+ style = { styles . titleBox }
70+ onChangeText = { this . titleOnChange }
71+ value = { this . state . title }
72+ autoFocus = { true }
73+ clearButtonMode = { 'while-editing' }
74+ placeholder = { 'Title' }
75+ />
76+
77+ < TextInput
78+ style = { styles . noteMessageBox }
79+ multiline = { true }
80+ onChangeText = { this . messageOnChange }
81+ value = { this . state . message }
82+ placeholder = { 'Note content' }
83+ />
7984
8085 < View style = { styles . actionsPanel } >
81- < Button title = { " Discard" } onPress = { this . cancelButtonPressed } />
82- < Button title = { " Create!" } onPress = { this . createButtonPressed } />
86+ < Button title = { ' Discard' } onPress = { this . cancelButtonPressed } />
87+ < Button title = { ' Create!' } onPress = { this . createButtonPressed } />
8388 </ View >
84-
8589 </ View >
8690 ) ;
8791 }
88- } ;
89-
92+ }
9093
9194const styles = StyleSheet . create ( {
9295 mainPanel : {
9396 flex : 1 ,
94- flexDirection : "column" ,
95- alignItems : "center" ,
96- margin : 30
97- } ,
98- titlePanel : {
99- height : 60 ,
97+ flexDirection : 'column' ,
98+ alignItems : 'center' ,
99+ margin : 30 ,
100100 } ,
101101 titleBox : {
102102 borderLeftWidth : 0 ,
103103 borderRightWidth : 0 ,
104104 borderBottomWidth : 1 ,
105105 borderTopWidth : 0 ,
106- width : " 90%" ,
107- borderColor : "#D0D0D0" ,
108- fontWeight : " bold"
106+ width : ' 90%' ,
107+ borderColor : Colors . noteTextPanelBorder ,
108+ fontWeight : ' bold' ,
109109 } ,
110110 noteMessageBox : {
111111 borderWidth : 0.2 ,
112112 margin : 10 ,
113- width : " 90%" ,
114- height : " 85%" ,
115- borderColor : "#D0D0D0" ,
116- alignContent : " center" ,
117- textAlignVertical : " center" ,
113+ width : ' 90%' ,
114+ height : ' 85%' ,
115+ borderColor : Colors . noteTextPanelBorder ,
116+ alignContent : ' center' ,
117+ textAlignVertical : ' center' ,
118118 } ,
119119 actionsPanel : {
120120 flex : 1 ,
121- flexDirection : " row" ,
122- justifyContent : " space-around" ,
123- width : " 60%" ,
121+ flexDirection : ' row' ,
122+ justifyContent : ' space-around' ,
123+ width : ' 60%' ,
124124 maxHeight : 35 ,
125- }
125+ } ,
126126} ) ;
127127
128-
129- AppRegistry . registerComponent ( "CreateNotePanel" , ( ) => CreateNotePanel ) ;
128+ AppRegistry . registerComponent ( 'CreateNotePanel' , ( ) => CreateNotePanel ) ;
130129
131130export default CreateNotePanel ;
0 commit comments