From 3c14aaefe32f29b2c1cd8140fda65e2c45e942b0 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sun, 25 Jan 2026 18:29:46 +0300 Subject: [PATCH 01/20] fix: Animation: Many Pages: The displayed animation cannot be stopped or paused --- src/components/Lottie/index.tsx | 10 +++++++--- src/libs/Accessibility/index.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/components/Lottie/index.tsx b/src/components/Lottie/index.tsx index 980290ce4454..b40e74a91dbf 100644 --- a/src/components/Lottie/index.tsx +++ b/src/components/Lottie/index.tsx @@ -7,6 +7,7 @@ import type DotLottieAnimation from '@components/LottieAnimations/types'; import useAppState from '@hooks/useAppState'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import {getBrowser, isMobile} from '@libs/Browser'; import isSideModalNavigator from '@libs/Navigation/helpers/isSideModalNavigator'; import CONST from '@src/CONST'; @@ -23,6 +24,7 @@ function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props const {splashScreenState} = useSplashScreenStateContext(); const styles = useThemeStyles(); const [isError, setIsError] = React.useState(false); + const isReduceMotionEnabled = Accessibility.useReducedMotion(); useNetwork({onReconnect: () => setIsError(false)}); @@ -90,17 +92,19 @@ function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props animationRef?.current?.pause(); }, [hasNavigatedAway]); - // If the page navigates to another screen, the image fails to load, app is in background state, animation file isn't ready, or the splash screen isn't hidden yet, - // we'll just render an empty view as the fallback to prevent + // If the page navigates to another screen, the image fails to load, app is in background state, animation file isn't ready, the splash screen isn't hidden yet, + // or the user prefers reduced motion, we'll just render an empty view as the fallback to prevent // 1. heavy rendering, see issues: https://github.com/Expensify/App/issues/34696 and https://github.com/Expensify/App/issues/47273 // 2. lag on react navigation transitions, see issue: https://github.com/Expensify/App/issues/44812 + // 3. animation playing for users who have reduced motion enabled (WCAG 2.2.2), see issue: https://github.com/Expensify/App/issues/77157 if ( isError || appState.isBackground || !animationFile || hasNavigatedAway || splashScreenState !== CONST.BOOT_SPLASH_STATE.HIDDEN || - (!isInteractionComplete && shouldLoadAfterInteractions) + (!isInteractionComplete && shouldLoadAfterInteractions) || + isReduceMotionEnabled ) { return ( { return isScreenReaderEnabled; }; +/** + * Hook that returns whether the user has enabled the "reduce motion" accessibility setting. + * This is used to disable animations for users who are sensitive to motion. + * Works on iOS, Android, and Web (via react-native-web which uses prefers-reduced-motion media query). + */ +const useReducedMotion = (): boolean => { + const [isReduceMotionEnabled, setIsReduceMotionEnabled] = useState(false); + + useEffect(() => { + AccessibilityInfo.isReduceMotionEnabled() + .then(setIsReduceMotionEnabled) + .catch(() => { + // If the check fails, default to false (animations enabled) + setIsReduceMotionEnabled(false); + }); + + const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setIsReduceMotionEnabled); + + return () => { + subscription?.remove(); + }; + }, []); + + return isReduceMotionEnabled; +}; + const getHitSlopForSize = ({x, y}: HitSlop) => { /* according to https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/ the minimum tappable area is 44x44 points */ @@ -50,4 +76,5 @@ export default { moveAccessibilityFocus, useScreenReaderStatus, useAutoHitSlop, + useReducedMotion, }; From 8c92d311d1267119ae5e0bae8b3aff7c34bbbd10 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sun, 25 Jan 2026 18:46:50 +0300 Subject: [PATCH 02/20] fix: guard against state update on unmounted component in useReducedMotion --- src/libs/Accessibility/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/Accessibility/index.ts b/src/libs/Accessibility/index.ts index d4d645a57096..e2bb2a5c412c 100644 --- a/src/libs/Accessibility/index.ts +++ b/src/libs/Accessibility/index.ts @@ -27,16 +27,25 @@ const useReducedMotion = (): boolean => { const [isReduceMotionEnabled, setIsReduceMotionEnabled] = useState(false); useEffect(() => { + let isMounted = true; + AccessibilityInfo.isReduceMotionEnabled() - .then(setIsReduceMotionEnabled) + .then((enabled) => { + if (isMounted) { + setIsReduceMotionEnabled(enabled); + } + }) .catch(() => { // If the check fails, default to false (animations enabled) - setIsReduceMotionEnabled(false); + if (isMounted) { + setIsReduceMotionEnabled(false); + } }); const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setIsReduceMotionEnabled); return () => { + isMounted = false; subscription?.remove(); }; }, []); From c4222c36731e6a3d2f03381bbc2c76f7ff4f0261 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sun, 25 Jan 2026 18:56:08 +0300 Subject: [PATCH 03/20] fix: use early return pattern in useReducedMotion to satisfy linter --- src/libs/Accessibility/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libs/Accessibility/index.ts b/src/libs/Accessibility/index.ts index e2bb2a5c412c..ebc4b55b4412 100644 --- a/src/libs/Accessibility/index.ts +++ b/src/libs/Accessibility/index.ts @@ -31,15 +31,17 @@ const useReducedMotion = (): boolean => { AccessibilityInfo.isReduceMotionEnabled() .then((enabled) => { - if (isMounted) { - setIsReduceMotionEnabled(enabled); + if (!isMounted) { + return; } + setIsReduceMotionEnabled(enabled); }) .catch(() => { // If the check fails, default to false (animations enabled) - if (isMounted) { - setIsReduceMotionEnabled(false); + if (!isMounted) { + return; } + setIsReduceMotionEnabled(false); }); const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setIsReduceMotionEnabled); From b94d527456dd0456190caf5b90dbd716c85af543 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sun, 25 Jan 2026 20:36:45 +0300 Subject: [PATCH 04/20] test: add unit tests for useReducedMotion hook --- tests/unit/useReducedMotionTest.tsx | 133 ++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 tests/unit/useReducedMotionTest.tsx diff --git a/tests/unit/useReducedMotionTest.tsx b/tests/unit/useReducedMotionTest.tsx new file mode 100644 index 000000000000..f2dce98ea751 --- /dev/null +++ b/tests/unit/useReducedMotionTest.tsx @@ -0,0 +1,133 @@ +import {act, renderHook} from '@testing-library/react-native'; +import {AccessibilityInfo} from 'react-native'; +import Accessibility from '@libs/Accessibility'; + +describe('useReducedMotion', () => { + let mockIsReduceMotionEnabled: jest.Mock; + let mockAddEventListener: jest.Mock; + let mockRemove: jest.Mock; + + beforeEach(() => { + mockRemove = jest.fn(); + mockIsReduceMotionEnabled = jest.fn().mockResolvedValue(false); + mockAddEventListener = jest.fn().mockReturnValue({remove: mockRemove}); + + jest.spyOn(AccessibilityInfo, 'isReduceMotionEnabled').mockImplementation(mockIsReduceMotionEnabled); + jest.spyOn(AccessibilityInfo, 'addEventListener').mockImplementation(mockAddEventListener); + }); + + afterEach(() => { + jest.restoreAllMocks(); + }); + + it('should return false by default', async () => { + const {result} = renderHook(() => Accessibility.useReducedMotion()); + + // Initial state should be false + expect(result.current).toBe(false); + + // Wait for the async check to complete + await act(async () => { + await Promise.resolve(); + }); + + expect(result.current).toBe(false); + }); + + it('should return true when reduce motion is enabled', async () => { + mockIsReduceMotionEnabled.mockResolvedValue(true); + + const {result} = renderHook(() => Accessibility.useReducedMotion()); + + // Wait for the async check to complete + await act(async () => { + await Promise.resolve(); + }); + + expect(result.current).toBe(true); + }); + + it('should subscribe to reduceMotionChanged event', () => { + renderHook(() => Accessibility.useReducedMotion()); + + expect(mockAddEventListener).toHaveBeenCalledWith('reduceMotionChanged', expect.any(Function)); + }); + + it('should update when reduce motion setting changes at runtime', async () => { + let changeHandler: (enabled: boolean) => void = () => {}; + mockAddEventListener.mockImplementation((event: string, handler: (enabled: boolean) => void) => { + changeHandler = handler; + return {remove: mockRemove}; + }); + + const {result} = renderHook(() => Accessibility.useReducedMotion()); + + // Wait for initial async check + await act(async () => { + await Promise.resolve(); + }); + + expect(result.current).toBe(false); + + // Simulate the user enabling reduce motion + await act(async () => { + changeHandler(true); + }); + + expect(result.current).toBe(true); + + // Simulate the user disabling reduce motion + await act(async () => { + changeHandler(false); + }); + + expect(result.current).toBe(false); + }); + + it('should cleanup subscription on unmount', () => { + const {unmount} = renderHook(() => Accessibility.useReducedMotion()); + + unmount(); + + expect(mockRemove).toHaveBeenCalled(); + }); + + it('should handle API failure gracefully', async () => { + mockIsReduceMotionEnabled.mockRejectedValue(new Error('API Error')); + + const {result} = renderHook(() => Accessibility.useReducedMotion()); + + // Wait for the async check to complete + await act(async () => { + await Promise.resolve(); + }); + + // Should default to false on error + expect(result.current).toBe(false); + }); + + it('should not update state after unmount', async () => { + // Create a delayed promise to simulate slow API + let resolvePromise: (value: boolean) => void = () => {}; + mockIsReduceMotionEnabled.mockReturnValue( + new Promise((resolve) => { + resolvePromise = resolve; + }), + ); + + const {result, unmount} = renderHook(() => Accessibility.useReducedMotion()); + + // Unmount before the promise resolves + unmount(); + + // Resolve the promise after unmount + await act(async () => { + resolvePromise(true); + await Promise.resolve(); + }); + + // The state should still be the initial value (false) since we unmounted + // This test verifies the isMounted guard prevents state updates after unmount + expect(result.current).toBe(false); + }); +}); From 76262aa772347cca15e6cb935c73fa24f9ca5e79 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sat, 31 Jan 2026 13:59:29 +0300 Subject: [PATCH 05/20] fix: hide all illustrations (SVG and Lottie) when reduce motion is enable --- src/components/Section/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Section/index.tsx b/src/components/Section/index.tsx index 9b1fa58eb3ab..1848566b1156 100644 --- a/src/components/Section/index.tsx +++ b/src/components/Section/index.tsx @@ -13,6 +13,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import isIllustrationLottieAnimation from '@libs/isIllustrationLottieAnimation'; import type ChildrenProps from '@src/types/utils/ChildrenProps'; import type IconAsset from '@src/types/utils/IconAsset'; @@ -129,6 +130,7 @@ function Section({ const theme = useTheme(); const StyleUtils = useStyleUtils(); const {shouldUseNarrowLayout} = useResponsiveLayout(); + const isReduceMotionEnabled = Accessibility.useReducedMotion(); const isLottie = isIllustrationLottieAnimation(illustration); @@ -144,7 +146,7 @@ function Section({ iconContainerStyles={[iconContainerStyles, styles.alignSelfStart, styles.mb3]} /> )} - {!!illustration && ( + {!!illustration && !isReduceMotionEnabled && ( Date: Sat, 31 Jan 2026 15:04:31 +0300 Subject: [PATCH 06/20] fix: keep overlay content visible when reduce motion hides illustration --- src/components/Section/index.tsx | 38 +++++++++++++++++--------------- src/libs/Accessibility/index.ts | 4 ++-- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/components/Section/index.tsx b/src/components/Section/index.tsx index 1848566b1156..ccf1edc7fdd9 100644 --- a/src/components/Section/index.tsx +++ b/src/components/Section/index.tsx @@ -146,7 +146,7 @@ function Section({ iconContainerStyles={[iconContainerStyles, styles.alignSelfStart, styles.mb3]} /> )} - {!!illustration && !isReduceMotionEnabled && ( + {!!illustration && ( - - {isLottie ? ( - - ) : ( - - )} - + {!isReduceMotionEnabled && ( + + {isLottie ? ( + + ) : ( + + )} + + )} {overlayContent?.()} )} diff --git a/src/libs/Accessibility/index.ts b/src/libs/Accessibility/index.ts index ebc4b55b4412..96faaec5cde0 100644 --- a/src/libs/Accessibility/index.ts +++ b/src/libs/Accessibility/index.ts @@ -29,6 +29,8 @@ const useReducedMotion = (): boolean => { useEffect(() => { let isMounted = true; + const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setIsReduceMotionEnabled); + AccessibilityInfo.isReduceMotionEnabled() .then((enabled) => { if (!isMounted) { @@ -44,8 +46,6 @@ const useReducedMotion = (): boolean => { setIsReduceMotionEnabled(false); }); - const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setIsReduceMotionEnabled); - return () => { isMounted = false; subscription?.remove(); From b2bb34d2d7fe544ee941af4a82b2cf4320fd2aaf Mon Sep 17 00:00:00 2001 From: TaduJR Date: Thu, 5 Feb 2026 17:24:25 +0300 Subject: [PATCH 07/20] fix: pause Lottie animations instead of hiding when reduced motion is enabled --- src/components/Section/index.tsx | 36 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/components/Section/index.tsx b/src/components/Section/index.tsx index ccf1edc7fdd9..31530cab6e68 100644 --- a/src/components/Section/index.tsx +++ b/src/components/Section/index.tsx @@ -157,25 +157,23 @@ function Section({ illustrationContainerStyle, ]} > - {!isReduceMotionEnabled && ( - - {isLottie ? ( - - ) : ( - - )} - - )} + + {isLottie ? ( + + ) : ( + + )} + {overlayContent?.()} )} From 784f54ac6e9cb927b923ce22a933a9750f7e096c Mon Sep 17 00:00:00 2001 From: TaduJR Date: Fri, 13 Feb 2026 09:43:17 +0300 Subject: [PATCH 08/20] fix: render paused Lottie first frame instead of empty view when reduced motion is enabled --- src/components/Lottie/index.tsx | 15 ++++++++------- src/components/Section/index.tsx | 4 ---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/Lottie/index.tsx b/src/components/Lottie/index.tsx index 90d7efafa4f0..39ffcb26efac 100644 --- a/src/components/Lottie/index.tsx +++ b/src/components/Lottie/index.tsx @@ -64,10 +64,12 @@ function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props } const unsubscribeNavigationFocus = navigator.addListener('focus', () => { setHasNavigatedAway(false); - animationRef.current?.play(); + if (!isReduceMotionEnabled) { + animationRef.current?.play(); + } }); return unsubscribeNavigationFocus; - }, [browser, navigationContainerRef, navigator]); + }, [browser, navigationContainerRef, navigator, isReduceMotionEnabled]); useEffect(() => { if (!browser || !navigationContainerRef || !navigator) { @@ -92,19 +94,17 @@ function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props animationRef?.current?.pause(); }, [hasNavigatedAway]); - // If the page navigates to another screen, the image fails to load, app is in background state, animation file isn't ready, the splash screen isn't hidden yet, - // or the user prefers reduced motion, we'll just render an empty view as the fallback to prevent + // If the page navigates to another screen, the image fails to load, app is in background state, animation file isn't ready, or the splash screen isn't hidden yet, + // we'll just render an empty view as the fallback to prevent // 1. heavy rendering, see issues: https://github.com/Expensify/App/issues/34696 and https://github.com/Expensify/App/issues/47273 // 2. lag on react navigation transitions, see issue: https://github.com/Expensify/App/issues/44812 - // 3. animation playing for users who have reduced motion enabled (WCAG 2.2.2), see issue: https://github.com/Expensify/App/issues/77157 if ( isError || appState.isBackground || !animationFile || hasNavigatedAway || splashScreenState !== CONST.BOOT_SPLASH_STATE.HIDDEN || - (!isInteractionComplete && shouldLoadAfterInteractions) || - isReduceMotionEnabled + (!isInteractionComplete && shouldLoadAfterInteractions) ) { return ( { animationRef.current = newRef; }} + autoPlay={!isReduceMotionEnabled} style={[aspectRatioStyle, props.style]} webStyle={{...aspectRatioStyle, ...webStyle}} onAnimationFailure={() => setIsError(true)} diff --git a/src/components/Section/index.tsx b/src/components/Section/index.tsx index 31530cab6e68..5876e247a03a 100644 --- a/src/components/Section/index.tsx +++ b/src/components/Section/index.tsx @@ -13,7 +13,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import Accessibility from '@libs/Accessibility'; import isIllustrationLottieAnimation from '@libs/isIllustrationLottieAnimation'; import type ChildrenProps from '@src/types/utils/ChildrenProps'; import type IconAsset from '@src/types/utils/IconAsset'; @@ -130,8 +129,6 @@ function Section({ const theme = useTheme(); const StyleUtils = useStyleUtils(); const {shouldUseNarrowLayout} = useResponsiveLayout(); - const isReduceMotionEnabled = Accessibility.useReducedMotion(); - const isLottie = isIllustrationLottieAnimation(illustration); const lottieIllustration = isLottie ? illustration : undefined; @@ -163,7 +160,6 @@ function Section({ source={illustration} style={styles.h100} webStyle={styles.h100} - autoPlay={!isReduceMotionEnabled} loop shouldLoadAfterInteractions={shouldUseNarrowLayout} /> From 5b950c721be703328240be915a1bc678f0c0562c Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sat, 21 Feb 2026 10:46:58 +0300 Subject: [PATCH 09/20] fix: cache reduced motion value to prevent animation flash on component remount --- src/libs/Accessibility/index.ts | 12 ++++++++-- tests/unit/useReducedMotionTest.tsx | 37 +++++++++++++++++++---------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/libs/Accessibility/index.ts b/src/libs/Accessibility/index.ts index 96faaec5cde0..a997282a9935 100644 --- a/src/libs/Accessibility/index.ts +++ b/src/libs/Accessibility/index.ts @@ -23,16 +23,24 @@ const useScreenReaderStatus = (): boolean => { * This is used to disable animations for users who are sensitive to motion. * Works on iOS, Android, and Web (via react-native-web which uses prefers-reduced-motion media query). */ +// Module-level cache so new hook instances start with the last known value +// instead of defaulting to false (which causes a race condition on remount) +let cachedReduceMotionValue = false; + const useReducedMotion = (): boolean => { - const [isReduceMotionEnabled, setIsReduceMotionEnabled] = useState(false); + const [isReduceMotionEnabled, setIsReduceMotionEnabled] = useState(cachedReduceMotionValue); useEffect(() => { let isMounted = true; - const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setIsReduceMotionEnabled); + const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', (enabled) => { + cachedReduceMotionValue = enabled; + setIsReduceMotionEnabled(enabled); + }); AccessibilityInfo.isReduceMotionEnabled() .then((enabled) => { + cachedReduceMotionValue = enabled; if (!isMounted) { return; } diff --git a/tests/unit/useReducedMotionTest.tsx b/tests/unit/useReducedMotionTest.tsx index f2dce98ea751..f515f8b887f7 100644 --- a/tests/unit/useReducedMotionTest.tsx +++ b/tests/unit/useReducedMotionTest.tsx @@ -20,12 +20,9 @@ describe('useReducedMotion', () => { jest.restoreAllMocks(); }); - it('should return false by default', async () => { + it('should return false when reduce motion is disabled', async () => { const {result} = renderHook(() => Accessibility.useReducedMotion()); - // Initial state should be false - expect(result.current).toBe(false); - // Wait for the async check to complete await act(async () => { await Promise.resolve(); @@ -62,13 +59,11 @@ describe('useReducedMotion', () => { const {result} = renderHook(() => Accessibility.useReducedMotion()); - // Wait for initial async check + // Wait for initial async check to settle await act(async () => { await Promise.resolve(); }); - expect(result.current).toBe(false); - // Simulate the user enabling reduce motion await act(async () => { changeHandler(true); @@ -115,19 +110,37 @@ describe('useReducedMotion', () => { }), ); - const {result, unmount} = renderHook(() => Accessibility.useReducedMotion()); + const {unmount} = renderHook(() => Accessibility.useReducedMotion()); // Unmount before the promise resolves unmount(); - // Resolve the promise after unmount + // Resolve the promise after unmount — should not throw or update state await act(async () => { resolvePromise(true); await Promise.resolve(); }); + }); - // The state should still be the initial value (false) since we unmounted - // This test verifies the isMounted guard prevents state updates after unmount - expect(result.current).toBe(false); + it('should use cached value on remount so new instances start with correct state', async () => { + mockIsReduceMotionEnabled.mockResolvedValue(true); + + // First mount: resolves to true, which caches the value + const {result: result1, unmount} = renderHook(() => Accessibility.useReducedMotion()); + + await act(async () => { + await Promise.resolve(); + }); + + expect(result1.current).toBe(true); + + // Unmount the first instance + unmount(); + + // Second mount: should start with cached value (true) immediately + const {result: result2} = renderHook(() => Accessibility.useReducedMotion()); + + // On the very first render, it should already be true (from cache) + expect(result2.current).toBe(true); }); }); From dbcd1f6d5861e222babc71d4a276d532e1ee3728 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sat, 21 Feb 2026 12:14:02 +0300 Subject: [PATCH 10/20] fix: show stable animation frame instead of blank first frame when reduced motion is enabled --- src/components/Lottie/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Lottie/index.tsx b/src/components/Lottie/index.tsx index 39ffcb26efac..3e69ef5390aa 100644 --- a/src/components/Lottie/index.tsx +++ b/src/components/Lottie/index.tsx @@ -124,6 +124,7 @@ function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props animationRef.current = newRef; }} autoPlay={!isReduceMotionEnabled} + progress={isReduceMotionEnabled ? 0.5 : undefined} style={[aspectRatioStyle, props.style]} webStyle={{...aspectRatioStyle, ...webStyle}} onAnimationFailure={() => setIsError(true)} From 9fdc4bbf3336be5d1539ad867189b1c5ca12f5b7 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Thu, 5 Mar 2026 12:54:27 +0300 Subject: [PATCH 11/20] fix: show static SVGs on native when reduced motion is enabled for some Lottie animations --- src/components/Lottie/index.tsx | 1 - .../RequireTwoFactorAuthenticationModal.tsx | 1 - .../index.native.ts | 14 ++++++++++++++ .../useAboutSectionIllustration/index.native.ts | 14 ++++++++++++++ .../index.native.ts | 14 ++++++++++++++ .../index.native.ts | 14 ++++++++++++++ .../index.native.ts | 14 ++++++++++++++ .../useWalletSectionIllustration/index.native.ts | 11 +++++++++++ .../signin/SignInPageLayout/SignInHeroImage.tsx | 14 ++++++++++++++ 9 files changed, 95 insertions(+), 2 deletions(-) diff --git a/src/components/Lottie/index.tsx b/src/components/Lottie/index.tsx index 3e69ef5390aa..39ffcb26efac 100644 --- a/src/components/Lottie/index.tsx +++ b/src/components/Lottie/index.tsx @@ -124,7 +124,6 @@ function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props animationRef.current = newRef; }} autoPlay={!isReduceMotionEnabled} - progress={isReduceMotionEnabled ? 0.5 : undefined} style={[aspectRatioStyle, props.style]} webStyle={{...aspectRatioStyle, ...webStyle}} onAnimationFailure={() => setIsError(true)} diff --git a/src/components/RequireTwoFactorAuthenticationModal.tsx b/src/components/RequireTwoFactorAuthenticationModal.tsx index 37350c8f958f..6b4e7ff71866 100644 --- a/src/components/RequireTwoFactorAuthenticationModal.tsx +++ b/src/components/RequireTwoFactorAuthenticationModal.tsx @@ -38,7 +38,6 @@ function RequireTwoFactorAuthenticationModal({onCancel = () => {}, description, const styles = useThemeStyles(); const {translate} = useLocalize(); const StyleUtils = useStyleUtils(); - return ( { + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['SaveTheWorldScale']); + const styles = useThemeStyles(); + + if (isReduceMotionEnabled) { + return { + illustration: illustrations.SaveTheWorldScale, + illustrationStyle: styles.saveTheWorldStaticIllustration, + }; + } + return { illustration: LottieAnimations.SaveTheWorld, }; diff --git a/src/pages/settings/AboutPage/useAboutSectionIllustration/index.native.ts b/src/pages/settings/AboutPage/useAboutSectionIllustration/index.native.ts index e821542a0153..b6a05f5a4942 100644 --- a/src/pages/settings/AboutPage/useAboutSectionIllustration/index.native.ts +++ b/src/pages/settings/AboutPage/useAboutSectionIllustration/index.native.ts @@ -1,7 +1,21 @@ import LottieAnimations from '@components/LottieAnimations'; +import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import type UseAboutSectionIllustration from './types'; const useAboutSectionIllustration: UseAboutSectionIllustration = () => { + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['TiltedCoinExpensify']); + const styles = useThemeStyles(); + + if (isReduceMotionEnabled) { + return { + illustration: illustrations.TiltedCoinExpensify, + illustrationStyle: styles.aboutStaticIllustration, + }; + } + return { illustration: LottieAnimations.Coin, }; diff --git a/src/pages/settings/Preferences/usePreferencesSectionIllustration/index.native.ts b/src/pages/settings/Preferences/usePreferencesSectionIllustration/index.native.ts index c6953dab43b3..7a3029e1930c 100644 --- a/src/pages/settings/Preferences/usePreferencesSectionIllustration/index.native.ts +++ b/src/pages/settings/Preferences/usePreferencesSectionIllustration/index.native.ts @@ -1,7 +1,21 @@ import LottieAnimations from '@components/LottieAnimations'; +import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import type UsePreferencesSectionIllustration from './types'; const usePreferencesSectionIllustration: UsePreferencesSectionIllustration = () => { + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['DjBoothReferenceHands']); + const styles = useThemeStyles(); + + if (isReduceMotionEnabled) { + return { + illustration: illustrations.DjBoothReferenceHands, + illustrationStyle: styles.preferencesStaticIllustration, + }; + } + return { illustration: LottieAnimations.PreferencesDJ, }; diff --git a/src/pages/settings/Security/useSecuritySettingsSectionIllustration/index.native.ts b/src/pages/settings/Security/useSecuritySettingsSectionIllustration/index.native.ts index 9d1b4c635c8f..31d8399e5763 100644 --- a/src/pages/settings/Security/useSecuritySettingsSectionIllustration/index.native.ts +++ b/src/pages/settings/Security/useSecuritySettingsSectionIllustration/index.native.ts @@ -1,7 +1,21 @@ import LottieAnimations from '@components/LottieAnimations'; +import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import type UseSecuritySettingsSectionIllustration from './types'; const useSecuritySettingsSectionIllustration: UseSecuritySettingsSectionIllustration = () => { + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['Safe']); + const styles = useThemeStyles(); + + if (isReduceMotionEnabled) { + return { + illustration: illustrations.Safe, + illustrationStyle: styles.securitySettingsStaticIllustration, + }; + } + return { illustration: LottieAnimations.Safe, }; diff --git a/src/pages/settings/Troubleshoot/useTroubleshootSectionIllustration/index.native.ts b/src/pages/settings/Troubleshoot/useTroubleshootSectionIllustration/index.native.ts index b96941544b82..d45617c23c4a 100644 --- a/src/pages/settings/Troubleshoot/useTroubleshootSectionIllustration/index.native.ts +++ b/src/pages/settings/Troubleshoot/useTroubleshootSectionIllustration/index.native.ts @@ -1,7 +1,21 @@ import LottieAnimations from '@components/LottieAnimations'; +import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import type UseTroubleshootSectionIllustration from './types'; const useTroubleshootSectionIllustration: UseTroubleshootSectionIllustration = () => { + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['WorkspaceScene']); + const styles = useThemeStyles(); + + if (isReduceMotionEnabled) { + return { + illustration: illustrations.WorkspaceScene, + illustrationStyle: styles.troubleshootStaticIllustration, + }; + } + return { illustration: LottieAnimations.Desk, }; diff --git a/src/pages/settings/Wallet/WalletPage/useWalletSectionIllustration/index.native.ts b/src/pages/settings/Wallet/WalletPage/useWalletSectionIllustration/index.native.ts index 4a5010560025..1d9b9a11c4e7 100644 --- a/src/pages/settings/Wallet/WalletPage/useWalletSectionIllustration/index.native.ts +++ b/src/pages/settings/Wallet/WalletPage/useWalletSectionIllustration/index.native.ts @@ -1,10 +1,21 @@ import LottieAnimations from '@components/LottieAnimations'; +import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import type UseWalletSectionIllustration from './types'; const useWalletSectionIllustration: UseWalletSectionIllustration = () => { + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['BigVault']); const styles = useThemeStyles(); + if (isReduceMotionEnabled) { + return { + illustration: illustrations.BigVault, + illustrationStyle: styles.walletStaticIllustration, + }; + } + return { illustration: LottieAnimations.BankVault, illustrationStyle: styles.walletLottieIllustration, diff --git a/src/pages/signin/SignInPageLayout/SignInHeroImage.tsx b/src/pages/signin/SignInPageLayout/SignInHeroImage.tsx index e4e953862261..cb585fc8bd04 100644 --- a/src/pages/signin/SignInPageLayout/SignInHeroImage.tsx +++ b/src/pages/signin/SignInPageLayout/SignInHeroImage.tsx @@ -1,13 +1,18 @@ import React, {useMemo} from 'react'; +import ImageSVG from '@components/ImageSVG'; import Lottie from '@components/Lottie'; import LottieAnimations from '@components/LottieAnimations'; +import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import {isAnonymousUser} from '@libs/actions/Session'; import variables from '@styles/variables'; function SignInHeroImage() { const styles = useThemeStyles(); + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['Hands']); const {shouldUseNarrowLayout, isMediumScreenWidth} = useResponsiveLayout(); const imageSize = useMemo(() => { if (shouldUseNarrowLayout) { @@ -23,6 +28,15 @@ function SignInHeroImage() { }; }, [shouldUseNarrowLayout, isMediumScreenWidth]); + if (isReduceMotionEnabled) { + return ( + + ); + } + return ( Date: Sun, 8 Mar 2026 20:50:05 +0300 Subject: [PATCH 12/20] fix: add SVG fallbacks for remaining Lottie consumers when reduced motion is enabled --- .../BankAccountVerificationView.tsx | 10 ++++--- src/components/ConfirmationPage.tsx | 14 +++++++++- src/components/FeatureTrainingModal.tsx | 27 ++++++++++++++----- src/components/MigratedUserWelcomeModal.tsx | 9 ++++--- .../RequireTwoFactorAuthenticationModal.tsx | 26 +++++++++++++----- .../ValidateCode/JustSignedInModal.tsx | 27 +++++++++++++------ 6 files changed, 83 insertions(+), 30 deletions(-) diff --git a/src/components/BankAccountVerificationView.tsx b/src/components/BankAccountVerificationView.tsx index cc5a93813331..3f53f5cdc5ce 100644 --- a/src/components/BankAccountVerificationView.tsx +++ b/src/components/BankAccountVerificationView.tsx @@ -4,6 +4,7 @@ import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddi import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Accessibility from '@libs/Accessibility'; import Navigation from '@navigation/Navigation'; import variables from '@styles/variables'; import CONST from '@src/CONST'; @@ -24,7 +25,8 @@ type BankAccountVerificationViewProps = { function BankAccountVerificationView({verificationState, children, onVerifiedButtonPress, verifiedButtonText, verifiedTitle, verifiedSubtitle}: BankAccountVerificationViewProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const illustrations = useMemoizedLazyIllustrations(['Puzzle']); + const isReduceMotionEnabled = Accessibility.useReducedMotion(); + const illustrations = useMemoizedLazyIllustrations(['Puzzle', 'Fireworks']); const bottomSafeAreaPaddingStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding: true}); if (!verificationState) { @@ -72,9 +74,9 @@ function BankAccountVerificationView({verificationState, children, onVerifiedBut