Skip to content

Commit 7feee73

Browse files
committed
feat: wrap main app in GestureHandlerRootView for improved gesture handling
1 parent c2486da commit 7feee73

File tree

1 file changed

+75
-67
lines changed

1 file changed

+75
-67
lines changed

example/src/App.tsx

Lines changed: 75 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ActivityIndicator,
1111
} from 'react-native';
1212
import { networkLogger, NetworkLoggerOverlay } from 'react-native-api-debugger';
13+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
1314

1415
interface LoadingState {
1516
[key: string]: boolean;
@@ -229,85 +230,92 @@ const App: React.FC = () => {
229230
};
230231

231232
return (
232-
<SafeAreaView style={styles.container}>
233-
<ScrollView contentContainerStyle={styles.scrollContent}>
234-
<View style={styles.header}>
235-
<Text style={styles.headerTitle}>API Logger Test App</Text>
236-
<Text style={styles.headerSubtitle}>
237-
Test network requests and view them in the logger
238-
</Text>
239-
</View>
240-
241-
<View style={styles.body}>
242-
<Text style={styles.sectionTitle}>GET Requests</Text>
243-
<View style={styles.buttonRow}>
244-
<ButtonComponent
245-
title="Get Posts"
246-
onPress={handleGetPosts}
247-
buttonId="getPosts"
248-
color="#4CAF50"
249-
loading={loading.getPosts}
250-
/>
251-
<ButtonComponent
252-
title="Get Users"
253-
onPress={handleGetUsers}
254-
buttonId="getUsers"
255-
color="#2196F3"
256-
loading={loading.getUsers}
257-
/>
233+
<GestureHandlerRootView style={{ flex: 1 }}>
234+
<SafeAreaView style={styles.container}>
235+
<ScrollView contentContainerStyle={styles.scrollContent}>
236+
<View style={styles.header}>
237+
<Text style={styles.headerTitle}>API Logger Test App</Text>
238+
<Text style={styles.headerSubtitle}>
239+
Test network requests and view them in the logger
240+
</Text>
258241
</View>
259242

260-
<Text style={styles.sectionTitle}>POST Requests</Text>
261-
<View style={styles.buttonRow}>
262-
<ButtonComponent
263-
title="Create Post"
264-
onPress={handleCreatePost}
265-
buttonId="createPost"
266-
color="#FF9800"
267-
loading={loading.createPost}
268-
/>
269-
<ButtonComponent
270-
title="Create User"
271-
onPress={handleCreateUser}
272-
buttonId="createUser"
273-
color="#9C27B0"
274-
loading={loading.createUser}
275-
/>
276-
</View>
243+
<View style={styles.body}>
244+
<Text style={styles.sectionTitle}>GET Requests</Text>
245+
<View style={styles.buttonRow}>
246+
<ButtonComponent
247+
title="Get Posts"
248+
onPress={handleGetPosts}
249+
buttonId="getPosts"
250+
color="#4CAF50"
251+
loading={loading.getPosts}
252+
/>
253+
<ButtonComponent
254+
title="Get Users"
255+
onPress={handleGetUsers}
256+
buttonId="getUsers"
257+
color="#2196F3"
258+
loading={loading.getUsers}
259+
/>
260+
</View>
277261

278-
<Text style={styles.sectionTitle}>Error & Edge Cases</Text>
279-
<View style={styles.buttonRow}>
280-
<ButtonComponent
281-
title="Test 404 Error"
282-
onPress={handleErrorRequest}
283-
buttonId="errorRequest"
284-
color="#F44336"
285-
loading={loading.errorRequest}
286-
/>
287-
</View>
262+
<Text style={styles.sectionTitle}>POST Requests</Text>
263+
<View style={styles.buttonRow}>
264+
<ButtonComponent
265+
title="Create Post"
266+
onPress={handleCreatePost}
267+
buttonId="createPost"
268+
color="#FF9800"
269+
loading={loading.createPost}
270+
/>
271+
<ButtonComponent
272+
title="Create User"
273+
onPress={handleCreateUser}
274+
buttonId="createUser"
275+
color="#9C27B0"
276+
loading={loading.createUser}
277+
/>
278+
</View>
288279

289-
<View style={styles.instructions}>
290-
<Text style={styles.instructionsTitle}>📊 How to use:</Text>
291-
<Text style={styles.instructionsText}>
292-
1. Tap any button to make an API request{'\n'}
293-
2. Check the floating network logger button{'\n'}
294-
3. Tap the logger to view request details{'\n'}
295-
4. Expand requests to see headers & responses{'\n'}
296-
5. Use cURL generation for debugging
297-
</Text>
298-
</View>
299-
</View>
300-
</ScrollView>
280+
<Text style={styles.sectionTitle}>Error & Edge Cases</Text>
281+
<View style={styles.buttonRow}>
282+
<ButtonComponent
283+
title="Test 404 Error"
284+
onPress={handleErrorRequest}
285+
buttonId="errorRequest"
286+
color="#F44336"
287+
loading={loading.errorRequest}
288+
/>
289+
</View>
301290

302-
<NetworkLoggerOverlay networkLogger={networkLogger} />
303-
</SafeAreaView>
291+
<View style={styles.instructions}>
292+
<Text style={styles.instructionsTitle}>📊 How to use:</Text>
293+
<Text style={styles.instructionsText}>
294+
1. Tap any button to make an API request{'\n'}
295+
2. Check the floating network logger button{'\n'}
296+
3. Tap the logger to view request details{'\n'}
297+
4. Expand requests to see headers & responses{'\n'}
298+
5. Use cURL generation for debugging
299+
</Text>
300+
</View>
301+
</View>
302+
</ScrollView>
303+
<NetworkLoggerOverlay
304+
networkLogger={networkLogger}
305+
showRequestHeader={false}
306+
showResponseHeader={false}
307+
draggable={true}
308+
/>
309+
</SafeAreaView>
310+
</GestureHandlerRootView>
304311
);
305312
};
306313

307314
const styles = StyleSheet.create({
308315
container: {
309316
flex: 1,
310317
backgroundColor: '#f5f5f5',
318+
paddingTop: '5%',
311319
},
312320
scrollContent: {
313321
flexGrow: 1,

0 commit comments

Comments
 (0)