From 458480a0f39f1eab21b90795043a272220a1b99c Mon Sep 17 00:00:00 2001 From: QQ Date: Sat, 14 Nov 2026 14:22:07 +0800 Subject: [PATCH] Import apps/android/src/ui/use-reduce-motion.ts --- apps/android/src/ui/use-reduce-motion.ts | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 apps/android/src/ui/use-reduce-motion.ts diff --git a/apps/android/src/ui/use-reduce-motion.ts b/apps/android/src/ui/use-reduce-motion.ts new file mode 100644 index 0000000..3fd2e93 --- /dev/null +++ b/apps/android/src/ui/use-reduce-motion.ts @@ -0,0 +1,25 @@ +import { useEffect, useState } from 'react' +import { AccessibilityInfo } from 'react-native' + +/** + * System "remove animations" preference, kept live for the lifetime of the + * caller. Shared by connection hero, chat motion and the sheet primitive so a + * single implementation decides how motion degrades. + */ +export function useReduceMotion(): boolean { + const [reduceMotion, setReduceMotion] = useState(false) + + useEffect(() => { + let mounted = true + void AccessibilityInfo.isReduceMotionEnabled().then(enabled => { + if (mounted) setReduceMotion(enabled) + }) + const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduceMotion) + return () => { + mounted = false + subscription.remove() + } + }, []) + + return reduceMotion +}