Skip to content

Commit c8da63c

Browse files
authored
Merge pull request Expensify#77242 from software-mansion-labs/@GCyganek/gps/gps-tab
Add GPS tab to the Distance Request page
2 parents 1ff4def + d9099bb commit c8da63c

26 files changed

Lines changed: 125 additions & 14 deletions

File tree

src/CONST/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,6 +2885,7 @@ const CONST = {
28852885
PER_DIEM: 'per-diem',
28862886
DISTANCE_MAP: 'distance-map',
28872887
DISTANCE_MANUAL: 'distance-manual',
2888+
DISTANCE_GPS: 'distance-gps',
28882889
},
28892890
EXPENSE_TYPE: {
28902891
DISTANCE: 'distance',
@@ -2895,6 +2896,7 @@ const CONST = {
28952896
PENDING_EXPENSIFY_CARD: 'pendingExpensifyCard',
28962897
DISTANCE_MAP: 'distance-map',
28972898
DISTANCE_MANUAL: 'distance-manual',
2899+
DISTANCE_GPS: 'distance-gps',
28982900
},
28992901
REPORT_ACTION_TYPE: {
29002902
PAY: 'pay',
@@ -5457,6 +5459,7 @@ const CONST = {
54575459
PER_DIEM: 'per-diem',
54585460
DISTANCE_MAP: 'distance-map',
54595461
DISTANCE_MANUAL: 'distance-manual',
5462+
DISTANCE_GPS: 'distance-gps',
54605463
},
54615464

54625465
STATUS_TEXT_MAX_LENGTH: 100,

src/ROUTES.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,11 @@ const ROUTES = {
12561256
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backToReport?: string) =>
12571257
`${action as string}/${iouType as string}/start/${transactionID}/${reportID}/distance-new${backToReport ? `/${backToReport}` : ''}/distance-manual` as const,
12581258
},
1259+
DISTANCE_REQUEST_CREATE_TAB_GPS: {
1260+
route: 'distance-gps',
1261+
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string | undefined, reportID: string | undefined, backToReport?: string) =>
1262+
`${action as string}/${iouType as string}/start/${transactionID}/${reportID}/distance-new${backToReport ? `/${backToReport}` : ''}/distance-gps` as const,
1263+
},
12591264
IOU_SEND_ADD_BANK_ACCOUNT: 'pay/new/add-bank-account',
12601265
IOU_SEND_ADD_DEBIT_CARD: 'pay/new/add-debit-card',
12611266
IOU_SEND_ENABLE_PAYMENTS: 'pay/new/enable-payments',

src/SCREENS.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ const SCREENS = {
327327
DISTANCE_CREATE: 'Money_Request_Distance_Create',
328328
STEP_DISTANCE_MAP: 'Money_Request_Step_Distance_Map',
329329
STEP_DISTANCE_MANUAL: 'Money_Request_Step_Distance_Manual',
330+
STEP_DISTANCE_GPS: 'Money_Request_Step_Distance_GPS',
330331
RECEIPT_PREVIEW: 'Money_Request_Receipt_preview',
331332
},
332333

