Skip to content

Commit

Permalink
Merge branch 'andrew-scan' into simplify-global-create-menu-material-…
Browse files Browse the repository at this point in the history
…top-tab2
  • Loading branch information
MaciejSWM committed Aug 1, 2023
2 parents 3624178 + 20cce36 commit 7b4da52
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -2548,10 +2548,10 @@ const CONST = {
},
TAB: {
RECEIPT_TAB_ID: 'ReceiptTab',
TAB_MANUAL: 'manual',
TAB_SCAN: 'scan',
TAB_NEW_CHAT: 'chat',
TAB_NEW_ROOM: 'room',
MANUAL: 'manual',
SCAN: 'scan',
NEW_CHAT: 'chat',
NEW_ROOM: 'room',
},
};

Expand Down
8 changes: 4 additions & 4 deletions src/components/TabSelector/TabSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ const defaultProps = {

const getIcon = (route) => {
switch (route) {
case CONST.TAB.TAB_MANUAL:
case CONST.TAB.MANUAL:
return Expensicons.Pencil;
case CONST.TAB.TAB_SCAN:
case CONST.TAB.SCAN:
return Expensicons.Receipt;
case CONST.TAB.TAB_NEW_CHAT:
case CONST.TAB.NEW_CHAT:
return Expensicons.User;
case CONST.TAB.TAB_NEW_ROOM:
case CONST.TAB.NEW_ROOM:
return Expensicons.Hashtag;
default:
return Expensicons.DotIndicator
Expand Down
7 changes: 3 additions & 4 deletions src/libs/Navigation/OnyxTabNavigator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import Tab from '../actions/Tab';
import ONYXKEYS from '../../ONYXKEYS';
Expand All @@ -28,19 +27,19 @@ const TopTab = createMaterialTopTabNavigator();
function OnyxTabNavigator({id, selectedTab, children, ...rest}) {
return (
<TopTab.Navigator
/* eslint-disable-next-line react/jsx-props-no-spreading */
{...rest}
id={id}
initialRouteName={selectedTab}
screenListeners={{
state: (event) => {
const state = lodashGet(event, 'data.state', {});
const state = event.data.state;
const index = state.index;
const routeNames = state.routeNames;
Tab.setSelectedTab(id, routeNames[index]);
},
...(rest.screenListeners || {}),
}}
/* eslint-disable-next-line react/jsx-props-no-spreading */
{...rest}
>
{children}
</TopTab.Navigator>
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,6 @@ function setMoneyRequestReceipt(receiptPath, receiptSource) {
* @param {Object} iou
* @param {String} reportID
* @param {Object} report
* @param {Object} currentUserPersonalDetails
*/
function navigateToNextPage(iou, reportID, report) {
const moneyRequestID = `${iou.iouType}${reportID}`;
Expand Down Expand Up @@ -1533,7 +1532,6 @@ function navigateToNextPage(iou, reportID, report) {
* @param {Object} iou
* @param {String} reportID
* @param {Object} report
* @param {Object} currentUserPersonalDetails
*/
function onReceiptImageSelected(file, iou, reportID, report) {
if (!ReceiptUtils.isValidReceipt(file)) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/NewChatSelectorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ function NewChatSelectorPage(props) {
)}
>
<TopTab.Screen
name={CONST.TAB.TAB_NEW_CHAT}
name={CONST.TAB.NEW_CHAT}
component={NewChatPage}
/>
<TopTab.Screen
name={CONST.TAB.TAB_NEW_ROOM}
name={CONST.TAB.NEW_ROOM}
component={WorkspaceNewRoomPage}
/>
</TopTab.Navigator>
Expand Down
17 changes: 9 additions & 8 deletions src/pages/iou/MoneyRequestSelectorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const defaultProps = {
currency: CONST.CURRENCY.USD,
participants: [],
},
selectedTab: CONST.TAB.TAB_MANUAL,
selectedTab: CONST.TAB.MANUAL,
};

function MoneyRequestSelectorPage(props) {
Expand All @@ -82,7 +82,7 @@ function MoneyRequestSelectorPage(props) {
[CONST.IOU.MONEY_REQUEST_TYPE.SPLIT]: translate('iou.splitBill'),
};

const onTabPress = () => {
const resetMoneyRequestInfo = () => {
const moneyRequestID = `${iouType.current}${reportID.current}`;
IOU.resetMoneyRequestInfo(moneyRequestID, iouType.current);
};
Expand All @@ -91,36 +91,37 @@ function MoneyRequestSelectorPage(props) {
<FullPageNotFoundView shouldShow={!IOUUtils.isValidMoneyRequestType(iouType.current)}>
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
{({safeAreaPaddingBottomStyle}) => (
<DragAndDropProvider isDisabled={props.selectedTab === CONST.TAB.TAB_MANUAL}>
<DragAndDropProvider isDisabled={props.selectedTab === CONST.TAB.MANUAL}>
<View style={[styles.flex1, safeAreaPaddingBottomStyle]}>
<HeaderWithBackButton
title={title[iouType.current]}
onBackButtonPress={() => Navigation.goBack()}
/>
{Permissions.canUseScanReceipts(props.betas) && (
{Permissions.canUseScanReceipts(props.betas) ? (
<OnyxTabNavigator
id={CONST.TAB.RECEIPT_TAB_ID}
tabBar={({state, navigation}) => (
<TabSelector
state={state}
navigation={navigation}
onTabPress={onTabPress}
onTabPress={resetMoneyRequestInfo}
/>
)}
>
<TopTab.Screen
name={CONST.TAB.TAB_MANUAL}
name={CONST.TAB.MANUAL}
component={MoneyRequestAmount}
initialParams={{reportID: reportID.current}}
/>
<TopTab.Screen
name={CONST.TAB.TAB_SCAN}
name={CONST.TAB.SCAN}
component={ReceiptSelector}
initialParams={{reportID: reportID.current}}
/>
</OnyxTabNavigator>
) : (
!Permissions.canUseScanReceipts(props.betas) && <MoneyRequestAmount />
)}
{!Permissions.canUseScanReceipts(props.betas) && <MoneyRequestAmount />}
</View>
</DragAndDropProvider>
)}
Expand Down

0 comments on commit 7b4da52

Please sign in to comment.