Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram). AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan. Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { Platform } from 'react-native';
|
|
import * as Haptics from 'expo-haptics';
|
|
|
|
import { useSettingsStore } from '../store/settingsStore';
|
|
|
|
export type HapticStrength = 'Light' | 'Medium' | 'Heavy';
|
|
|
|
/**
|
|
* Returns a stable callback that fires a tactile impact, respecting the user's
|
|
* "disable haptics" preference. Ported from Bluesky's useHaptics hook.
|
|
*
|
|
* Android's medium/heavy impacts feel too strong, so non-iOS platforms always
|
|
* use the Light style regardless of the requested strength.
|
|
*/
|
|
export function useHaptics(): (strength?: HapticStrength) => void {
|
|
const hapticsDisabled = useSettingsStore((state) => state.hapticsDisabled);
|
|
|
|
return useCallback(
|
|
(strength: HapticStrength = 'Medium') => {
|
|
if (hapticsDisabled || Platform.OS === 'web') {
|
|
return;
|
|
}
|
|
|
|
const style =
|
|
Platform.OS === 'ios'
|
|
? Haptics.ImpactFeedbackStyle[strength]
|
|
: Haptics.ImpactFeedbackStyle.Light;
|
|
|
|
// impactAsync returns a promise; fire-and-forget is intentional and any
|
|
// failure (e.g. unsupported device) must not interrupt the interaction.
|
|
void Haptics.impactAsync(style).catch(() => {});
|
|
},
|
|
[hapticsDisabled],
|
|
);
|
|
}
|