src/components/TabSelector/TabSelector.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {MaterialTopTabBarProps} from '@react-navigation/material-top-tabs';
22
import {TabActions} from '@react-navigation/native';
3-
import React, {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react';
3+
import React, {useCallback, useEffect, useLayoutEffect, useRef, useState} from 'react';
44
import {View} from 'react-native';
5+
import type {TupleToUnion} from 'type-fest';
56
import FocusTrapContainerElement from '@components/FocusTrap/FocusTrapContainerElement';
67
// eslint-disable-next-line no-restricted-imports
78
import * as Expensicons from '@components/Icon/Expensicons';
@@ -43,8 +44,10 @@ type IconTitleAndTestID = {
4344
testID?: string;
4445
};
4546

47+
const MEMOIZED_LAZY_TAB_SELECTOR_ICONS = ['CalendarSolid', 'UploadAlt', 'User', 'Car', 'Hashtag', 'Map', 'Pencil', 'Crosshair'] as const;
48+
4649
function getIconTitleAndTestID(
47-
icons: Record<'CalendarSolid' | 'UploadAlt' | 'User' | 'Car' | 'Hashtag' | 'Map' | 'Pencil', IconAsset>,
50+
icons: Record<TupleToUnion<typeof MEMOIZED_LAZY_TAB_SELECTOR_ICONS>, IconAsset>,
4851
route: string,
4952
translate: LocaleContextProps['translate'],
5053
): IconTitleAndTestID {
@@ -75,6 +78,8 @@ function getIconTitleAndTestID(
7578
return {icon: icons.Map, title: translate('tabSelector.map'), testID: 'distanceMap'};
7679
case CONST.TAB_REQUEST.DISTANCE_MANUAL:
7780
return {icon: icons.Pencil, title: translate('tabSelector.manual'), testID: 'distanceManual'};
81+
case CONST.TAB_REQUEST.DISTANCE_GPS:
82+
return {icon: icons.Crosshair, title: translate('tabSelector.gps'), testID: 'distanceGPS'};
7883
default:
7984
throw new Error(`Route ${route} has no icon nor title set.`);
8085
}
@@ -91,11 +96,11 @@ function TabSelector({
9196
renderProductTrainingTooltip,
9297
equalWidth = false,
9398
}: TabSelectorProps) {
94-
const icons = useMemoizedLazyExpensifyIcons(['CalendarSolid', 'UploadAlt', 'User', 'Car', 'Hashtag', 'Map', 'Pencil']);
99+
const icons = useMemoizedLazyExpensifyIcons(MEMOIZED_LAZY_TAB_SELECTOR_ICONS);
95100
const {translate} = useLocalize();
96101
const theme = useTheme();
97102
const styles = useThemeStyles();
98-
const defaultAffectedAnimatedTabs = useMemo(() => Array.from({length: state.routes.length}, (v, i) => i), [state.routes.length]);
103+
const defaultAffectedAnimatedTabs = Array.from({length: state.routes.length}, (v, i) => i);
99104
const [affectedAnimatedTabs, setAffectedAnimatedTabs] = useState(defaultAffectedAnimatedTabs);
100105
const viewRef = useRef<View>(null);
101106
const [selectorWidth, setSelectorWidth] = React.useState(0);

src/languages/de.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ const translations: TranslationDeepObject<typeof en> = {
10361036
manual: 'Manuell',
10371037
scan: 'Scannen',
10381038
map: 'Karte',
1039+
gps: 'GPS',
10391040
},
10401041
spreadsheet: {
10411042
upload: 'Eine Tabellenkalkulation hochladen',

src/languages/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ const translations = {
10181018
manual: 'Manual',
10191019
scan: 'Scan',
10201020
map: 'Map',
1021+
gps: 'GPS',
10211022
},
10221023
spreadsheet: {
10231024
upload: 'Upload a spreadsheet',

src/languages/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ const translations: TranslationDeepObject<typeof en> = {
698698
manual: 'Manual',
699699
scan: 'Escanear',
700700
map: 'Map',
701+
gps: 'GPS',
701702
},
702703
spreadsheet: {
703704
upload: 'Importar',

src/languages/fr.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ const translations: TranslationDeepObject<typeof en> = {
10381038
manual: 'Manuel',
10391039
scan: 'Scanner',
10401040
map: 'Carte',
1041+
gps: 'GPS',
10411042
},
10421043
spreadsheet: {
10431044
upload: 'Téléverser une feuille de calcul',

src/languages/it.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ const translations: TranslationDeepObject<typeof en> = {
10341034
manual: 'Manuale',
10351035
scan: 'Scannerizza',
10361036
map: 'Mappa',
1037+
gps: 'GPS',
10371038
},
10381039
spreadsheet: {
10391040
upload: 'Carica un foglio di calcolo',

src/languages/ja.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ const translations: TranslationDeepObject<typeof en> = {
10341034
manual: '手動',
10351035
scan: 'スキャン',
10361036
map: '地図',
1037+
gps: 'GPS',
10371038
},
10381039
spreadsheet: {
10391040
upload: 'スプレッドシートをアップロード',

0 commit comments

Comments
 (0)