From 76d6009d65a7e119d640f4184d53e13389374d45 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Sun, 3 Sep 2023 18:47:15 +0200 Subject: [PATCH 1/3] Add multiple waypoints are visible on smaller screens --- src/components/DistanceRequest.js | 14 +++++++++++--- src/styles/styles.js | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/DistanceRequest.js b/src/components/DistanceRequest.js index ce6b9880a82c..d88aaed85100 100644 --- a/src/components/DistanceRequest.js +++ b/src/components/DistanceRequest.js @@ -1,4 +1,4 @@ -import React, {useEffect, useMemo, useState} from 'react'; +import React, {useEffect, useMemo, useState, useRef} from 'react'; import {ScrollView, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; @@ -82,12 +82,14 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) const reportID = lodashGet(report, 'reportID', ''); const waypoints = useMemo(() => lodashGet(transaction, 'comment.waypoints', {}), [transaction]); + const previousWaypoints = usePrevious(waypoints); const numberOfWaypoints = _.size(waypoints); + const numberOfPreviousWaypoints = _.size(previousWaypoints); + const scrollViewRef = useRef(null); const lastWaypointIndex = numberOfWaypoints - 1; const isLoadingRoute = lodashGet(transaction, 'comment.isLoading', false); const hasRouteError = lodashHas(transaction, 'errorFields.route'); - const previousWaypoints = usePrevious(waypoints); const haveWaypointsChanged = !_.isEqual(previousWaypoints, waypoints); const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates'); const shouldFetchRoute = (!doesRouteExist || haveWaypointsChanged) && !isLoadingRoute && TransactionUtils.validateWaypoints(waypoints); @@ -167,9 +169,15 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) onLayout={(event = {}) => setScrollContainerHeight(lodashGet(event, 'nativeEvent.layout.height', 0))} > setScrollContentHeight(height)} + onContentSizeChange={(width, height) => { + if (scrollContentHeight < height && numberOfWaypoints > numberOfPreviousWaypoints) { + scrollViewRef.current.scrollToEnd({animated: true}); + } + setScrollContentHeight(height); + }} onScroll={updateGradientVisibility} scrollEventThrottle={16} + ref={scrollViewRef} > {_.map(waypoints, (waypoint, key) => { // key is of the form waypoint0, waypoint1, ... diff --git a/src/styles/styles.js b/src/styles/styles.js index 8d033a22e16a..7c8c12c4a6c8 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3862,7 +3862,7 @@ const styles = { distanceRequestContainer: (maxHeight) => ({ ...flex.flexShrink2, - minHeight: variables.baseMenuItemHeight, + minHeight: variables.baseMenuItemHeight * 2, maxHeight, }), From 2bb2fcc9f6901706d8f463d6bbb444d20f9ab6d7 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Sun, 3 Sep 2023 19:50:47 +0200 Subject: [PATCH 2/3] Fix bug with error banner --- src/components/DistanceRequest.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/DistanceRequest.js b/src/components/DistanceRequest.js index d88aaed85100..618ab552ff31 100644 --- a/src/components/DistanceRequest.js +++ b/src/components/DistanceRequest.js @@ -215,14 +215,14 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) colors={[theme.transparent, theme.modalBackground]} /> )} - {hasRouteError && ( - - )} + {hasRouteError && ( + + )}