Skip to content

Commit e71baab

Browse files
committed
chore: update readme and example code
1 parent a0879f5 commit e71baab

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,21 @@ const PlaceDetailsExample = () => {
183183
</details>
184184

185185
<details>
186-
<summary>Example with scroll configuration</summary>
186+
<summary>Example embed in vertical ScrollView</summary>
187187

188188
```javascript
189-
<GooglePlacesTextInput
190-
apiKey="YOUR_GOOGLE_PLACES_API_KEY"
191-
onPlaceSelect={handlePlaceSelect}
192-
scrollEnabled={false}
193-
nestedScrollEnabled={false}
194-
/>
189+
<ScrollView
190+
keyboardShouldPersistTaps="handled"
191+
nestedScrollEnabled={true}
192+
>
193+
<Text>Fill in your address</Text>
194+
<GooglePlacesTextInput
195+
apiKey="YOUR_GOOGLE_PLACES_API_KEY"
196+
onPlaceSelect={handlePlaceSelect}
197+
scrollEnabled={false}
198+
nestedScrollEnabled={false}
199+
/>
200+
</ScrollView>
195201
```
196202
</details>
197203

example/App.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SafeAreaView, StyleSheet, View, Text } from 'react-native';
1+
import { SafeAreaView, StyleSheet, View, Text, ScrollView } from 'react-native';
22
import GooglePlacesTextInput from 'react-native-google-places-textinput';
33

44
const App = () => {
@@ -65,6 +65,7 @@ const App = () => {
6565

6666
return (
6767
<SafeAreaView style={styles.container}>
68+
{/* Basic usage example with minimal configuration */}
6869
<View style={styles.section}>
6970
<Text style={styles.sectionTitle}>Basic Example</Text>
7071
<GooglePlacesTextInput
@@ -76,6 +77,7 @@ const App = () => {
7677
/>
7778
</View>
7879

80+
{/* Example showing custom styling and filtered place types */}
7981
<View style={styles.section}>
8082
<Text style={styles.sectionTitle}>Styled Example</Text>
8183
<GooglePlacesTextInput
@@ -90,6 +92,7 @@ const App = () => {
9092
/>
9193
</View>
9294

95+
{/* Example demonstrating how to fetch detailed place information */}
9396
<View style={styles.section}>
9497
<Text style={styles.sectionTitle}>Place Details Example</Text>
9598
<GooglePlacesTextInput
@@ -139,23 +142,29 @@ const App = () => {
139142
/>
140143
</View>
141144

145+
{/* This example shows how to properly integrate GooglePlacesTextInput inside a vertical ScrollView */}
142146
<View style={styles.section}>
143-
<Text style={styles.sectionTitle}>Scroll Disabled Example</Text>
144-
<GooglePlacesTextInput
145-
apiKey="YOUR_API_KEY_HERE"
146-
placeHolderText="Try scrolling these results"
147-
onPlaceSelect={(place) => {
148-
console.log('Scroll disabled example, selected:', place);
149-
}}
150-
scrollEnabled={false}
151-
nestedScrollEnabled={false}
152-
style={{
153-
container: {
154-
width: '100%',
155-
paddingHorizontal: 16,
156-
},
157-
}}
158-
/>
147+
<ScrollView
148+
keyboardShouldPersistTaps="handled"
149+
nestedScrollEnabled={true}
150+
>
151+
<Text style={styles.sectionTitle}>Scroll Disabled Example</Text>
152+
<GooglePlacesTextInput
153+
apiKey="YOUR_API_KEY_HERE"
154+
placeHolderText="Try scrolling these results"
155+
onPlaceSelect={(place) => {
156+
console.log('Scroll disabled example, selected:', place);
157+
}}
158+
scrollEnabled={false}
159+
nestedScrollEnabled={false}
160+
style={{
161+
container: {
162+
width: '100%',
163+
paddingHorizontal: 16,
164+
},
165+
}}
166+
/>
167+
</ScrollView>
159168
</View>
160169
</SafeAreaView>
161170
);

0 commit comments

Comments
 (0)