make haptic feedback weaker on android (#584)

zio/stable
Ansh 2023-05-04 22:41:08 -07:00 committed by GitHub
parent 99ecb17739
commit 646eddad5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -10,7 +10,9 @@ import {
FontAwesomeIcon, FontAwesomeIcon,
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import ReactNativeHapticFeedback from 'react-native-haptic-feedback' import ReactNativeHapticFeedback, {
HapticFeedbackTypes,
} from 'react-native-haptic-feedback'
// DISABLED see #135 // DISABLED see #135
// import { // import {
// TriggerableAnimated, // TriggerableAnimated,
@ -27,6 +29,7 @@ import {
import {s, colors} from 'lib/styles' import {s, colors} from 'lib/styles'
import {useTheme} from 'lib/ThemeContext' import {useTheme} from 'lib/ThemeContext'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import {isIOS} from 'platform/detection'
interface PostCtrlsOpts { interface PostCtrlsOpts {
itemUri: string itemUri: string
@ -59,6 +62,7 @@ interface PostCtrlsOpts {
} }
const HITSLOP = {top: 5, left: 5, bottom: 5, right: 5} const HITSLOP = {top: 5, left: 5, bottom: 5, right: 5}
const hapticImpact: HapticFeedbackTypes = isIOS ? 'impactMedium' : 'impactLight' // Users said the medium impact was too strong on Android; see APP-537
// DISABLED see #135 // DISABLED see #135
/* /*
@ -111,7 +115,7 @@ export function PostCtrls(opts: PostCtrlsOpts) {
const onRepost = () => { const onRepost = () => {
store.shell.closeModal() store.shell.closeModal()
if (!opts.isReposted) { if (!opts.isReposted) {
ReactNativeHapticFeedback.trigger('impactMedium') ReactNativeHapticFeedback.trigger(hapticImpact)
opts.onPressToggleRepost().catch(_e => undefined) opts.onPressToggleRepost().catch(_e => undefined)
// DISABLED see #135 // DISABLED see #135
// repostRef.current?.trigger( // repostRef.current?.trigger(
@ -137,7 +141,7 @@ export function PostCtrls(opts: PostCtrlsOpts) {
indexedAt: opts.indexedAt, indexedAt: opts.indexedAt,
}, },
}) })
ReactNativeHapticFeedback.trigger('impactMedium') ReactNativeHapticFeedback.trigger(hapticImpact)
} }
const onPressToggleRepostWrapper = () => { const onPressToggleRepostWrapper = () => {
@ -151,7 +155,7 @@ export function PostCtrls(opts: PostCtrlsOpts) {
const onPressToggleLikeWrapper = async () => { const onPressToggleLikeWrapper = async () => {
if (!opts.isLiked) { if (!opts.isLiked) {
ReactNativeHapticFeedback.trigger('impactMedium') ReactNativeHapticFeedback.trigger(hapticImpact)
await opts.onPressToggleLike().catch(_e => undefined) await opts.onPressToggleLike().catch(_e => undefined)
// DISABLED see #135 // DISABLED see #135
// likeRef.current?.trigger( // likeRef.current?.trigger(