@rific/drawer 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @rific/drawer
2
2
 
3
- Left/right sliding drawer for React Native — spring-animated, theme-aware (reads colors from `react-native-paper`), and opens either by calling an action or by swiping in from the screen edge. One `createDrawer()` call per drawer instance, so a left nav drawer and a right settings drawer stay fully independent.
3
+ Left/right sliding drawer for React Native. Spring-animated, theme-aware (reads colors from `react-native-paper`), and opens either by calling an action or by swiping in from the screen edge. One `createDrawer()` call per drawer instance, so a left nav drawer and a right settings drawer stay fully independent.
4
4
 
5
5
  ## Install
6
6
 
@@ -14,7 +14,7 @@ npm install @rific/drawer
14
14
  npm install react-native-gesture-handler react-native-reanimated react-native-paper @rific/haptic-press
15
15
  ```
16
16
 
17
- Your app's root must already be wrapped in `GestureHandlerRootView` (from `react-native-gesture-handler`) — this package doesn't add its own, since only one should ever wrap the whole app.
17
+ Your app's root must already be wrapped in `GestureHandlerRootView` (from `react-native-gesture-handler`). This package doesn't add its own, since only one should ever wrap the whole app.
18
18
 
19
19
  ## Usage
20
20
 
@@ -25,7 +25,7 @@ const { DrawerProvider: NavDrawerProvider, useDrawer: useNavDrawer } = createDra
25
25
  const { DrawerProvider: SettingsDrawerProvider, useDrawer: useSettingsDrawer } = createDrawer({ side: 'right', width: 320 })
26
26
  ```
27
27
 
28
- Mount each `DrawerProvider` once, near your app root — `children` is the rest of the app (so `useDrawer()` is reachable from anywhere inside it), `content` is what renders inside the sliding panel itself. With more than one drawer, `combineDrawerProviders` flattens the nesting into a single wrapper (first argument is outermost, matching how you'd nest them by hand):
28
+ Mount each `DrawerProvider` once, near your app root: `children` is the rest of the app (so `useDrawer()` is reachable from anywhere inside it), and `content` is what renders inside the sliding panel itself. With more than one drawer, `combineDrawerProviders` flattens the nesting into a single wrapper (first argument is outermost, matching how you'd nest them by hand):
29
29
 
30
30
  ```tsx
31
31
  import { combineDrawerProviders } from '@rific/drawer'
@@ -43,7 +43,7 @@ export default function RootLayout() {
43
43
  }
44
44
  ```
45
45
 
46
- Each drawer's state stays fully independent under the hood — this is purely a way to avoid writing out the nesting by hand. With a single drawer, just render its `DrawerProvider` directly with a `content` prop; `combineDrawerProviders` only earns its keep once you have more than one.
46
+ Each drawer's state stays fully independent under the hood. This is purely a way to avoid writing out the nesting by hand. With a single drawer, just render its `DrawerProvider` directly with a `content` prop; `combineDrawerProviders` only earns its keep once you have more than one.
47
47
 
48
48
  Then anywhere else in the tree:
49
49
 
@@ -55,8 +55,12 @@ const { isOpen, open, close } = useNavDrawer()
55
55
  <IconButton icon='menu' onPress={open} />
56
56
  ```
57
57
 
58
- The drawer opens by calling `open()`, by tapping the backdrop or an in-content close button (call `close()`), or by swiping in from the screen edge — no extra wiring needed for the swipe gesture, it's built into `DrawerProvider`. Pass `enabled={false}` to `DrawerProvider` to temporarily suppress the edge-swipe gesture (e.g. on a screen where it would conflict with another gesture).
58
+ The drawer opens by calling `open()`, by tapping the backdrop or an in-content close button (call `close()`), or by swiping in from the screen edge. No extra wiring is needed for the swipe gesture; it's built into `DrawerProvider`. Pass `enabled={false}` to `DrawerProvider` to temporarily suppress the edge-swipe gesture (e.g. on a screen where it would conflict with another gesture).
59
+
60
+ ## Safe area
61
+
62
+ The panel renders edge-to-edge, behind the status bar/notch and home indicator, on purpose. This package doesn't take a position on how you handle that. Pad your `content` yourself, however fits your app: `useSafeAreaInsets()` from `react-native-safe-area-context` directly, or a safe-area-aware header like `@rific/scroll-view`'s. Baking a fixed strategy into the panel itself would double up with whichever one you're already using for the rest of your app.
59
63
 
60
64
  ## Lower-level pieces
61
65
 
62
- `Drawer` (the sliding panel + backdrop) and `DrawerEdgeSwipe` (the edge gesture zone) are also exported directly, for apps that want to manage the open/closed state and shared value themselves instead of using `createDrawer()`.
66
+ `Drawer` (the sliding panel and backdrop) and `DrawerEdgeSwipe` (the edge gesture zone) are also exported directly, for apps that want to manage the open/closed state and shared value themselves instead of using `createDrawer()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rific/drawer",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Left/right sliding drawer with edge-swipe gestures for React Native — spring-animated, theme-aware, one factory call per drawer instance",
5
5
  "keywords": [
6
6
  "react-native",
package/src/Drawer.tsx CHANGED
@@ -7,6 +7,9 @@ import Animated, { SharedValue, useAnimatedStyle, useSharedValue, withSpring } f
7
7
  const SPRING = { damping: 40, stiffness: 300, overshootClamping: true }
8
8
 
9
9
  export type DrawerProps = {
10
+ // Renders edge-to-edge behind the status bar/notch/home indicator, deliberately — pad your own
11
+ // content with useSafeAreaInsets() (or a safe-area-aware header like @rific/scroll-view's) rather
12
+ // than have this component impose a strategy that might double up with one you're already using.
10
13
  children?: ReactNode
11
14
  onClose: () => void
12
15
  open: boolean