Skip to content

Commit 4e1e2ad

Browse files
feat: initial release
1 parent d28b216 commit 4e1e2ad

16 files changed

+22135
-165
lines changed

.circleci/config.yml

Lines changed: 0 additions & 98 deletions
This file was deleted.

example/babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = function (api) {
1717
},
1818
},
1919
],
20+
'react-native-reanimated/plugin',
2021
],
2122
};
2223
};

example/metro.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
2-
const blacklist = require('metro-config/src/defaults/blacklist');
2+
const exclusionList = require('metro-config/src/defaults/exclusionList');
33
const escape = require('escape-string-regexp');
44
const pak = require('../package.json');
55

@@ -16,11 +16,11 @@ module.exports = {
1616
// We need to make sure that only one version is loaded for peerDependencies
1717
// So we blacklist them at the root, and alias them to the versions in example's node_modules
1818
resolver: {
19-
blacklistRE: blacklist(
19+
blockList: exclusionList(
2020
modules.map(
2121
(m) =>
22-
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
23-
)
22+
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`),
23+
),
2424
),
2525

2626
extraNodeModules: modules.reduce((acc, name) => {

example/package.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@
1212
"test": "jest"
1313
},
1414
"dependencies": {
15-
"expo": "^42.0.0",
16-
"expo-splash-screen": "~0.11.2",
17-
"react": "16.13.1",
18-
"react-dom": "16.13.1",
19-
"react-native": "0.63.4",
20-
"react-native-unimodules": "~0.14.5",
21-
"react-native-web": "~0.13.12"
15+
"@gorhom/bottom-sheet": "^4.3.1",
16+
"@react-navigation/native": "^6.0.10",
17+
"expo": "^45.0.5",
18+
"react": "17.0.2",
19+
"react-dom": "17.0.2",
20+
"react-native": "0.68.2",
21+
"react-native-gesture-handler": "~2.2.1",
22+
"react-native-reanimated": "~2.8.0",
23+
"react-native-web": "0.17.7"
2224
},
2325
"devDependencies": {
24-
"@babel/core": "~7.9.0",
25-
"@babel/runtime": "^7.9.6",
26-
"babel-plugin-module-resolver": "^4.0.0",
27-
"babel-preset-expo": "8.3.0",
28-
"expo-cli": "^4.0.13"
26+
"@babel/core": "~7.18.2",
27+
"@babel/runtime": "^7.18.3",
28+
"@types/react": "~17.0.21",
29+
"babel-plugin-module-resolver": "^4.1.0",
30+
"babel-preset-expo": "9.1.0",
31+
"expo-cli": "^5.4.9"
2932
}
3033
}

example/src/App.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
11
import * as React from 'react';
2-
3-
import { StyleSheet, View, Text } from 'react-native';
4-
import { multiply } from '@th3rdwave/react-navigation-bottom-sheet';
2+
import { StyleSheet } from 'react-native';
3+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
4+
import { SimpleExample } from './SimpleExample';
55

66
export default function App() {
7-
const [result, setResult] = React.useState<number | undefined>();
8-
9-
React.useEffect(() => {
10-
multiply(3, 7).then(setResult);
11-
}, []);
12-
137
return (
14-
<View style={styles.container}>
15-
<Text>Result: {result}</Text>
16-
</View>
8+
<GestureHandlerRootView style={styles.container}>
9+
<SimpleExample />
10+
</GestureHandlerRootView>
1711
);
1812
}
1913

2014
const styles = StyleSheet.create({
2115
container: {
2216
flex: 1,
23-
alignItems: 'center',
24-
justifyContent: 'center',
25-
},
26-
box: {
27-
width: 60,
28-
height: 60,
29-
marginVertical: 20,
3017
},
3118
});

example/src/SimpleExample.tsx

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import {
2+
BottomSheetBackdrop,
3+
BottomSheetBackdropProps,
4+
} from '@gorhom/bottom-sheet';
5+
import { NavigationContainer } from '@react-navigation/native';
6+
import {
7+
BottomSheetScreenProps,
8+
createBottomSheetNavigator,
9+
} from '@th3rdwave/react-navigation-bottom-sheet';
10+
import * as React from 'react';
11+
import { Button, StyleSheet, Text, View } from 'react-native';
12+
13+
type BottomSheetParams = {
14+
Home: undefined;
15+
Sheet: { id: number };
16+
};
17+
18+
const BottomSheet = createBottomSheetNavigator<BottomSheetParams>();
19+
20+
function HomeScreen({
21+
navigation,
22+
}: BottomSheetScreenProps<BottomSheetParams, 'Home'>) {
23+
return (
24+
<View style={styles.container}>
25+
<Text>Home Screen</Text>
26+
<Button
27+
title="Open sheet"
28+
onPress={() => {
29+
navigation.navigate('Sheet', { id: 1 });
30+
}}
31+
/>
32+
</View>
33+
);
34+
}
35+
36+
function SheetScreen({
37+
route,
38+
navigation,
39+
}: BottomSheetScreenProps<BottomSheetParams, 'Sheet'>) {
40+
return (
41+
<View style={styles.container}>
42+
<Text>Sheet Screen {route.params.id}</Text>
43+
<Button
44+
title="Open new sheet"
45+
onPress={() => {
46+
navigation.navigate('Sheet', { id: route.params.id + 1 });
47+
}}
48+
/>
49+
<Button
50+
title="Close sheet"
51+
onPress={() => {
52+
navigation.goBack();
53+
}}
54+
/>
55+
<Button
56+
title="Snap to top"
57+
onPress={() => {
58+
navigation.snapTo(1);
59+
}}
60+
/>
61+
</View>
62+
);
63+
}
64+
65+
export function SimpleExample() {
66+
const renderBackdrop = React.useCallback(
67+
(props: BottomSheetBackdropProps) => (
68+
<BottomSheetBackdrop
69+
{...props}
70+
appearsOnIndex={0}
71+
disappearsOnIndex={-1}
72+
/>
73+
),
74+
[],
75+
);
76+
return (
77+
<NavigationContainer>
78+
<BottomSheet.Navigator
79+
screenOptions={{
80+
snapPoints: ['70%', '90%'],
81+
backdropComponent: renderBackdrop,
82+
}}
83+
>
84+
<BottomSheet.Screen name="Home" component={HomeScreen} />
85+
<BottomSheet.Screen
86+
name="Sheet"
87+
component={SheetScreen}
88+
getId={({ params }) => `sheet-${params.id}`}
89+
/>
90+
</BottomSheet.Navigator>
91+
</NavigationContainer>
92+
);
93+
}
94+
95+
const styles = StyleSheet.create({
96+
container: { flex: 1, alignItems: 'center', justifyContent: 'center' },
97+
});

example/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"paths": {
4+
"@th3rdwave/react-navigation-bottom-sheet": ["../"],
5+
"react": ["./node_modules/@types/react"],
6+
}
7+
},
8+
"extends": "expo/tsconfig.base"
9+
}

0 commit comments

Comments
 (0)