From 64c65497be97e2b6b179eaf6b277e160de13176c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Grychto=C5=82?= <44443723+danielmark0116@users.noreply.github.com> Date: Wed, 8 Jun 2022 19:44:24 +0200 Subject: [PATCH] feat: drop react-native-device-info (#146) --- README.md | 7 +------ docs/docs/api/apiReference.md | 2 +- .../global-notifications-settings.md | 16 ++++++++-------- docs/docs/intro/intro.md | 14 +++++++------- example/package.json | 1 - package.json | 4 +--- src/core/utils/pickers.ts | 3 +-- 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 1e0f0eaf..119ffcfb 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/docs/docs/api/apiReference.md b/docs/docs/api/apiReference.md index 3f208150..e9484c45 100644 --- a/docs/docs/api/apiReference.md +++ b/docs/docs/api/apiReference.md @@ -70,7 +70,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 diff --git a/docs/docs/intro/comprehensive-configuration/global-notifications-settings.md b/docs/docs/intro/comprehensive-configuration/global-notifications-settings.md index be0b3027..504a1a2a 100644 --- a/docs/docs/intro/comprehensive-configuration/global-notifications-settings.md +++ b/docs/docs/intro/comprehensive-configuration/global-notifications-settings.md @@ -12,13 +12,13 @@ In the beginning, you can set the configuration for all the notifications used i Let's take a look at what exactly can we set globally: -| Name | Type | Default | Description | -| --------------------- | :-------------------------: | :---------------------------------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 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 defining whether the device has a notched display. Under the hood uses react-native-device-info, but this can by overwritten by passing value to it. | -| defaultStylesSettings | Object | - | Object responsible for setting global styles for the notifications. You can also set the styles for all the notifications of a 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. | +| Name | Type | Default | Description | +| ----------------------------------- | :-------------------------: | :----------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 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 | 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.
@@ -31,7 +31,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: {}, }) ``` diff --git a/docs/docs/intro/intro.md b/docs/docs/intro/intro.md index 5bf0410c..6fb931cb 100644 --- a/docs/docs/intro/intro.md +++ b/docs/docs/intro/intro.md @@ -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) @@ -20,12 +19,18 @@ id: intro yarn add react-native-notificated ``` +:::info +Starting from the latest beta version, 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 @@ -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) diff --git a/example/package.json b/example/package.json index f84836fb..10a2ad4a 100644 --- a/example/package.json +++ b/example/package.json @@ -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", diff --git a/package.json b/package.json index f7f909c9..0df0caba 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,6 @@ "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" }, @@ -77,8 +76,7 @@ "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", diff --git a/src/core/utils/pickers.ts b/src/core/utils/pickers.ts index 893e7350..a3771f69 100644 --- a/src/core/utils/pickers.ts +++ b/src/core/utils/pickers.ts @@ -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, 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