Skip to content

Commit c23a177

Browse files
committed
demonstrate nestedScrolling implementation
1 parent 873571b commit c23a177

File tree

4 files changed

+41
-18
lines changed

4 files changed

+41
-18
lines changed

example/App.js

+28-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
1-
/**
2-
* Sample React Native App
3-
* https://github.com/facebook/react-native
4-
*
5-
* @format
6-
* @flow
7-
*/
8-
9-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
102
import {
113
SafeAreaView,
124
StatusBar,
135
TouchableOpacity,
146
Text,
157
View,
168
TextInput,
9+
ScrollView,
1710
} from 'react-native';
18-
import ActionSheet from 'react-native-actions-sheet';
11+
import ActionSheet, {addHasReachedTopListener, removeHasReachedTopListener} from 'react-native-actions-sheet';
12+
1913

2014
const App = () => {
15+
const [nestedScrollEnabled, setNestedScrollEnabled] = useState(false);
16+
2117
let actionSheet;
2218

19+
const _onHasReachedTop = () => {
20+
setNestedScrollEnabled(true);
21+
}
22+
23+
useEffect(() => {
24+
addHasReachedTopListener(_onHasReachedTop)
25+
return () => {
26+
removeHasReachedTopListener(_onHasReachedTop)
27+
}
28+
},[])
29+
30+
const _onClose = () => {
31+
setNestedScrollEnabled(false);
32+
}
33+
2334
return (
2435
<>
2536
<StatusBar barStyle="dark-content" />
@@ -61,11 +72,14 @@ const App = () => {
6172
bounceOnOpen={true}
6273
bounciness={8}
6374
gestureEnabled={true}
75+
onClose={_onClose}
6476
defaultOverlayOpacity={0.3}>
65-
<View
77+
<ScrollView
78+
nestedScrollEnabled={nestedScrollEnabled}
6679
style={{
6780
width: '100%',
6881
padding: 12,
82+
maxHeight:500
6983
}}>
7084
<View
7185
style={{
@@ -105,7 +119,7 @@ const App = () => {
105119
placeholder="Write your text here"></TextInput>
106120

107121
<View style={{}}>
108-
{[100, 60, 150, 200, 170, 80, 40].map(item => (
122+
{[100, 60, 150, 200, 170, 80, 41,101, 61, 151, 202, 172, 82, 43,103, 64, 155, 205, 176, 86, 46,106, 66, 152, 203, 173, 81, 42].map(item => (
109123
<TouchableOpacity
110124
key={item}
111125
onPress={() => {
@@ -136,7 +150,8 @@ const App = () => {
136150
</TouchableOpacity>
137151
))}
138152
</View>
139-
</View>
153+
</ScrollView>
154+
140155
</ActionSheet>
141156
</SafeAreaView>
142157
</>

example/ios/example.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@
194194
48EE7C255324ED125727C018 /* Pods-exampleTests.debug.xcconfig */,
195195
6102F24A6E168475D2E3F3DE /* Pods-exampleTests.release.xcconfig */,
196196
);
197-
name = Pods;
198197
path = Pods;
199198
sourceTree = "<group>";
200199
};
@@ -308,6 +307,7 @@
308307
developmentRegion = English;
309308
hasScannedForEncodings = 0;
310309
knownRegions = (
310+
English,
311311
en,
312312
Base,
313313
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

example/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -5032,10 +5032,10 @@ react-is@^16.8.1, react-is@^16.8.4, react-is@^16.9.0:
50325032
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c"
50335033
integrity sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==
50345034

5035-
react-native-actions-sheet@^0.1.6:
5036-
version "0.1.6"
5037-
resolved "https://registry.yarnpkg.com/react-native-actions-sheet/-/react-native-actions-sheet-0.1.6.tgz#1b04cb22c565c252aad1840e2763e880e4796cab"
5038-
integrity sha512-3bGhRCBGKXpM5cA9S2/NMH2HQEDdMiMsP1Gl2HFcgK8dBlsgQcMiZv+JOrhewCJvUc1srbMWGitAYXBnEjYxfw==
5035+
react-native-actions-sheet@^0.1.9:
5036+
version "0.1.9"
5037+
resolved "https://registry.yarnpkg.com/react-native-actions-sheet/-/react-native-actions-sheet-0.1.9.tgz#03409456a5d793a2ff36482b754270880a936d32"
5038+
integrity sha512-MYioZKkvNJr53Z0jGHK5MIuvXjptGmbzRgfqT16bgIyFjE2Wm0DK962K9c5s8bcfrRmeE+lJ+LV+nUQw6dRimQ==
50395039

50405040
react-native@0.61.5:
50415041
version "0.61.5"

0 commit comments

Comments
 (0)