Skip to content

Commit

Permalink
Merge pull request #26849 from tienifr/fix/25709
Browse files Browse the repository at this point in the history
fix: 25709 drop container does not add opacity to entire height of the drawer
  • Loading branch information
AndrewGable authored Sep 8, 2023
2 parents caab10f + 809d56c commit 153ab36
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export default {

/** Should this dropZone be disabled? */
isDisabled: PropTypes.bool,

/** Indicate that users are dragging file or not */
setIsDraggingOver: PropTypes.func,
};
8 changes: 6 additions & 2 deletions src/components/DragAndDrop/Provider/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'underscore';
import React, {useRef, useCallback} from 'react';
import React, {useRef, useCallback, useEffect} from 'react';
import {View} from 'react-native';
import {PortalHost} from '@gorhom/portal';
import Str from 'expensify-common/lib/str';
Expand All @@ -17,7 +17,7 @@ function shouldAcceptDrop(event) {
return _.some(event.dataTransfer.types, (type) => type === 'Files');
}

function DragAndDropProvider({children, isDisabled = false}) {
function DragAndDropProvider({children, isDisabled = false, setIsDraggingOver = () => {}}) {
const dropZone = useRef(null);
const dropZoneID = useRef(Str.guid('drag-n-drop'));

Expand All @@ -33,6 +33,10 @@ function DragAndDropProvider({children, isDisabled = false}) {
isDisabled,
});

useEffect(() => {
setIsDraggingOver(isDraggingOver);
}, [isDraggingOver, setIsDraggingOver]);

return (
<DragAndDropContext.Provider value={{isDraggingOver, setOnDropHandler, dropZoneID: dropZoneID.current}}>
<View
Expand Down
17 changes: 15 additions & 2 deletions src/components/HeaderGap/index.desktop.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import React, {PureComponent} from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../styles/styles';

export default class HeaderGap extends PureComponent {
const propTypes = {
/** Styles to apply to the HeaderGap */
// eslint-disable-next-line react/forbid-prop-types
styles: PropTypes.arrayOf(PropTypes.object),
};

class HeaderGap extends PureComponent {
render() {
return <View style={styles.headerGap} />;
return <View style={[styles.headerGap, ...this.props.styles]} />;
}
}

HeaderGap.propTypes = propTypes;
HeaderGap.defaultProps = {
styles: [],
};
export default HeaderGap;
2 changes: 1 addition & 1 deletion src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ScreenWrapper extends React.Component {
style={styles.flex1}
enabled={this.props.shouldEnablePickerAvoiding}
>
<HeaderGap />
<HeaderGap styles={this.props.headerGapStyles} />
{this.props.environment === CONST.ENVIRONMENT.DEV && <TestToolsModal />}
{this.props.environment === CONST.ENVIRONMENT.DEV && <CustomDevMenu />}
{
Expand Down
4 changes: 4 additions & 0 deletions src/components/ScreenWrapper/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const propTypes = {
/** Whether to use the maxHeight (true) or use the 100% of the height (false) */
shouldEnableMaxHeight: PropTypes.bool,

/** Array of additional styles for header gap */
headerGapStyles: PropTypes.arrayOf(PropTypes.object),

...windowDimensionsPropTypes,

...environmentPropTypes,
Expand All @@ -59,6 +62,7 @@ const defaultProps = {
shouldEnablePickerAvoiding: true,
shouldShowOfflineIndicator: true,
offlineIndicatorStyle: [],
headerGapStyles: [],
};

export {propTypes, defaultProps};
19 changes: 17 additions & 2 deletions src/pages/iou/MoneyRequestSelectorPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {withOnyx} from 'react-native-onyx';
import {View} from 'react-native';
import React from 'react';
import React, {useState} from 'react';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import ONYXKEYS from '../../ONYXKEYS';
Expand All @@ -21,6 +21,7 @@ import OnyxTabNavigator, {TopTab} from '../../libs/Navigation/OnyxTabNavigator';
import NewRequestAmountPage from './steps/NewRequestAmountPage';
import reportPropTypes from '../reportPropTypes';
import * as ReportUtils from '../../libs/ReportUtils';
import themeColors from '../../styles/themes/default';

const propTypes = {
/** React Navigation route */
Expand Down Expand Up @@ -48,6 +49,8 @@ const defaultProps = {
};

function MoneyRequestSelectorPage(props) {
const [isDraggingOver, setIsDraggingOver] = useState(false);

const iouType = lodashGet(props.route, 'params.iouType', '');
const reportID = lodashGet(props.route, 'params.reportID', '');
const {translate} = useLocalize();
Expand All @@ -70,10 +73,22 @@ function MoneyRequestSelectorPage(props) {
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableKeyboardAvoidingView={false}
headerGapStyles={
isDraggingOver
? [
{
backgroundColor: themeColors.receiptDropUIBG,
},
]
: []
}
>
{({safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView shouldShow={!IOUUtils.isValidMoneyRequestType(iouType)}>
<DragAndDropProvider isDisabled={props.selectedTab !== CONST.TAB.SCAN}>
<DragAndDropProvider
isDisabled={props.selectedTab !== CONST.TAB.SCAN}
setIsDraggingOver={setIsDraggingOver}
>
<View style={[styles.flex1, safeAreaPaddingBottomStyle]}>
<HeaderWithBackButton
title={title[iouType]}
Expand Down

0 comments on commit 153ab36

Please sign in to comment.