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

fix: 25709 drop container does not add opacity to entire height of the drawer #26849

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export default {

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

setIsDraggingOver: PropTypes.func,
tienifr marked this conversation as resolved.
Show resolved Hide resolved
};
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
3 changes: 2 additions & 1 deletion src/components/HeaderGap/index.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styles from '../../styles/styles';

export default class HeaderGap extends PureComponent {
render() {
return <View style={styles.headerGap} />;
// eslint-disable-next-line react/prop-types
tienifr marked this conversation as resolved.
Show resolved Hide resolved
return <View style={[styles.headerGap, ...this.props.styles]} />;
}
}
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
Loading