Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
54c2cc6
Wrap with a TestToolsGesture detector on dev only
neil-marcellini Mar 3, 2023
324f857
Merge branch 'main' into neil-test-tool-gesture
neil-marcellini Mar 3, 2023
4386786
Restore previous work
neil-marcellini Mar 3, 2023
ccdaf00
Add 4-tap gesture and move to ScreenWrapper
alexxxwork Apr 9, 2023
6bc8ad3
Fix trailing spaces, delete gesture detector
alexxxwork Apr 9, 2023
bf3b425
Add react-native-dev-menu item
alexxxwork Apr 10, 2023
57abc31
Fix lint issues, add necessary files
alexxxwork Apr 11, 2023
c0dc3c7
Fix lint issues
alexxxwork Apr 11, 2023
18844ee
Merge branch 'main' into neil-test-tool-gesture
alexxxwork Apr 11, 2023
be97a70
Add BaseScreenWrapper, CONST, TestTool action
alexxxwork Apr 11, 2023
b946971
Merge branch 'main' into neil-test-alex
alexxxwork Apr 11, 2023
9e947fc
Merge branch 'main' into neil-test-alex
alexxxwork Apr 11, 2023
6cc6f45
Fix lint issues
alexxxwork Apr 11, 2023
5a553ab
Fix more lint issues and withWindowDimensions
alexxxwork Apr 12, 2023
dba33d4
Fix more lint issues
alexxxwork Apr 12, 2023
2fac5ad
Fix import issue
alexxxwork Apr 12, 2023
414d29e
Merge branch 'main' into neil-test-alex
alexxxwork Apr 12, 2023
dc4d281
Update src/CONST.js
alexxxwork Apr 12, 2023
f7d923d
Update src/CONST.js
alexxxwork Apr 12, 2023
f2442f7
Fix CONST name
alexxxwork Apr 12, 2023
8808ed6
Move hocs to BaseScreenWrapper
alexxxwork Apr 12, 2023
afbb784
Fix copy, styling and props
alexxxwork Apr 13, 2023
b79e16b
Remove unused props
alexxxwork Apr 13, 2023
6f5d493
Merge branch 'main' into neil-test-tool-gesture
alexxxwork Apr 14, 2023
a18fa6c
Add CustomDevMenu, revert to ScreenWrapper
alexxxwork Apr 14, 2023
e5bcfcf
Fix lint issue
alexxxwork Apr 14, 2023
944fabd
Refactor CustomDevMenu and ScreenWrapper
alexxxwork Apr 14, 2023
cbff1f4
Minor change
alexxxwork Apr 14, 2023
547ca6c
Style fix in ScreenWrapper
alexxxwork Apr 14, 2023
5cd5d48
Merge branch 'main' into neil-test-tool-gesture
alexxxwork Apr 17, 2023
bf70370
Merge branch 'main' into neil-alex
alexxxwork Apr 19, 2023
77782f7
Add react-native-dev-menu to mocks
alexxxwork Apr 19, 2023
11b9f8c
Fix lint issue
alexxxwork Apr 19, 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
3 changes: 3 additions & 0 deletions __mocks__/react-native-dev-menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
addItem: jest.fn(),
};
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-plaid-link-sdk'
project(':react-native-plaid-link-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-plaid-link-sdk/android')
include ':react-native-dev-menu'
Comment thread
neil-marcellini marked this conversation as resolved.
Resolved
project(':react-native-dev-menu').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-dev-menu/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')
10 changes: 9 additions & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@ PODS:
- React-Core
- RNDeviceInfo (10.3.0):
- React-Core
- RNDevMenu (4.1.1):
- React-Core
- React-Core/DevSupport
- React-RCTNetwork
- RNFastImage (8.6.3):
- React-Core
- SDWebImage (~> 5.11.1)
Expand Down Expand Up @@ -793,6 +797,7 @@ DEPENDENCIES:
- "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
- "RNDateTimePicker (from `../node_modules/@react-native-community/datetimepicker`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
- RNDevMenu (from `../node_modules/react-native-dev-menu`)
- RNFastImage (from `../node_modules/react-native-fast-image`)
- "RNFBAnalytics (from `../node_modules/@react-native-firebase/analytics`)"
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
Expand Down Expand Up @@ -972,6 +977,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-community/datetimepicker"
RNDeviceInfo:
:path: "../node_modules/react-native-device-info"
RNDevMenu:
:path: "../node_modules/react-native-dev-menu"
RNFastImage:
:path: "../node_modules/react-native-fast-image"
RNFBAnalytics:
Expand Down Expand Up @@ -1095,6 +1102,7 @@ SPEC CHECKSUMS:
RNCPicker: 0b65be85fe7954fbb2062ef079e3d1cde252d888
RNDateTimePicker: 7658208086d86d09e1627b5c34ba0cf237c60140
RNDeviceInfo: 4701f0bf2a06b34654745053db0ce4cb0c53ada7
RNDevMenu: 72807568fe4188bd4c40ce32675d82434b43c45d
RNFastImage: 5c9c9fed9c076e521b3f509fe79e790418a544e8
RNFBAnalytics: f76bfa164ac235b00505deb9fc1776634056898c
RNFBApp: 729c0666395b1953198dc4a1ec6deb8fbe1c302e
Expand All @@ -1115,4 +1123,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: cd132e281e9e3d7e6ec2c99c08e6ec32b37886f8

