From effb9130ea464df7415569e426f4d59082d37f7d Mon Sep 17 00:00:00 2001 From: Michael Amaral Date: Sun, 18 Jun 2023 21:16:03 -0300 Subject: [PATCH] chore(remove-haptic): removing generateHaptic (#399) * chore(remove-haptic): removing generateHaptic * chore(remove-haptic): updating author --- README.md | 10 +---- package.json | 8 ++-- src/native/__tests__/generateHaptic.spec.ts | 47 --------------------- src/native/generateHaptic.ts | 8 ---- src/native/index.ts | 1 - yarn.lock | 5 --- 6 files changed, 5 insertions(+), 74 deletions(-) delete mode 100644 src/native/__tests__/generateHaptic.spec.ts delete mode 100644 src/native/generateHaptic.ts diff --git a/README.md b/README.md index e1cc2f3..b89bfc1 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,11 @@ Just add the library to your project and import it! ``` yarn add @platformbuilders/helpers -``` -**If using Native helpers:** +2. Import: ``` -yarn add react-native-haptic react-native-size-matters -``` - -3. Import: -``` import { getTheme } from '@platformbuilders/helpers' import { isIOS } from '@platformbuilders/helpers/native' @@ -62,4 +56,4 @@ import { isIOS } from '@platformbuilders/helpers/native' | Name | Returns | Arguments | | --------------------------------------------------- | ------- | ------------------ | | [`isIOS`](./docs/native/isIOS.md) | boolean | | -| [`generateHaptic`](./docs/native/generateHaptic.md) | void | HapticFeedbackType | +``` diff --git a/package.json b/package.json index e5b420c..b6f6c08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@platformbuilders/helpers", - "version": "0.9.0", + "version": "0.10.0", "description": "Builders helpers library", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -13,7 +13,7 @@ "builders", "helpers" ], - "author": "Builders ", + "author": "Builders ", "license": "ISC", "private": false, "scripts": { @@ -46,7 +46,6 @@ "react": ">=18", "react-dom": ">=18", "react-native": ">=0.69.3", - "react-native-haptic": ">=1.0.1", "react-native-safe-area-context": ">=4.5.3", "react-native-size-matters": ">=0.3.0", "styled-components": ">=5" @@ -99,7 +98,6 @@ "prettier": "2.7.1", "react": "18.2.0", "react-native": "0.70.6", - "react-native-haptic": "1.0.1", "react-native-safe-area-context": "^4.5.3", "react-native-size-matters": "0.4.0", "react-test-renderer": "18.2.0", @@ -114,4 +112,4 @@ "dependencies": { "lint-staged": "^13.2.2" } -} +} \ No newline at end of file diff --git a/src/native/__tests__/generateHaptic.spec.ts b/src/native/__tests__/generateHaptic.spec.ts deleted file mode 100644 index 113a5c4..0000000 --- a/src/native/__tests__/generateHaptic.spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Platform } from 'react-native'; -import Haptic from 'react-native-haptic'; -import { generateHaptic } from '../generateHaptic'; - -jest.mock('react-native-haptic', () => ({ - generate: jest.fn(), -})); - -describe('generateHaptic', () => { - beforeEach(() => { - jest.resetModules(); - }); - - it('should NOT call `generate` when Platform is Android', () => { - // given - Platform.OS = 'android'; - - // when - generateHaptic(); - - // then - expect(Haptic.generate).not.toBeCalled(); - }); - - it('should call `generate` when Platform is IOS', () => { - // given - Platform.OS = 'ios'; - - // when - generateHaptic(); - - // then - expect(Haptic.generate).toBeCalled(); - }); - - it('should call `generate` with specific feedback when Platform is IOS', () => { - // given - Platform.OS = 'ios'; - const hapticFeedbackType = 'notification'; - - // when - generateHaptic(hapticFeedbackType); - - // then - expect(Haptic.generate).toBeCalledWith(hapticFeedbackType); - }); -}); diff --git a/src/native/generateHaptic.ts b/src/native/generateHaptic.ts deleted file mode 100644 index 9181c6e..0000000 --- a/src/native/generateHaptic.ts +++ /dev/null @@ -1,8 +0,0 @@ -import Haptic, { HapticFeedbackType } from 'react-native-haptic'; -import { isIOS } from './isIOS'; - -export const generateHaptic = (haptic: HapticFeedbackType = 'impact'): void => { - if (isIOS()) { - Haptic.generate(haptic); - } -}; diff --git a/src/native/index.ts b/src/native/index.ts index 3fc7124..2c9d72a 100644 --- a/src/native/index.ts +++ b/src/native/index.ts @@ -1,6 +1,5 @@ export { scale, verticalScale, moderateScale } from 'react-native-size-matters'; export * from './isIOS'; -export * from './generateHaptic'; export * from './getShadow'; export * from '../shared'; export * from './useSpacingsWithSafeArea'; diff --git a/yarn.lock b/yarn.lock index b738605..0dfa946 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7666,11 +7666,6 @@ react-native-gradle-plugin@^0.70.3: resolved "https://registry.yarnpkg.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz#cbcf0619cbfbddaa9128701aa2d7b4145f9c4fc8" integrity sha512-oOanj84fJEXUg9FoEAQomA8ISG+DVIrTZ3qF7m69VQUJyOGYyDZmPqKcjvRku4KXlEH6hWO9i4ACLzNBh8gC0A== -react-native-haptic@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/react-native-haptic/-/react-native-haptic-1.0.1.tgz#5ecedb6049c1b0cdeca5e31e4fbde16a622675f3" - integrity sha512-Eg5omAZYZsIGe+QsVkQrK3Krgv96qejYyfgPUfyIELZ1j6W7RnisduJJ+65aV9Nw/k6gxrmvEUC/Uuap4qf8JA== - react-native-safe-area-context@^4.5.3: version "4.5.3" resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.5.3.tgz#e98eb1a73a6b3846d296545fe74760754dbaaa69"