Commit 0fb1e04 1 parent 5b93ab7 commit 0fb1e04 Copy full SHA for 0fb1e04
File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { PasswordModal } from "./components/PasswordModal" ;
2
2
import { Message } from "./components/Message"
3
3
import { FlatList , Text , View } from "react-native" ;
4
+ const RNFS = require ( 'react-native-fs' ) ;
4
5
5
6
export default function App ( ) {
7
+ const [ message , setMessage ] = useState ( "" ) ;
6
8
return (
7
9
< View
8
10
style = { {
@@ -20,6 +22,14 @@ export default function App() {
20
22
>
21
23
22
24
</ FlatList >
25
+
26
+ < View style = { { } } >
27
+ < TextInput style = { styles . textInput } secureTextEntry = { true } onChangeText = { setMessage } > </ TextInput >
28
+ < Button title = 'Submit' onPress = { ( ) => {
29
+ sendMessage ( message ) ;
30
+ setMessage ( "" ) ;
31
+ } } />
32
+ </ View >
23
33
</ View >
24
34
) ;
25
35
}
@@ -55,6 +65,19 @@ class MessageCmp {
55
65
}
56
66
}
57
67
68
+ function sendMessage ( msg ) {
69
+ if ( msg ) {
70
+ var newMsg = {
71
+ type : 0 ,
72
+ content : content . value ,
73
+ id : currId
74
+ } ;
75
+ socket . send ( JSON . stringify ( newMsg ) ) ;
76
+ sendMyMessage ( content . value , currId ) ;
77
+ currId ++ ;
78
+ }
79
+ }
80
+
58
81
function sendMessageInternal ( msg ) {
59
82
messages . push ( msg ) ;
60
83
}
@@ -86,6 +109,7 @@ function submitPassword(pwd) {
86
109
. then ( resp => resp . ok ? resp . text ( ) : Promise . reject ( `${ resp . status } ` ) )
87
110
. then ( async text => {
88
111
token = text ;
112
+ //await RNFS.writeFile(RNFS.DocumentDirectoryPath + '/token.dat', token, 'utf8');
89
113
//await filesystem.writeAsync(token);
90
114
openMessageConnection ( ) ;
91
115
} )
You can’t perform that action at this time.
0 commit comments