Skip to content

Commit bd19d7b

Browse files
authored
chore: add expo-router example and update package (#37)
* chore: add expo-router example and update package * fix: fix example * fix: ts comment * fix: fix ts error
1 parent 6941d64 commit bd19d7b

39 files changed

+2825
-11010
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ jobs:
5757
- name: Build package
5858
run: yarn prepare
5959

60-
build-web:
61-
runs-on: ubuntu-latest
62-
63-
steps:
64-
- name: Checkout
65-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
66-
67-
- name: Setup
68-
uses: ./.github/actions/setup
69-
70-
- name: Build example for Web
71-
run: |
72-
yarn example expo export --platform web
60+
# build-web:
61+
# runs-on: ubuntu-latest
62+
#
63+
# steps:
64+
# - name: Checkout
65+
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
66+
#
67+
# - name: Setup
68+
# uses: ./.github/actions/setup
69+
#
70+
# - name: Build example for Web
71+
# run: |
72+
# yarn example expo export --platform web

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Janic Duplessis
3+
Copyright (c) 2025 AppAndFlow
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
# @th3rdwave/react-navigation-bottom-sheet
1+
# @appandflow/react-navigation-bottom-sheet
22

33
Bottom sheet navigator for React Navigation.
44

5+
Can also work with Expo Router [example](./example/expo-router/)
6+
57
Integrates [@gorhom/bottom-sheet](https://github.com/gorhom/react-native-bottom-sheet) with [React Navigation](https://github.com/react-navigation/react-navigation).
68

79
## Installation
810

911
```sh
10-
yarn add @th3rdwave/react-navigation-bottom-sheet @react-navigation/native @gorhom/bottom-sheet
12+
yarn add @appandflow/react-navigation-bottom-sheet @react-navigation/native @gorhom/bottom-sheet
1113
```
1214

1315
If you don't have those already, you will also need to install the [@gorhom/bottom-sheet dependencies](https://gorhom.github.io/react-native-bottom-sheet/#dependencies) react-native-reanimated and react-native-gesture-handler.
1416

1517
## Usage
1618

1719
```js
18-
import { createBottomSheetNavigator } from "@th3rdwave/react-navigation-bottom-sheet";
20+
import { createBottomSheetNavigator } from '@appandflow/react-navigation-bottom-sheet';
1921

2022
// ...
2123

2224
const BottomSheet = createBottomSheetNavigator();
2325

2426
<BottomSheet.Navigator
2527
// Default options
26-
screenOptions={{ snapPoints: ["60%", "90%"] }}
28+
screenOptions={{ snapPoints: ['60%', '90%'] }}
2729
>
2830
{/* The first screen should be your app content */}
2931
<BottomSheet.Screen name="app" component={MyApp} />
@@ -32,18 +34,22 @@ const BottomSheet = createBottomSheetNavigator();
3234
name="secondSheet"
3335
component={SecondSheetComponent}
3436
// Can pass any prop from @gorhom/bottom-sheet's BottomSheetModal
35-
options={{ snapPoints: [200, "100%"], index: 1 }}
37+
options={{ snapPoints: [200, '100%'], index: 1 }}
3638
/>
3739
</BottomSheet.Navigator>;
3840

3941
// ...
4042

4143
// Open like any regular react-navigation screen.
42-
navigation.navigate("firstSheet", { id: 1 });
43-
44+
navigation.navigate('firstSheet', { id: 1 });
4445
```
4546

46-
See the [example app](./example/src/SimpleExample.tsx) for full usage details.
47+
See the React Navigation [example app](./example/react-navigation/src/SimpleExample.tsx) or the Expo Router example under [`example/expo-router/app`](./example/expo-router/app) for full usage details.
48+
49+
### Running the examples
50+
51+
- `yarn example:react-navigation` – launches the classic React Navigation sample
52+
- `yarn example:expo-router` – launches the Expo Router sample
4753

4854
## API
4955

@@ -52,7 +58,7 @@ See the [example app](./example/src/SimpleExample.tsx) for full usage details.
5258
#### `snapPoints`
5359

5460
```ts
55-
Array<string | number>
61+
Array<string | number>;
5662
```
5763

5864
Points for the bottom sheet to snap to, points should be sorted from bottom to top. It accepts array of number and string.

example/expo-router/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
3+
# The following patterns were generated by expo-cli
4+
5+
expo-env.d.ts
6+
# @end expo-cli

example/expo-router/app.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"expo": {
3+
"name": "@appandflow/react-navigation-bottom-sheet expo-router",
4+
"slug": "appandflow-react-navigation-bottom-sheet-expo-router",
5+
"description": "Expo Router example app for @appandflow/react-navigation-bottom-sheet",
6+
"version": "1.0.0",
7+
"orientation": "portrait",
8+
"icon": "./assets/icon.png",
9+
"userInterfaceStyle": "light",
10+
"newArchEnabled": true,
11+
"splash": {
12+
"image": "./assets/splash-icon.png",
13+
"resizeMode": "contain",
14+
"backgroundColor": "#ffffff"
15+
},
16+
"ios": {
17+
"supportsTablet": true,
18+
"bundleIdentifier": "testlibrary.example.exporouter"
19+
},
20+
"android": {
21+
"adaptiveIcon": {
22+
"foregroundImage": "./assets/adaptive-icon.png",
23+
"backgroundColor": "#ffffff"
24+
},
25+
"edgeToEdgeEnabled": true,
26+
"package": "testlibrary.example.exporouter"
27+
},
28+
"web": {
29+
"favicon": "./assets/favicon.png"
30+
},
31+
"plugins": ["expo-router"],
32+
"experiments": {
33+
"typedRoutes": true
34+
}
35+
}
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { BottomSheetBackdrop } from '@gorhom/bottom-sheet';
2+
import type { BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
3+
import { createBottomSheetNavigator } from '@appandflow/react-navigation-bottom-sheet';
4+
import { withLayoutContext } from 'expo-router';
5+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
6+
import type { BottomSheetParamList } from '../utils/types';
7+
8+
const BottomSheetNavigator = createBottomSheetNavigator<BottomSheetParamList>();
9+
10+
const BottomSheet = withLayoutContext(BottomSheetNavigator.Navigator);
11+
12+
const renderBackdrop = (props: BottomSheetBackdropProps) => (
13+
<BottomSheetBackdrop {...props} appearsOnIndex={0} disappearsOnIndex={-1} />
14+
);
15+
16+
export const unstable_settings = {
17+
initialRouteName: 'index',
18+
};
19+
20+
export default function RootLayout() {
21+
return (
22+
<GestureHandlerRootView>
23+
<BottomSheet
24+
screenOptions={{
25+
backdropComponent: renderBackdrop,
26+
enableDynamicSizing: false,
27+
}}
28+
>
29+
<BottomSheet.Screen name="index" />
30+
<BottomSheet.Screen name="sheet" />
31+
<BottomSheet.Screen
32+
name="big-sheet"
33+
options={{
34+
snapPoints: ['60%', '80%'],
35+
}}
36+
/>
37+
</BottomSheet>
38+
</GestureHandlerRootView>
39+
);
40+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './sheet-screen';

example/expo-router/app/index.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Button, Text, View } from 'react-native';
2+
import { styles } from '../utils/styles';
3+
import { Link, useRouter } from 'expo-router';
4+
5+
export default function HomeScreen() {
6+
const router = useRouter();
7+
return (
8+
<View style={styles.container}>
9+
<Text>Home Screen</Text>
10+
<View style={styles.spacer} />
11+
{/* @ts-ignore - Suppress the error since the runtime will work fine */}
12+
<Link href="/sheet?id=1" asChild>
13+
<Button title="Open sheet" />
14+
</Link>
15+
<View style={styles.spacer} />
16+
<Button
17+
title="Open a big sheet"
18+
onPress={() => {
19+
router.push('/big-sheet?id=1');
20+
}}
21+
/>
22+
</View>
23+
);
24+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Button, Text, View } from 'react-native';
2+
import { useBottomSheetNavigation } from '@appandflow/react-navigation-bottom-sheet';
3+
import { styles } from '../utils/styles';
4+
import type { BottomSheetParamList } from '../utils/types';
5+
import { useLocalSearchParams, usePathname, useRouter } from 'expo-router';
6+
7+
export default function SheetScreen() {
8+
const { id } = useLocalSearchParams<{ id: string }>();
9+
const router = useRouter();
10+
const navigation = useBottomSheetNavigation<BottomSheetParamList>();
11+
const pathname = usePathname();
12+
return (
13+
<View style={[styles.container, styles.content]}>
14+
<Text>Sheet Screen {id}</Text>
15+
<View style={styles.spacer} />
16+
<Button
17+
title="Open new sheet"
18+
onPress={() => {
19+
router.push({
20+
pathname: '/sheet',
21+
params: { id: Number(id) + 1 },
22+
});
23+
}}
24+
/>
25+
<View style={styles.spacer} />
26+
<Button
27+
title="Open new big sheet"
28+
onPress={() => {
29+
router.navigate(`/big-sheet?id=${Number(id) + 1}`);
30+
}}
31+
/>
32+
<View style={styles.spacer} />
33+
<Button
34+
title="Close this sheet"
35+
onPress={() => {
36+
router.back();
37+
}}
38+
/>
39+
{pathname.includes('big-sheet') && (
40+
<>
41+
<View style={styles.spacer} />
42+
<Button
43+
title="Snap to top"
44+
onPress={() => {
45+
navigation.snapTo(1);
46+
}}
47+
/>
48+
</>
49+
)}
50+
</View>
51+
);
52+
}

example/expo-router/app/sheet.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './sheet-screen';

0 commit comments

Comments
 (0)