Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bufgix committed Nov 19, 2022
1 parent b292b1c commit a85db60
Showing 1 changed file with 95 additions and 14 deletions.
109 changes: 95 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,112 @@
# rn-notify

A notify utility that show notification in app UI
https://user-images.githubusercontent.com/22038798/164993645-bd2b6942-92c2-45c6-b8f1-4286b66bdcd8.mov

## Installation
A utility that displays notifications to user ✏️

## Installation ⚙️

```sh
yarn add rn-notify
```

`rn-notify` needs `react-native-reanimated` package 💎

```sh
npm install rn-notify
yarn add react-native-reanimated
```

## Usage
👇 You also need to complete installations of these packages for more information use the links below 👇

- [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation)

## Usage 🧑‍💻

```tsx
import * as React from 'react';
import { View, Text, TouchableOpacity } from 'react-native';

```js
import { multiply } from 'rn-notify';
import { NotifyProvider, useNotify } from 'rn-notify';

// ...
function Page() {
const notify = useNotify();
return (
<View style={styles.container}>
<TouchableOpacity
onPress={() =>
notify.success({
message: 'Good Job 👍',
duration: 1000,
})
}
>
<Text>Show alert</Text>
</TouchableOpacity>
</View>
);
}

const result = await multiply(3, 7);
export default function App() {
return (
<NotifyProvider>
<Page />
</NotifyProvider>
);
}
```

## Contributing
For more examples check out the [example](https://github.com/Papyon-Apps/rn-notify/blob/feat/reanimated/example/src/App.tsx) folder 📂

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## Usage 🎚️

#### `notify.<type>(options: NotifyOptions)`

Used to show a message. can take 3 types:

- `notify.success` - Shows the message in a green box
- `notify.info` - Shows the message in a yellow box
- `notify.error` - Shows the message in a red box

## License
`NotifyOptions` is an object with the following properties:

MIT
```ts
export type NotifyOptions = {
/**
* The text of the notification.
*/
message: string;
/**
* The level of the notification. Can be 'info', 'success' or 'error'.
*/
level: NotifyLevel;
/**
* The duration of the notification. Defaults to `3000`.
*/
duration?: number;
/**
* Show the timeout bar
*/
noTimeoutBar?: boolean;
/**
* the function to call when the notification is clicked
* @param remove - the function to remove the notification that was clicked
*/
onPress?: (remove: () => void) => void;
/**
* The style of the notification.
*/
options?: {
containerStyle?: ViewStyle;
textStyle?: TextStyle;
timeoutBarStyle?: ViewStyle;
};
};
```

## Contributing 🔖

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

---
## License 📰

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
[MIT](https://github.com/Papyon-Apps/rn-notify/blob/master/LICENSE)

0 comments on commit a85db60

Please sign in to comment.