COCOAPODS: 1.11.3
COCOAPODS: 1.12.0
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"react-native-blob-util": "^0.16.2",
"react-native-collapsible": "^1.6.0",
"react-native-config": "^1.4.5",
"react-native-dev-menu": "^4.1.1",
"react-native-device-info": "^10.3.0",
"react-native-document-picker": "^8.0.0",
"react-native-fast-image": "git+https://github.com/Expensify/react-native-fast-image.git#afedf204bfc253d18f08fdcc5356a2bb82f6a87c",
Expand Down
10 changes: 10 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ const CONST = {
CONFIRM: 'confirm',
CENTERED: 'centered',
CENTERED_UNSWIPEABLE: 'centered_unswipeable',
CENTERED_SMALL: 'centered_small',
BOTTOM_DOCKED: 'bottom_docked',
POPOVER: 'popover',
RIGHT_DOCKED: 'right_docked',
Expand All @@ -492,6 +493,7 @@ const CONST = {
WARM: 'warm',
REPORT_ACTION_ITEM_LAYOUT_DEBOUNCE_TIME: 1500,
SHOW_LOADING_SPINNER_DEBOUNCE_TIME: 250,
TEST_TOOLS_MODAL_THROTTLE_TIME: 800,
TOOLTIP_SENSE: 1000,
TRIE_INITIALIZATION: 'trie_initialization',
COMMENT_LENGTH_DEBOUNCE_TIME: 500,
Expand Down Expand Up @@ -2199,9 +2201,17 @@ const CONST = {
SAMPLE_INPUT: '123456.789',
EXPECTED_OUTPUT: 'FCFA 123,457',
},

PATHS_TO_TREAT_AS_EXTERNAL: [
'NewExpensify.dmg',
],

// Test tool menu parameters
TEST_TOOL: {
// Number of concurrent taps to open then the Test modal menu
NUMBER_OF_TAPS: 4,
},

PAYPAL_SUPPORTED_CURRENCIES: [
'AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF',
'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP',
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ export default {
// Is Keyboard shortcuts modal open?
IS_SHORTCUTS_MODAL_OPEN: 'isShortcutsModalOpen',

// Is the test tools modal open?
IS_TEST_TOOLS_MODAL_OPEN: 'isTestToolsModalOpen',

// Stores information about active wallet transfer amount, selectedAccountID, status, etc
WALLET_TRANSFER: 'walletTransfer',

Expand Down
5 changes: 5 additions & 0 deletions src/components/CustomDevMenu/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const CustomDevMenu = () => {};

CustomDevMenu.displayName = 'CustomDevMenu';

export default CustomDevMenu;
15 changes: 15 additions & 0 deletions src/components/CustomDevMenu/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {useEffect} from 'react';
import DevMenu from 'react-native-dev-menu';
import toggleTestToolsModal from '../../libs/actions/TestTool';

const CustomDevMenu = () => {
useEffect(() => {
DevMenu.addItem('Open Test Preferences', toggleTestToolsModal);
}, []);

return null;
};

CustomDevMenu.displayName = 'CustomDevMenu';

export default CustomDevMenu;
18 changes: 16 additions & 2 deletions src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Keyboard, View} from 'react-native';
import {Keyboard, View, PanResponder} from 'react-native';
import React from 'react';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
Expand All @@ -12,17 +12,26 @@ import HeaderGap from '../HeaderGap';
import OfflineIndicator from '../OfflineIndicator';
import compose from '../../libs/compose';
import withNavigation from '../withNavigation';
import withWindowDimensions from '../withWindowDimensions';
import ONYXKEYS from '../../ONYXKEYS';
import {withNetwork} from '../OnyxProvider';
import {propTypes, defaultProps} from './propTypes';
import SafeAreaConsumer from '../SafeAreaConsumer';
import TestToolsModal from '../TestToolsModal';
import withKeyboardState from '../withKeyboardState';
import withWindowDimensions from '../withWindowDimensions';
import withEnvironment from '../withEnvironment';
import toggleTestToolsModal from '../../libs/actions/TestTool';
import CustomDevMenu from '../CustomDevMenu';

class ScreenWrapper extends React.Component {
constructor(props) {
super(props);

this.panResponder = PanResponder.create({
onStartShouldSetPanResponderCapture: (e, gestureState) => gestureState.numberActiveTouches === CONST.TEST_TOOL.NUMBER_OF_TAPS,
onPanResponderRelease: toggleTestToolsModal,
});

this.state = {
didScreenTransitionEnd: false,
};
Expand Down Expand Up @@ -108,9 +117,13 @@ class ScreenWrapper extends React.Component {
styles.flex1,
paddingStyle,
]}
// eslint-disable-next-line react/jsx-props-no-spreading
{...(this.props.environment === CONST.ENVIRONMENT.DEV ? this.panResponder.panHandlers : {})}
>
<KeyboardAvoidingView style={[styles.w100, styles.h100, {maxHeight: this.props.windowHeight}]} behavior={this.props.keyboardAvoidingViewBehavior}>
<HeaderGap />
{(this.props.environment === CONST.ENVIRONMENT.DEV) && <TestToolsModal />}
{(this.props.environment === CONST.ENVIRONMENT.DEV) && <CustomDevMenu />}
{// If props.children is a function, call it to provide the insets to the children.
_.isFunction(this.props.children)
? this.props.children({
Expand All @@ -137,6 +150,7 @@ ScreenWrapper.defaultProps = defaultProps;

export default compose(
withNavigation,
withEnvironment,
Comment thread
alexxxwork marked this conversation as resolved.
Resolved
withWindowDimensions,
withKeyboardState,
withOnyx({
Expand Down
5 changes: 4 additions & 1 deletion src/components/ScreenWrapper/propTypes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import {windowDimensionsPropTypes} from '../withWindowDimensions';
Comment thread
alexxxwork marked this conversation as resolved.
Resolved
import {environmentPropTypes} from '../withEnvironment';
Comment thread
alexxxwork marked this conversation as resolved.
Resolved

const propTypes = {
/** Array of additional styles to add */
Expand All @@ -17,7 +18,7 @@ const propTypes = {
/** Whether to include padding top */
includePaddingTop: PropTypes.bool,

// Called when navigated Screen's transition is finished. It does not fire when user exit the page.
/** Called when navigated Screen's transition is finished. It does not fire when user exit the page. */
onEntryTransitionEnd: PropTypes.func,

/** The behavior to pass to the KeyboardAvoidingView, requires some trial and error depending on the layout/devices used.
Expand All @@ -34,6 +35,8 @@ const propTypes = {
shouldDismissKeyboardBeforeClose: PropTypes.bool,

...windowDimensionsPropTypes,

...environmentPropTypes,
};

const defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TestToolMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const defaultProps = {

const TestToolMenu = props => (
<>
<Text style={[styles.textLabelSupporting, styles.mb2, styles.mt6]} numberOfLines={1}>
<Text style={[styles.textLabelSupporting, styles.mb4]} numberOfLines={1}>
Test Preferences
</Text>

Expand Down
2 changes: 1 addition & 1 deletion src/components/TestToolRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const propTypes = {
};

const TestToolRow = props => (
<View style={[styles.flexRow, styles.mb6, styles.justifyContentBetween, styles.alignItemsCenter]}>
<View style={[styles.flexRow, styles.mb6, styles.justifyContentBetween, styles.alignItemsCenter, styles.mnw120]}>
<View style={styles.flex2}>
<Text>
{props.title}
Expand Down
51 changes: 51 additions & 0 deletions src/components/TestToolsModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import {View} from 'react-native';
import ONYXKEYS from '../ONYXKEYS';
import Modal from './Modal';
import CONST from '../CONST';
import toggleTestToolsModal from '../libs/actions/TestTool';
import TestToolMenu from './TestToolMenu';
import styles from '../styles/styles';

const propTypes = {
/** Details about modal */
modal: PropTypes.shape({
/** Indicates when an Alert modal is about to be visible */
willAlertModalBecomeVisible: PropTypes.bool,
}),

/** Whether the test tools modal is open */
isTestToolsModalOpen: PropTypes.bool,
};

const defaultProps = {
modal: {},
isTestToolsModalOpen: false,
};

const TestToolsModal = props => (
<Modal
isVisible={props.isTestToolsModalOpen}
type={CONST.MODAL.MODAL_TYPE.CENTERED_SMALL}
onClose={toggleTestToolsModal}
>
<View style={[styles.settingsPageBody, styles.p5]}>
<TestToolMenu />
</View>
</Modal>
);

TestToolsModal.propTypes = propTypes;
TestToolsModal.defaultProps = defaultProps;
TestToolsModal.displayName = 'TestToolsModal';

export default withOnyx({
modal: {
key: ONYXKEYS.MODAL,
},
isTestToolsModalOpen: {
key: ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN,
},
})(TestToolsModal);
22 changes: 22 additions & 0 deletions src/libs/actions/TestTool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import ONYXKEYS from '../../ONYXKEYS';
import CONST from '../../CONST';

let isTestToolsModalOpen = false;
Onyx.connect({
key: ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN,
callback: val => isTestToolsModalOpen = val || false,
});

/**
* Toggle the test tools modal open or closed.
* Throttle the toggle to make the modal stay open if you accidentally tap an extra time, which is easy to do.
*/
function toggleTestToolsModal() {
const toggle = () => Onyx.set(ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN, !isTestToolsModalOpen);
const throttledToggle = _.throttle(toggle, CONST.TIMING.TEST_TOOLS_MODAL_THROTTLE_TIME);
throttledToggle();
}

export default toggleTestToolsModal;
31 changes: 31 additions & 0 deletions src/styles/getModalStyles/getBaseModalStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,37 @@ export default (type, windowDimensions, popoverAnchorPosition = {}, innerContain
shouldAddTopSafeAreaPadding = isSmallScreenWidth;
shouldAddBottomSafeAreaPadding = false;
break;
case CONST.MODAL.MODAL_TYPE.CENTERED_SMALL:
// A centered modal that takes up the minimum possible screen space on all devices
modalStyle = {
...modalStyle,
...{
alignItems: 'center',
},
};
modalContainerStyle = {
// Shadow Styles
shadowColor: themeColors.shadow,
shadowOffset: {
width: 0,
height: 0,
},
shadowOpacity: 0.1,
shadowRadius: 5,

borderRadius: 12,
borderWidth: 0,
};

// Allow this modal to be dismissed with a swipe down or swipe right
swipeDirection = ['down', 'right'];
animationIn = 'fadeIn';
animationOut = 'fadeOut';
shouldAddTopSafeAreaMargin = false;
shouldAddBottomSafeAreaMargin = false;
shouldAddTopSafeAreaPadding = false;
shouldAddBottomSafeAreaPadding = false;
break;
case CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED:
modalStyle = {
...modalStyle,
Expand Down
4 changes: 4 additions & 0 deletions src/styles/utilities/sizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default {
minWidth: '25%',
},

mnw120: {
minWidth: 120,
},

w50: {
width: '50%',
},
Expand Down