Skip to content

Commit e96ae66

Browse files
committed
More review fixes
1 parent 589c0ee commit e96ae66

6 files changed

Lines changed: 41 additions & 12 deletions

File tree

src/components/DatePicker/CalendarPicker/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function CalendarPicker({
9696
);
9797
return newCurrentDateView;
9898
});
99-
setTimeout(() => setIsYearPickerVisible(false));
99+
requestAnimationFrame(() => setIsYearPickerVisible(false));
100100
};
101101

102102
/**

src/components/Modal/BaseModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ function BaseModal(
209209
innerContainerStyle,
210210
outerStyle,
211211
shouldUseModalPaddingStyle,
212+
shouldUseReanimatedModal,
212213
),
213-
[StyleUtils, type, windowWidth, windowHeight, isSmallScreenWidth, popoverAnchorPosition, innerContainerStyle, outerStyle, shouldUseModalPaddingStyle],
214+
[StyleUtils, type, windowWidth, windowHeight, isSmallScreenWidth, popoverAnchorPosition, innerContainerStyle, outerStyle, shouldUseModalPaddingStyle, shouldUseReanimatedModal],
214215
);
215216

216217
const modalPaddingStyles = useMemo(() => {

src/components/Modal/ReanimatedModal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import type {AnimationInType, AnimationOutType} from './types';
1616
function ReanimatedModal({
1717
testID,
1818
animationInDelay,
19-
animationInTiming = 300,
20-
animationOutTiming = 300,
19+
animationInTiming = CONST.MODAL.ANIMATION_TIMING.DEFAULT_IN,
20+
animationOutTiming = CONST.MODAL.ANIMATION_TIMING.DEFAULT_OUT,
2121
animationIn = 'fadeIn',
2222
animationOut = 'fadeOut',
2323
avoidKeyboard = false,

src/components/Modal/ReanimatedModal/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type {ViewStyle} from 'react-native';
12
import {Easing} from 'react-native-reanimated';
23
import type {ValidKeyframeProps} from 'react-native-reanimated/lib/typescript/commonTypes';
3-
import type {ViewStyle} from 'react-native';
44
import variables from '@styles/variables';
55
import type {AnimationInType, AnimationOutType} from './types';
66

@@ -37,7 +37,8 @@ function getModalInAnimation(animationType: AnimationInType): ValidKeyframeProps
3737
}
3838
}
3939

40-
function getModalInAnimationStyle(animationType: AnimationInType): (progress: number) => ViewStyle { // 'progress' in range [0, 1]
40+
function getModalInAnimationStyle(animationType: AnimationInType): (progress: number) => ViewStyle {
41+
// 'progress' in range [0, 1]
4142
switch (animationType) {
4243
case 'slideInRight':
4344
return (progress) => ({transform: [{translateX: `${100 * (1 - progress)}%`}]});

src/components/SidePanel/HelpComponents/HelpOverlay.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Animated, {Easing, Keyframe} from 'react-native-reanimated';
33
import {PressableWithoutFeedback} from '@components/Pressable';
44
import useLocalize from '@hooks/useLocalize';
55
import useThemeStyles from '@hooks/useThemeStyles';
6-
import variables from '@styles/variables';
76
import CONST from '@src/CONST';
87

98
type HelpOverlayProps = {
@@ -23,13 +22,13 @@ function HelpOverlay({isRHPVisible, onBackdropPress}: HelpOverlayProps) {
2322
const CustomFadeIn = new Keyframe({
2423
from: {opacity: 0},
2524
to: {
26-
opacity: variables.overlayOpacity,
25+
opacity: 0.72,
2726
easing,
2827
},
2928
}).duration(CONST.MODAL.ANIMATION_TIMING.DEFAULT_IN);
3029

3130
const CustomFadeOut = new Keyframe({
32-
from: {opacity: variables.overlayOpacity},
31+
from: {opacity: 0.72},
3332
to: {
3433
opacity: 0,
3534
easing,

src/styles/utils/generators/ModalStyleUtils.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,20 @@ type GetModalStylesStyleUtil = {
4242
innerContainerStyle?: ViewStyle,
4343
outerStyle?: ViewStyle,
4444
shouldUseModalPaddingStyle?: boolean,
45+
shouldUseReanimatedModal?: boolean,
4546
) => GetModalStyles;
4647
};
4748

4849
const createModalStyleUtils: StyleUtilGenerator<GetModalStylesStyleUtil> = ({theme, styles}) => ({
49-
getModalStyles: (type, windowDimensions, popoverAnchorPosition = {}, innerContainerStyle = {}, outerStyle = {}, shouldUseModalPaddingStyle = true): GetModalStyles => {
50+
getModalStyles: (
51+
type,
52+
windowDimensions,
53+
popoverAnchorPosition = {},
54+
innerContainerStyle = {},
55+
outerStyle = {},
56+
shouldUseModalPaddingStyle = true,
57+
shouldUseReanimatedModal = false,
58+
): GetModalStyles => {
5059
const {windowWidth, isSmallScreenWidth} = windowDimensions;
5160

5261
let modalStyle: GetModalStyles['modalStyle'] = {
@@ -270,8 +279,27 @@ const createModalStyleUtils: StyleUtilGenerator<GetModalStylesStyleUtil> = ({the
270279
overflow: 'hidden',
271280
};
272281

273-
animationIn = 'slideInRight';
274-
animationOut = 'slideOutRight';
282+
if (shouldUseReanimatedModal) {
283+
animationIn = 'slideInRight';
284+
animationOut = 'slideOutRight';
285+
} else {
286+
animationIn = {
287+
from: {
288+
translateX: isSmallScreenWidth ? windowWidth : variables.sideBarWidth,
289+
},
290+
to: {
291+
translateX: 0,
292+
},
293+
};
294+
animationOut = {
295+
from: {
296+
translateX: 0,
297+
},
298+
to: {
299+
translateX: isSmallScreenWidth ? windowWidth : variables.sideBarWidth,
300+
},
301+
};
302+
}
275303

276304
hideBackdrop = true;
277305
swipeDirection = undefined;

0 commit comments

Comments
 (0)