forked from TheWidlarzGroup/rn-emoji-keyboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnableRecently.tsx
44 lines (39 loc) · 1.13 KB
/
EnableRecently.tsx
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
import * as React from 'react'
import { StyleSheet, Text, TouchableOpacity } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
import EmojiPicker from 'rn-emoji-keyboard'
import type { EmojiType } from 'src/types'
const EnableRecently = () => {
const [result, setResult] = React.useState<string>()
const [isModalOpen, setIsModalOpen] = React.useState<boolean>(false)
const handlePick = (emoji: EmojiType) => {
console.log(emoji)
setResult(emoji.emoji)
setIsModalOpen((prev) => !prev)
}
return (
<SafeAreaView style={styles.container}>
<Text style={styles.text}>Result: {result}</Text>
<TouchableOpacity onPress={() => setIsModalOpen(true)}>
<Text style={styles.text}>Open</Text>
</TouchableOpacity>
<EmojiPicker
onEmojiSelected={handlePick}
open={isModalOpen}
onClose={() => setIsModalOpen(false)}
enableRecentlyUsed
/>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
text: {
textAlign: 'center',
margin: 64,
fontSize: 18,
},
})
export default EnableRecently