Skip to content

Commit 5f16c94

Browse files
committed
Add Modal example
1 parent e4e0ab3 commit 5f16c94

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

example/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { RemoteDataSetExample } from './components/RemoteDataSetExample'
1919
import { RemoteDataSetExample2 } from './components/RemoteDataSetExample2'
2020
import { CustomRightIconExample } from './components/CustomRightIconExample'
2121
import { AutocompleteDropdownContextProvider } from 'react-native-autocomplete-dropdown'
22+
import { ModalExample } from './components/ModalExample'
2223

2324
const App = () => {
2425
const isDarkMode = useColorScheme() === 'dark'
@@ -68,6 +69,10 @@ const App = () => {
6869
<Text style={styles.sectionTitle}>Custom Right Icon Example</Text>
6970
<CustomRightIconExample />
7071
</View>
72+
<View style={styles.section}>
73+
<Text style={styles.sectionTitle}>Modal Example</Text>
74+
<ModalExample />
75+
</View>
7176
</View>
7277
</ScrollView>
7378
</KeyboardAvoidingView>

example/components/ModalExample.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { memo, useState } from 'react'
2+
import { Button, Modal, View } from 'react-native'
3+
import { RemoteDataSetExample } from './RemoteDataSetExample'
4+
import { AutocompleteDropdownContextProvider } from '../../src'
5+
6+
export const ModalExample = memo(() => {
7+
const [opened, setOpened] = useState(false)
8+
return (
9+
<>
10+
<Button onPress={() => setOpened(prev => !prev)} title="Open modal" />
11+
<Modal visible={opened}>
12+
<AutocompleteDropdownContextProvider>
13+
<View style={{ paddingHorizontal: 20, flex: 1 }}>
14+
<RemoteDataSetExample />
15+
<Button onPress={() => setOpened(false)} title="Close modal" />
16+
</View>
17+
</AutocompleteDropdownContextProvider>
18+
</Modal>
19+
</>
20+
)
21+
})

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"metro-react-native-babel-preset": "0.76.8",
3636
"prettier": "^3.0.0",
3737
"react-test-renderer": "18.2.0",
38-
"typescript": "4.8.4"
38+
"typescript": "4.8.4",
39+
"@react-native-community/cli-platform-android": "*"
3940
},
4041
"engines": {
4142
"node": ">=16"

0 commit comments

Comments
 (0)