From 4df3b60975627fa61e360be05994d18b3803510a Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Mon, 11 Sep 2023 14:04:26 +0200 Subject: [PATCH] Merge types into a single one --- src/libs/HapticFeedback/index.native.ts | 52 +++++++++++-------------- src/libs/HapticFeedback/index.ts | 14 ++++--- src/libs/HapticFeedback/types.ts | 12 +++--- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/libs/HapticFeedback/index.native.ts b/src/libs/HapticFeedback/index.native.ts index f1d7c80aa63d..4c3605cc27ef 100644 --- a/src/libs/HapticFeedback/index.native.ts +++ b/src/libs/HapticFeedback/index.native.ts @@ -1,33 +1,27 @@ import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; -import {HapticFeedbackError, HapticFeedbackLongPress, HapticFeedbackPress, HapticFeedbackSuccess} from './types'; +import HapticFeedback from './types'; -const press: HapticFeedbackPress = () => { - ReactNativeHapticFeedback.trigger('impactLight', { - enableVibrateFallback: true, - }); +const hapticFeedback: HapticFeedback = { + press: () => { + ReactNativeHapticFeedback.trigger('impactLight', { + enableVibrateFallback: true, + }); + }, + longPress: () => { + ReactNativeHapticFeedback.trigger('impactHeavy', { + enableVibrateFallback: true, + }); + }, + success: () => { + ReactNativeHapticFeedback.trigger('notificationSuccess', { + enableVibrateFallback: true, + }); + }, + error: () => { + ReactNativeHapticFeedback.trigger('notificationError', { + enableVibrateFallback: true, + }); + }, }; -const longPress: HapticFeedbackLongPress = () => { - ReactNativeHapticFeedback.trigger('impactHeavy', { - enableVibrateFallback: true, - }); -}; - -const success: HapticFeedbackSuccess = () => { - ReactNativeHapticFeedback.trigger('notificationSuccess', { - enableVibrateFallback: true, - }); -}; - -const error: HapticFeedbackError = () => { - ReactNativeHapticFeedback.trigger('notificationError', { - enableVibrateFallback: true, - }); -}; - -export default { - press, - longPress, - success, - error, -}; +export default hapticFeedback; diff --git a/src/libs/HapticFeedback/index.ts b/src/libs/HapticFeedback/index.ts index ce4b5ec1917b..3dd5b87f573b 100644 --- a/src/libs/HapticFeedback/index.ts +++ b/src/libs/HapticFeedback/index.ts @@ -1,11 +1,13 @@ -import {HapticFeedbackError, HapticFeedbackLongPress, HapticFeedbackPress, HapticFeedbackSuccess} from './types'; +import HapticFeedback from './types'; /** * Web does not support Haptic feedback */ -const press: HapticFeedbackPress = () => {}; -const longPress: HapticFeedbackLongPress = () => {}; -const success: HapticFeedbackSuccess = () => {}; -const error: HapticFeedbackError = () => {}; +const hapticFeedback: HapticFeedback = { + press: () => {}, + longPress: () => {}, + success: () => {}, + error: () => {}, +}; -export default {press, longPress, success, error}; +export default hapticFeedback; diff --git a/src/libs/HapticFeedback/types.ts b/src/libs/HapticFeedback/types.ts index 39d2b36bef21..3db056fad148 100644 --- a/src/libs/HapticFeedback/types.ts +++ b/src/libs/HapticFeedback/types.ts @@ -1,6 +1,8 @@ -type HapticFeedbackPress = () => void; -type HapticFeedbackLongPress = () => void; -type HapticFeedbackSuccess = () => void; -type HapticFeedbackError = () => void; +type HapticFeedback = { + press: () => void; + longPress: () => void; + success: () => void; + error: () => void; +}; -export type {HapticFeedbackPress, HapticFeedbackLongPress, HapticFeedbackSuccess, HapticFeedbackError}; +export default HapticFeedback;