migrate to 'expo-haptics' (#3418)

* migrate to 'expo-haptics'

* run yarn install twice if necessary
zio/stable
Hailey 2024-04-04 21:19:38 -07:00 committed by GitHub
parent cddbbc4bd4
commit 4e59914d2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 21 deletions

View File

@ -32,9 +32,6 @@ jobs:
node-version-file: .nvmrc node-version-file: .nvmrc
cache: yarn cache: yarn
- name: ⚙️ Install Dependencies
run: yarn install
- name: Ensure tracking relevant branches and checkout base - name: Ensure tracking relevant branches and checkout base
run: | run: |
git checkout ${{ github.head_ref }} git checkout ${{ github.head_ref }}
@ -50,6 +47,7 @@ jobs:
git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
git merge --no-edit ${{ github.head_ref }} git merge --no-edit ${{ github.head_ref }}
yarn install
- name: 🔦 Generate stats file for PR - name: 🔦 Generate stats file for PR
run: | run: |
@ -72,6 +70,7 @@ jobs:
- name: 🔦 Generate stats file from base commit - name: 🔦 Generate stats file from base commit
if: ${{ !steps.get-base-stats.outputs.cache-hit }} if: ${{ !steps.get-base-stats.outputs.cache-hit }}
run: | run: |
yarn install
yarn generate-webpack-stats-file yarn generate-webpack-stats-file
mv stats.json stats-base.json mv stats.json stats-base.json

View File

@ -113,6 +113,7 @@
"expo-constants": "~15.4.5", "expo-constants": "~15.4.5",
"expo-dev-client": "~3.3.8", "expo-dev-client": "~3.3.8",
"expo-device": "~5.9.3", "expo-device": "~5.9.3",
"expo-haptics": "^12.8.1",
"expo-image": "~1.10.6", "expo-image": "~1.10.6",
"expo-image-manipulator": "^11.8.0", "expo-image-manipulator": "^11.8.0",
"expo-image-picker": "~14.7.1", "expo-image-picker": "~14.7.1",
@ -159,7 +160,6 @@
"react-native-fs": "^2.20.0", "react-native-fs": "^2.20.0",
"react-native-gesture-handler": "~2.14.0", "react-native-gesture-handler": "~2.14.0",
"react-native-get-random-values": "~1.11.0", "react-native-get-random-values": "~1.11.0",
"react-native-haptic-feedback": "^1.14.0",
"react-native-image-crop-picker": "^0.38.1", "react-native-image-crop-picker": "^0.38.1",
"react-native-ios-context-menu": "^1.15.3", "react-native-ios-context-menu": "^1.15.3",
"react-native-linear-gradient": "^2.6.2", "react-native-linear-gradient": "^2.6.2",

View File

@ -1,28 +1,35 @@
import {isIOS, isWeb} from 'platform/detection' import {
import ReactNativeHapticFeedback, { impactAsync,
HapticFeedbackTypes, ImpactFeedbackStyle,
} from 'react-native-haptic-feedback' notificationAsync,
NotificationFeedbackType,
selectionAsync,
} from 'expo-haptics'
const hapticImpact: HapticFeedbackTypes = isIOS ? 'impactMedium' : 'impactLight' // Users said the medium impact was too strong on Android; see APP-537s import {isIOS, isWeb} from 'platform/detection'
const hapticImpact: ImpactFeedbackStyle = isIOS
? ImpactFeedbackStyle.Medium
: ImpactFeedbackStyle.Light // Users said the medium impact was too strong on Android; see APP-537s
export class Haptics { export class Haptics {
static default() { static default() {
if (isWeb) { if (isWeb) {
return return
} }
ReactNativeHapticFeedback.trigger(hapticImpact) impactAsync(hapticImpact)
} }
static impact(type: HapticFeedbackTypes = hapticImpact) { static impact(type: ImpactFeedbackStyle = hapticImpact) {
if (isWeb) { if (isWeb) {
return return
} }
ReactNativeHapticFeedback.trigger(type) impactAsync(type)
} }
static selection() { static selection() {
if (isWeb) { if (isWeb) {
return return
} }
ReactNativeHapticFeedback.trigger('selection') selectionAsync()
} }
static notification = (type: 'success' | 'warning' | 'error') => { static notification = (type: 'success' | 'warning' | 'error') => {
if (isWeb) { if (isWeb) {
@ -30,11 +37,11 @@ export class Haptics {
} }
switch (type) { switch (type) {
case 'success': case 'success':
return ReactNativeHapticFeedback.trigger('notificationSuccess') return notificationAsync(NotificationFeedbackType.Success)
case 'warning': case 'warning':
return ReactNativeHapticFeedback.trigger('notificationWarning') return notificationAsync(NotificationFeedbackType.Warning)
case 'error': case 'error':
return ReactNativeHapticFeedback.trigger('notificationError') return notificationAsync(NotificationFeedbackType.Error)
} }
} }
} }

View File

@ -11877,6 +11877,11 @@ expo-font@~11.10.3:
dependencies: dependencies:
fontfaceobserver "^2.1.0" fontfaceobserver "^2.1.0"
expo-haptics@^12.8.1:
version "12.8.1"
resolved "https://registry.yarnpkg.com/expo-haptics/-/expo-haptics-12.8.1.tgz#42b996763be33d661bd33bbc3b3958c3f2734b9d"
integrity sha512-ntLsHkfle8K8w9MW8pZEw92ZN3sguaGUSSIxv30fPKNeQFu7Cq/h47Qv3tONv2MO3wU48N9FbKnant6XlfptpA==
expo-image-loader@~4.6.0: expo-image-loader@~4.6.0:
version "4.6.0" version "4.6.0"
resolved "https://registry.yarnpkg.com/expo-image-loader/-/expo-image-loader-4.6.0.tgz#ca7d4fdf53125bff2091d3a2c34a3155f10df147" resolved "https://registry.yarnpkg.com/expo-image-loader/-/expo-image-loader-4.6.0.tgz#ca7d4fdf53125bff2091d3a2c34a3155f10df147"
@ -18603,11 +18608,6 @@ react-native-get-random-values@~1.11.0:
dependencies: dependencies:
fast-base64-decode "^1.0.0" fast-base64-decode "^1.0.0"
react-native-haptic-feedback@^1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/react-native-haptic-feedback/-/react-native-haptic-feedback-1.14.0.tgz#b50f49dedda4980b3c37c5780823f753cf3ee717"
integrity sha512-dSXZ6gAzl+W/L7BPjOpnT0bx0cgQiSr0sB3DjyDJbGIdVr4ISaktZC6gC9xYFTv2kMq0+KtbKi+dpd0WtxYZMw==
react-native-image-crop-picker@^0.38.1: react-native-image-crop-picker@^0.38.1:
version "0.38.1" version "0.38.1"
resolved "https://registry.yarnpkg.com/react-native-image-crop-picker/-/react-native-image-crop-picker-0.38.1.tgz#5973b4a8b55835b987e6be2064de411e849ac005" resolved "https://registry.yarnpkg.com/react-native-image-crop-picker/-/react-native-image-crop-picker-0.38.1.tgz#5973b4a8b55835b987e6be2064de411e849ac005"