This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
56 lines (50 loc) · 1.66 KB
/
App.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
import React from 'react'
import { TouchableWithoutFeedback, Keyboard, StyleSheet, Text, View, TextInput } from 'react-native'
import emojis from 'emojis-hash'
const replaceEmoji = (text) => (
text
.split(' ')
.map(word => emojis[word.toLowerCase()] || word)
.join(' ')
)
export default class App extends React.Component {
constructor(props) {
super(props)
this.state = { text: '', emojiText: '...and emojify it!' }
this.onChangeText = this.onChangeText.bind(this)
}
onChangeText(text) {
this.setState({
text,
emojiText: replaceEmoji(text)
})
}
render() {
return (
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={{flex: 1}}>
<View style={{flex: 1, backgroundColor: 'powderblue'}}>
<Text style={{fontSize: 30, padding: 20, textAlign: 'center'}}>
Emojify
</Text>
</View>
<View style={{flex: 1, backgroundColor: 'skyblue'}}>
<TextInput
multiline={true}
value={this.state.text}
placeholder='Type something here...'
placeholderTextColor='black'
onChangeText={this.onChangeText}
style={{fontSize: 20, flex: 1, textAlignVertical: 'center', textAlign: 'center', padding: 10}}
/>
</View>
<View style={{flex: 3, backgroundColor: 'steelblue'}}>
<Text style={{fontSize: 20, flex: 1, textAlignVertical: 'center', textAlign: 'center', color: 'white', padding: 10}}>
{this.state.emojiText}
</Text>
</View>
</View>
</TouchableWithoutFeedback>
)
}
}