Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lodev09 committed Apr 4, 2024
1 parent 20e9729 commit ae36545
Showing 1 changed file with 137 additions and 3 deletions.
140 changes: 137 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
![GitHub Release](https://img.shields.io/github/v/release/lodev09/react-native-true-sheet)
![NPM Downloads](https://img.shields.io/npm/dw/%40lodev09%2Freact-native-true-sheet)

The true native bottom sheet.
The true native bottom sheet πŸ’©

<div>
<img height="600" src="preview-ios.gif" />
<img height="600" src="preview-android.gif" />
</div>

## Features
* βœ… Implemented on the native realm.
Expand Down Expand Up @@ -35,15 +40,144 @@ const openSheet = () => {
return (
<View>
<Button onPress={openSheet} title="Open Sheet" />
<TrueSheet sizes={['auto', 'large']} ref={sheet}>
<TrueSheet
ref={sheet}
sizes={['auto', 'large']}
cornerRadius={24}
>
// ...
</TrueSheet>
</View>
)
```

## Options
> TODO - laters

Extended from `ViewProps`

| Prop | Type | Default | Description | 🍎 | πŸ€– |
| - | - | - | - | - | - |
| sizes | [`SheetSize`](#sheetsize) | `['medium', 'large']` | The sizes you want the Sheet to support. Maximum of _**3 sizes**_ only; "collapsed", "half-expanded" and "expanded". Example: `size={['auto', '60%', 'large']}`| βœ… | βœ… |
| backgroundColor | `ColorValue` | - | Main sheet background color. | βœ… | βœ… |
| cornerRadius | `number` | - | The sheet corner radius. | βœ… | βœ… |
| maxHeight | `number` | - | Overrides `large` or `100%` height. | βœ… | βœ… |
| FooterComponent | `ReactNode` | - | A component that floats at the bottom of the Sheet. | βœ… | βœ… |
| grabber | `boolean` | - | Shows native grabber (or handle) on IOS. | βœ… | |
| blurStyle | [`BlurStyle`](#blurstyle) | - | The blur effect style on iOS. Overrides `backgroundColor` if set. Example: `light`, `dark`, etc. | βœ… | |
| scrollRef | `RefObject<...>` | - | The main scrollable ref that Sheet should handle on IOS. | βœ… | |
## Methods
```ts
const sheet = useRef<TrueSheet>(null)

const open = () => {
// Presents 80%
sheet.current?.present(1)
}

const dismiss = () => {
sheet.current?.dismiss()
}

return (
<View>
<Button onPress={open} title="Open" />
<Button onPress={dismiss} title="Dimiss" />
<TrueSheet sizes={['auto', '80%']} ref={sheet}>
// ...
</TrueSheet>
</View>
)
```
| Name | Parameters | Description |
| - | - | - |
| present | `index: number = 0` | Present the modal sheet at size index. See `sizes` prop. |
| dismiss | - | Dismisses the Sheet. |
## Events
```ts
const handleSizeChange = (info: SizeInfo) => {
console.log(info)
}

return (
<TrueSheet onSizeChange={handleSizeChange} sizes={['auto', '80%']} ref={sheet}>
// ...
</TrueSheet>
)
```

| Name | Parameters | Description |
| - | - | - |
| onPresent | [`SizeInfo`](#sizeinfo) | Called when the Sheet has been presented. Comes with the size index and value. |
| onDismiss | - | Called when the Sheet has been dismissed. |
| onSizeChange | [`SizeInfo`](#sizeinfo) | Called when the size of the sheet has changed. Either by dragging or programatically. |

## Types

### `SheetSize`

```ts
<TrueSheet sizes={['auto', '80%', 'large']}>
// ...
</TrueSheet>
```

| Value | Description | 🍎 | πŸ€– |
| - | - | - | - |
| `medium` | Translates to 50% | βœ… | βœ… |
| `large` | Translates to 100% | βœ… | βœ… |
| `auto` | Auto resize based on content height. | iOS 16+ | βœ… |
| `number` | Fixed height | iOS 16+ | βœ… |
| `${number}%` | Fixed height in % | iOS 16+ | βœ… |
| `small` | Translates to 25% | iOS 16+ | βœ… |
### `BlurStyle`
Blur style mapped to native values in IOS.
| Value |
| - |
| `light` |
| `dark` |
| `default` |
| `extraLight` |
| `regular` |
| `prominent` |
| `systemUltraThinMaterial` |
| `systemThinMaterial` |
| `systemMaterial` |
| `systemThickMaterial` |
| `systemChromeMaterial` |
| `systemUltraThinMaterialLight` |
| `systemThinMaterialLight` |
| `systemMaterialLight` |
| `systemThickMaterialLight` |
| `systemChromeMaterialLight` |
| `systemUltraThinMaterialDark` |
| `systemThinMaterialDark` |
| `systemMaterialDark` |
| `systemThickMaterialDark` |
| `systemChromeMaterialDark` |
### `SizeInfo`
`Object` that comes with some events.
```ts
{
index: 1,
value: 69
}
```
| Property | Type | Description |
| - | - | - |
| index | `number` | The size index from the provided sizes. See `sizes` prop. |
| value | `number` | The actual height value of the size. |
## Contributing
Expand Down

0 comments on commit ae36545

Please sign in to comment.