Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS Migration] Migrate withWindowDimensions and Modal directories to TypeScript #30338

Merged
merged 28 commits into from
Nov 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
eebfbf1
migrate withWindowDimensions directory to TypeScript
JKobrynski Oct 20, 2023
8213caa
create types file for Modal
JKobrynski Oct 20, 2023
cf613ad
start migrating BaseModal to TypeScript
JKobrynski Oct 23, 2023
408ef25
add missing prop types
JKobrynski Oct 24, 2023
1c1d092
update types, update helper function types
JKobrynski Oct 24, 2023
118415e
reorganise types in StyleUtils
JKobrynski Oct 24, 2023
4c18fc0
fix typings in BaseModal
JKobrynski Oct 24, 2023
c016d84
migrate index.web.js to TypeScript
JKobrynski Oct 25, 2023
5f3968d
migrate index.ios.js to TypeScript
JKobrynski Oct 25, 2023
ffa9d70
migrate index.android.js to TypeScript
JKobrynski Oct 25, 2023
a437818
fix spacing calculation
JKobrynski Oct 25, 2023
7a637b9
Merge branch 'main' into migrateModalToTypeScript
JKobrynski Oct 25, 2023
7385968
apply finishing touches
JKobrynski Oct 26, 2023
c26a716
remove unnecessary conditional function calls
JKobrynski Oct 26, 2023
a1adc37
create common NewDimensions type
JKobrynski Oct 26, 2023
bc5c041
change index.web.tsx to index.tsx to fix linting
JKobrynski Oct 26, 2023
673d120
add event to backdrop press handler
JKobrynski Oct 26, 2023
2d7d45b
apply changes based on feedback from code review
JKobrynski Oct 26, 2023
a75557f
extract PopoverAnchorPosition to TypeScript
JKobrynski Oct 26, 2023
595c90d
Merge branch 'main' into migrateModalToTypeScript
JKobrynski Oct 30, 2023
da8b083
add return types to HOCs, fix linting
JKobrynski Oct 30, 2023
a6287ed
fix imports
JKobrynski Oct 30, 2023
3dfe00b
Merge branch 'main' into migrateModalToTypeScript
JKobrynski Nov 8, 2023
f4afdb4
remove redundant useNativeDriver prop
JKobrynski Nov 8, 2023
8082b7c
bring back default useNativeDriver prop for android
JKobrynski Nov 9, 2023
a5e8a58
add optional chaining to onModalShow
JKobrynski Nov 9, 2023
20e80d1
destructure props in Modal
JKobrynski Nov 13, 2023
434e472
bring back default props
JKobrynski Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix typings in BaseModal
  • Loading branch information
JKobrynski committed Oct 24, 2023
commit 4c18fc0ba771b5c5f2995b97c24c9d388ae17b34
32 changes: 13 additions & 19 deletions src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React, {forwardRef, useCallback, useEffect, useMemo, useRef} from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import ReactNativeModal from 'react-native-modal';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import styles from '../../styles/styles';
import * as Modal from '../../libs/actions/Modal';
import * as StyleUtils from '../../styles/StyleUtils';
import themeColors from '../../styles/themes/default';
import {propTypes as modalPropTypes, defaultProps as modalDefaultProps} from './modalPropTypes';
import getModalStyles from '../../styles/getModalStyles';
import useWindowDimensions from '../../hooks/useWindowDimensions';
import variables from '../../styles/variables';
import CONST from '../../CONST';
import ComposerFocusManager from '../../libs/ComposerFocusManager';
import useNativeDriver from '../../libs/useNativeDriver';
import usePrevious from '../../hooks/usePrevious';
Expand All @@ -21,24 +18,24 @@ function BaseModal(
{
JKobrynski marked this conversation as resolved.
Show resolved Hide resolved
isVisible,
onClose,
shouldSetModalVisibility,
onModalHide,
shouldSetModalVisibility = true,
onModalHide = () => {},
type,
popoverAnchorPosition,
innerContainerStyle,
popoverAnchorPosition = {},
innerContainerStyle = {},
outerStyle,
onModalShow,
onModalShow = () => {},
propagateSwipe,
fullscreen,
fullscreen = true,
animationIn,
animationOut,
useNativeDriver: useNativeDriverProp,
hideModalContentWhileAnimating,
hideModalContentWhileAnimating = false,
animationInTiming,
animationOutTiming,
statusBarTranslucent,
statusBarTranslucent = true,
onLayout,
avoidKeyboard,
avoidKeyboard = false,
children,
}: BaseModalProps,
ref: React.ForwardedRef<View>,
Expand Down Expand Up @@ -101,13 +98,10 @@ function BaseModal(
if (shouldSetModalVisibility) {
Modal.setModalVisibility(true);
}
onModalShow();
onModalShow?.();
JKobrynski marked this conversation as resolved.
Show resolved Hide resolved
};

const handleBackdropPress = (e) => {
if (e && e.key === CONST.KEYBOARD_SHORTCUTS.ENTER.shortcutKey) {
JKobrynski marked this conversation as resolved.
Show resolved Hide resolved
return;
}
const handleBackdropPress = () => {
onClose();
};

Expand Down Expand Up @@ -186,8 +180,8 @@ function BaseModal(
style={modalStyle}
deviceHeight={windowHeight}
deviceWidth={windowWidth}
animationIn={animationIn || modalStyleAnimationIn}
animationOut={animationOut || modalStyleAnimationOut}
animationIn={animationIn ?? modalStyleAnimationIn}
animationOut={animationOut ?? modalStyleAnimationOut}
useNativeDriver={useNativeDriverProp && useNativeDriver}
hideModalContentWhileAnimating={hideModalContentWhileAnimating}
animationInTiming={animationInTiming}
Expand Down