Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: drop react-native-device-info #146

Merged
merged 8 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
- `react-native` >= 0.62.0
- `reanimated` >= 2
- `react-native-gesture-handler` >= 1.10.3
- `react-native-device-info` >= 8.4.8
- `typescript` >= 4.1.0 (if you use TypeScript)
- `expo` >= 41 (if you use Expo)

Expand Down Expand Up @@ -59,7 +58,7 @@ Check the docs here [Click](https://thewidlarzgroup.github.io/react-native-notif
This library needs these dependencies to be installed in your project before you can use it:

```shell
yarn add react-native-reanimated react-native-gesture-handler react-native-device-info
yarn add react-native-reanimated react-native-gesture-handler
```

**react-native-reanimated** requires additional installations
Expand All @@ -68,9 +67,6 @@ steps: [guide here](https://docs.swmansion.com/react-native-reanimated/docs/fund
**react-native-gesture-handler** requires additional installations
steps: [guide here](https://docs.swmansion.com/react-native-gesture-handler/docs/) 👈

**react-native-device-info** requires additional installations
steps: [guide here](https://github.com/react-native-device-info/react-native-device-info) 👈

## Example

Android Emulator | iOS Simulator
Expand All @@ -82,7 +78,6 @@ Android Emulator | iOS Simulator
- [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated)
- [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler)
- [react-native-builder-bob](https://github.com/callstack/react-native-builder-bob)
- [react-native-device-info](https://github.com/react-native-device-info/react-native-device-info)

## 🥂 Contributing

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/apiReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const { NotificationsProvider } = createNotifications({
notificationPosition: NotificationPosition
animationConfig: CustomAnimationConfig
gestureConfig: GestureConfig
isNotch?: boolean // -> by default uses react-native-device-info
isNotch?: boolean
defaultStylesSettings: {
darkMode: false,
globalConfig: StyleProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Let's take a look at what exactly can we set globally:
| duration | Number | 3000 | Use this property to set how long the notifications should be displayed on the screen. Value expressed in milliseconds
| notificationPosition | 'top' / 'center' / 'bottom' | 'top' | Set where the notifications should appear on the screen. You can choose one of three default options: top / center / bottom. To read more about the notification position please go to the [NOTIFICATION POSITION](../default-variants-config/position) section.
| animationConfig | Object | SlideInLeftSlideOutRight | Property responsible for the notification animation. You can set one of the animations prepared by us, or make your own config. To read more about the animation settings please go to the [ANIMATIONS SETTINGS](../animations/changing-transitions) section.
| isNotch | Boolean | value returned by method 'hasNotch' from react-native-device-info | Property responsible for read if the device has notch. Under the hood uses react-native-device-info, but this can by overwritten by passing value to it.
| isNotch | Boolean | false | Property responsible for read if the device has notch. You can use one of the libraries (for example 'react-native-device-info') to read if the specific device has Notch and pass the value here.
| defaultStylesSettings | Object | - | Object responsible for setting global styles for the notifications. You can also set here styles, for all the notifications of the specific type. For example for the error notifications. To read more about global style settings please go to the [GLOBAL STYLES SETTINGS](../default-variants-config/global-config) section.

<br/>
Expand All @@ -29,7 +29,7 @@ const { useNotifications, NotificationsProvider } = createNotifications({
duration: 300,
notificationPosition: 'top',
animationConfig: SlideInLeftSlideOutRight,
isNotch: true or false, // depends on react-native-device-info's 'hasNotch' returned value
isNotch: undefined,
defaultStylesSettings: {},
})
```
14 changes: 7 additions & 7 deletions docs/docs/intro/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ id: intro
- `react-native` >= 0.62.0
- `reanimated` >= 2
- `react-native-gesture-handler` >= 1.10.3
- `react-native-device-info` >= 8.4.8
- `typescript` >= 4.1.0 (if you use TypeScript)
- `expo` >= 41 (if you use Expo)

Expand All @@ -20,12 +19,18 @@ id: intro
yarn add react-native-notificated
```

:::info
Starting from the latest beta version (0.0.2.beta), you are expected to manually tell the library whether a device has notch or not. Use the `isNotch` prop in the config for it (you can use the `react-native-device-info` for instance).

We are currently working on improving this part of our API 💪
:::

### 🛸 Dependencies

This library requires these dependencies to be installed in your project:

```shell
yarn add react-native-reanimated react-native-gesture-handler react-native-device-info
yarn add react-native-reanimated react-native-gesture-handler
```

:::info
Expand All @@ -36,13 +41,8 @@ yarn add react-native-reanimated react-native-gesture-handler react-native-devic
**react-native-gesture-handler** requires additional installation steps: [guide here](https://docs.swmansion.com/react-native-gesture-handler/docs/) 👈
:::

:::info
**react-native-device-info** requires additional installations steps: [guide here](https://github.com/react-native-device-info/react-native-device-info) 👈
:::

## ❤️ Built With[](https://gorhom.github.io/react-native-bottom-sheet/#built-with-%EF%B8%8F)

- [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated)
- [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler)
- [react-native-builder-bob](https://github.com/callstack/react-native-builder-bob)
- [react-native-device-info](https://github.com/react-native-device-info/react-native-device-info)
1 change: 0 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@reduxjs/toolkit": "^1.7.1",
"react": "17.0.2",
"react-native": "0.66.3",
"react-native-device-info": "^8.7.1",
"react-native-gesture-handler": "2.1.1",
"react-native-reanimated": "^2.3.1",
"react-native-safe-area-context": "^3.3.2",
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@
"react-native-builder-bob": "^0.18.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.2.4",
"react-native-device-info": "^8.4.8",
"release-it": "^14.14.3",
"typescript": "^4.1.3"
},
"peerDependencies": {
"react": "*",
"react-native": "*",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.2.4",
"react-native-device-info": "^8.4.8"
"react-native-reanimated": "^2.2.4"
},
"jest": {
"preset": "react-native",
Expand Down
3 changes: 1 addition & 2 deletions src/core/utils/pickers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import type { EmitParam } from '../services/types'
import type { DefaultKeys } from '../../defaultConfig/defaultConfig'
import type { DefaultStylesConfigs } from '../../defaultConfig/types'
import type { KeyType } from '../../types/misc'
import { hasNotch } from 'react-native-device-info'

export const getTopOffset = (
globalConfig: NotificationsConfig<VariantsMap>,
notificationHeight: number
) => {
const isNotch = typeof globalConfig.isNotch === 'undefined' ? hasNotch() : globalConfig.isNotch
const isNotch = globalConfig.isNotch
const extraSpace = 50
const topPosition = isNotch ? extraSpace : 10
const notificationPosition = globalConfig.notificationPosition
Expand Down