Skip to content

Commit 004900b

Browse files
committed
fix(provider): remove provider needs
1 parent ed8b3a8 commit 004900b

File tree

3 files changed

+89
-87
lines changed

3 files changed

+89
-87
lines changed

example/src/third-party/gorhom-bottom-sheet/index.tsx

Lines changed: 75 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -10,88 +10,8 @@ import {
1010
import { MagicScroll } from '../../../../src';
1111
import { useSafeAreaInsets } from 'react-native-safe-area-context';
1212

13-
const Form = () => {
14-
const insets = useSafeAreaInsets();
15-
16-
return (
17-
<MagicScroll.ScrollView
18-
scollViewProps={{
19-
contentContainerStyle: {
20-
paddingHorizontal: 16,
21-
paddingBottom: insets.bottom + 20,
22-
paddingTop: 100,
23-
},
24-
}}
25-
>
26-
<MagicScroll.TextInput
27-
name="username"
28-
textInputProps={{
29-
placeholder: 'Username',
30-
style: {
31-
height: 50,
32-
backgroundColor: '#ddd',
33-
borderRadius: 6,
34-
paddingHorizontal: 16,
35-
},
36-
}}
37-
/>
38-
<MagicScroll.TextInput
39-
name="first_name"
40-
containerStyle={{ marginTop: 8 }}
41-
textInputProps={{
42-
placeholder: 'First Name',
43-
style: {
44-
height: 50,
45-
backgroundColor: '#ddd',
46-
borderRadius: 6,
47-
paddingHorizontal: 16,
48-
},
49-
}}
50-
/>
51-
<MagicScroll.TextInput
52-
name="last_name"
53-
containerStyle={{ marginTop: 8 }}
54-
textInputProps={{
55-
placeholder: 'Last Name',
56-
style: {
57-
height: 50,
58-
backgroundColor: '#ddd',
59-
borderRadius: 6,
60-
paddingHorizontal: 16,
61-
},
62-
}}
63-
/>
64-
<MagicScroll.TextInput
65-
name="email"
66-
containerStyle={{ marginTop: 8 }}
67-
textInputProps={{
68-
placeholder: 'Email',
69-
style: {
70-
height: 50,
71-
backgroundColor: '#ddd',
72-
borderRadius: 6,
73-
paddingHorizontal: 16,
74-
},
75-
}}
76-
/>
77-
<MagicScroll.TextInput
78-
name="password"
79-
containerStyle={{ marginTop: 8 }}
80-
textInputProps={{
81-
placeholder: 'Password',
82-
style: {
83-
height: 50,
84-
backgroundColor: '#ddd',
85-
borderRadius: 6,
86-
paddingHorizontal: 16,
87-
},
88-
}}
89-
/>
90-
</MagicScroll.ScrollView>
91-
);
92-
};
93-
9413
const Example = () => {
14+
const insets = useSafeAreaInsets();
9515
const bottomSheetModalRef = useRef<BottomSheetModal>(null);
9616

9717
const snapPoints = useMemo(() => ['25%', '80%'], []);
@@ -127,9 +47,80 @@ const Example = () => {
12747
enablePanDownToClose
12848
>
12949
<BottomSheetView style={[styles.contentContainer]}>
130-
<MagicScroll.SmartScrollView>
131-
<Form />
132-
</MagicScroll.SmartScrollView>
50+
<MagicScroll.ScrollView
51+
scollViewProps={{
52+
contentContainerStyle: {
53+
paddingHorizontal: 16,
54+
paddingBottom: insets.bottom + 20,
55+
paddingTop: 100,
56+
},
57+
}}
58+
>
59+
<MagicScroll.TextInput
60+
name="username"
61+
textInputProps={{
62+
placeholder: 'Username',
63+
style: {
64+
height: 50,
65+
backgroundColor: '#ddd',
66+
borderRadius: 6,
67+
paddingHorizontal: 16,
68+
},
69+
}}
70+
/>
71+
<MagicScroll.TextInput
72+
name="first_name"
73+
containerStyle={{ marginTop: 8 }}
74+
textInputProps={{
75+
placeholder: 'First Name',
76+
style: {
77+
height: 50,
78+
backgroundColor: '#ddd',
79+
borderRadius: 6,
80+
paddingHorizontal: 16,
81+
},
82+
}}
83+
/>
84+
<MagicScroll.TextInput
85+
name="last_name"
86+
containerStyle={{ marginTop: 8 }}
87+
textInputProps={{
88+
placeholder: 'Last Name',
89+
style: {
90+
height: 50,
91+
backgroundColor: '#ddd',
92+
borderRadius: 6,
93+
paddingHorizontal: 16,
94+
},
95+
}}
96+
/>
97+
<MagicScroll.TextInput
98+
name="email"
99+
containerStyle={{ marginTop: 8 }}
100+
textInputProps={{
101+
placeholder: 'Email',
102+
style: {
103+
height: 50,
104+
backgroundColor: '#ddd',
105+
borderRadius: 6,
106+
paddingHorizontal: 16,
107+
},
108+
}}
109+
/>
110+
<MagicScroll.TextInput
111+
name="password"
112+
containerStyle={{ marginTop: 8 }}
113+
textInputProps={{
114+
placeholder: 'Password',
115+
style: {
116+
height: 50,
117+
backgroundColor: '#ddd',
118+
borderRadius: 6,
119+
paddingHorizontal: 16,
120+
},
121+
}}
122+
/>
123+
</MagicScroll.ScrollView>
133124
</BottomSheetView>
134125
</BottomSheetModal>
135126
</View>

src/Provider.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default function SmartScrollView(props: PropsWithChildren<{}>) {
7676
);
7777
}
7878

79-
export function ScrollView(
79+
function InsideScrollView(
8080
props: PropsWithChildren<{
8181
scollViewProps?: AnimatedScrollViewProps;
8282
additionalPadding?: number;
@@ -96,6 +96,18 @@ export function ScrollView(
9696
</Animated.ScrollView>
9797
);
9898
}
99+
export const ScrollView = (
100+
props: PropsWithChildren<{
101+
scollViewProps?: AnimatedScrollViewProps;
102+
additionalPadding?: number;
103+
}>
104+
) => {
105+
return (
106+
<SmartScrollView>
107+
<InsideScrollView {...props} />
108+
</SmartScrollView>
109+
);
110+
};
99111

100112
const currentFocusAtom = selectAtom(elementsAtom, (val) =>
101113
Object.keys(val)

src/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import SmartScrollView, { useFormSmartScroll, ScrollView } from './Provider';
1+
import { useFormSmartScroll, ScrollView } from './Provider';
22
import { TextInput } from './TextInput';
33
import ViewWrapper from './ViewWrapper';
44
import { withSmartScroll } from './withSmartScroll';
@@ -9,5 +9,4 @@ export const MagicScroll = {
99
ViewWrapper,
1010
TextInput,
1111
withSmartScroll,
12-
SmartScrollView,
1312
};

0 commit comments

Comments
 (0)