Skip to content

Commit d1cd46b

Browse files
author
Pierre Gee
authored
fix(ui): bottom sheet reduced motion (#4183)
1 parent bf3cd26 commit d1cd46b

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

mobile-app/app/components/BottomSheetInfo.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { tailwind } from "@tailwind";
22
import { translate } from "@translations";
33
import { StyleProp, TextStyle, View } from "react-native";
4+
import { useReducedMotion } from "react-native-reanimated";
45
import { ThemedIcon, ThemedText } from "./themed";
56
import { BottomSheetModal } from "./BottomSheetModal";
67

@@ -19,12 +20,15 @@ export function BottomSheetInfo({
1920
alertInfo,
2021
infoIconStyle,
2122
}: BottomSheetInfoProps): JSX.Element {
23+
const reducedMotion = useReducedMotion();
24+
2225
return (
2326
<BottomSheetModal
2427
name={name}
2528
index={0}
2629
snapPoints={["30%"]}
2730
alertInfo={alertInfo}
31+
animateOnMount={!reducedMotion}
2832
triggerComponent={
2933
<ThemedIcon
3034
size={16}

mobile-app/app/components/BottomSheetWithNav.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
BottomSheetBackgroundProps,
1111
BottomSheetModal,
1212
} from "@gorhom/bottom-sheet";
13+
import { useReducedMotion } from "react-native-reanimated";
1314
import { BottomSheetModalMethods } from "@gorhom/bottom-sheet/lib/typescript/types";
1415
import { NavigationContainer, Theme } from "@react-navigation/native";
1516
import { AddOrRemoveCollateralFormProps } from "@screens/AppNavigator/screens/Loans/components/AddOrRemoveCollateralForm";
@@ -49,6 +50,8 @@ export interface BottomSheetWithNavRouteParam {
4950

5051
export const BottomSheetWithNav = React.memo(
5152
(props: BottomSheetWithNavProps): JSX.Element => {
53+
const reducedMotion = useReducedMotion();
54+
5255
const getSnapPoints = (): string[] => {
5356
if (Platform.OS === "ios") {
5457
return props.snapPoints?.ios ?? ["50%"];
@@ -66,6 +69,7 @@ export const BottomSheetWithNav = React.memo(
6669
enablePanDownToClose={false}
6770
handleComponent={EmptyHandleComponent}
6871
keyboardBlurBehavior="restore"
72+
animateOnMount={!reducedMotion}
6973
backdropComponent={(backdropProps: BottomSheetBackdropProps) => (
7074
<View
7175
{...backdropProps}

mobile-app/app/components/BottomSheetWithNavV2.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
BottomSheetBackdropProps,
99
BottomSheetModal,
1010
} from "@gorhom/bottom-sheet";
11+
import { useReducedMotion } from "react-native-reanimated";
1112
import { BottomSheetModalMethods } from "@gorhom/bottom-sheet/lib/typescript/types";
1213
import { NavigationContainer } from "@react-navigation/native";
1314
import { AddOrRemoveCollateralFormProps } from "@screens/AppNavigator/screens/Loans/components/AddOrRemoveCollateralForm";
@@ -49,6 +50,8 @@ export const BottomSheetWithNavV2 = React.memo(
4950
(props: BottomSheetWithNavProps): JSX.Element => {
5051
const { modalRef, snapPoints } = props;
5152

53+
const reducedMotion = useReducedMotion();
54+
5255
const getSnapPoints = (): string[] => {
5356
if (Platform.OS === "ios") {
5457
return snapPoints?.ios ?? ["50%"];
@@ -66,6 +69,7 @@ export const BottomSheetWithNavV2 = React.memo(
6669
handleComponent={EmptyHandleComponent}
6770
enablePanDownToClose={false}
6871
keyboardBlurBehavior="restore"
72+
animateOnMount={!reducedMotion}
6973
backdropComponent={(backdropProps: BottomSheetBackdropProps) => (
7074
<View
7175
{...backdropProps}

mobile-app/app/screens/TransactionAuthorization/PasscodePrompt.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
BottomSheetBackgroundProps,
1919
BottomSheetModal,
2020
} from "@gorhom/bottom-sheet";
21+
import { useReducedMotion } from "react-native-reanimated";
2122
import { BottomSheetModalMethods } from "@gorhom/bottom-sheet/lib/typescript/types";
2223
import * as React from "react";
2324
import Modal from "react-overlays/Modal";
@@ -155,8 +156,8 @@ const PromptContent = React.memo((props: PasscodePromptProps): JSX.Element => {
155156
props.attemptsRemaining === 1
156157
? "Last attempt or your wallet will be unlinked for your security"
157158
: props.isRetry
158-
? "Incorrect passcode.\n{{attemptsRemaining}} attempts remaining"
159-
: "{{attemptsRemaining}} attempts remaining"
159+
? "Incorrect passcode.\n{{attemptsRemaining}} attempts remaining"
160+
: "{{attemptsRemaining}} attempts remaining"
160161
}`,
161162
{ attemptsRemaining: props.attemptsRemaining },
162163
)}
@@ -172,6 +173,8 @@ const PromptContent = React.memo((props: PasscodePromptProps): JSX.Element => {
172173
export const PasscodePrompt = React.memo(
173174
(props: PasscodePromptProps): JSX.Element => {
174175
const containerRef = React.useRef(null);
176+
const reducedMotion = useReducedMotion();
177+
175178
const getSnapPoints = (): string[] => {
176179
if (Platform.OS === "ios") {
177180
return ["70%"]; // ios measures space without keyboard
@@ -225,6 +228,7 @@ export const PasscodePrompt = React.memo(
225228
ref={props.modalRef}
226229
snapPoints={getSnapPoints()}
227230
handleComponent={EmptyHandleComponent}
231+
animateOnMount={!reducedMotion}
228232
backdropComponent={(backdropProps: BottomSheetBackdropProps) => (
229233
<View
230234
{...backdropProps}

0 commit comments

Comments
 (0)