diff --git a/packages/legacy/core/App/components/tour/AttachTourStep.tsx b/packages/legacy/core/App/components/tour/AttachTourStep.tsx index 52e3d395f5..a80d21061d 100644 --- a/packages/legacy/core/App/components/tour/AttachTourStep.tsx +++ b/packages/legacy/core/App/components/tour/AttachTourStep.tsx @@ -1,5 +1,5 @@ import React, { cloneElement, ReactElement, ReactNode, RefObject, useContext, useEffect, useRef } from 'react' -import { StyleProp, View } from 'react-native' +import { StyleProp, useWindowDimensions, View } from 'react-native' import { TourContext } from '../../contexts/tour/tour-context' import { TourID } from '../../types/tour' @@ -46,7 +46,7 @@ export interface AttachTourStepProps { */ export function AttachTourStep({ children, fill = false, index, tourID }: AttachTourStepProps): ReactElement { const { currentStep, currentTour, changeSpot } = useContext(TourContext) - + const { width: windowWidth, height: windowHeight } = useWindowDimensions() const childRef = useRef(null) useEffect(() => { @@ -55,7 +55,7 @@ export function AttachTourStep({ children, fill = false, index, tourID }: Att changeSpot({ height, width, x, y }) }) } - }, [changeSpot, currentTour, currentStep, index]) + }, [windowWidth, windowHeight, changeSpot, currentTour, currentStep, index]) const { style, ...rest } = children.props const childStyle = style ?? {} diff --git a/packages/legacy/core/App/components/tour/TourBox.tsx b/packages/legacy/core/App/components/tour/TourBox.tsx index 6d567c93ca..adfe7c7429 100644 --- a/packages/legacy/core/App/components/tour/TourBox.tsx +++ b/packages/legacy/core/App/components/tour/TourBox.tsx @@ -1,9 +1,9 @@ import React, { ReactElement, ReactNode, useCallback, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' -import { StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from 'react-native' +import { StyleSheet, Text, TouchableOpacity, View } from 'react-native' import Icon from 'react-native-vector-icons/MaterialIcons' -import { tourMargin, hitSlop } from '../../constants' +import { hitSlop } from '../../constants' import { useTheme } from '../../contexts/theme' import { RenderProps } from '../../contexts/tour/tour-context' import { testIdWithKey } from '../../utils/testable' @@ -74,7 +74,6 @@ export function TourBox(props: TourBoxProps): ReactElement { stepsOutOf, } = props const { TextTheme, ColorPallet, OnboardingTheme } = useTheme() - const { width } = useWindowDimensions() const iconSize = 30 const dismissIconName = 'clear' const iconColor = ColorPallet.notification.infoIcon @@ -89,7 +88,7 @@ export function TourBox(props: TourBoxProps): ReactElement { borderRadius: 5, borderWidth: 1, padding: 20, - width: width - tourMargin * 2, + flex: 1, margin: 'auto', }, headerContainer: { diff --git a/packages/legacy/core/App/components/tour/TourOverlay.tsx b/packages/legacy/core/App/components/tour/TourOverlay.tsx index 77981532e9..22f8dfa066 100644 --- a/packages/legacy/core/App/components/tour/TourOverlay.tsx +++ b/packages/legacy/core/App/components/tour/TourOverlay.tsx @@ -24,7 +24,7 @@ interface TourOverlayProps { export const TourOverlay = (props: TourOverlayProps) => { const { width: windowWidth, height: windowHeight } = useWindowDimensions() const { color, currentTour, currentStep, onBackdropPress, backdropOpacity, changeSpot, spot, tourStep } = props - + const [viewBox, setViewBox] = useState(`0 0 ${windowWidth} ${windowHeight}`) const { next, previous, start, stop } = useContext(TourContext) const [tooltipStyle, setTooltipStyle] = useState({}) @@ -52,11 +52,12 @@ export const TourOverlay = (props: TourOverlayProps) => { const gapBetweenSpotAndTooltip = 50 // if origin spot (ie. no spotlight) if (spot.x === 0 && spot.y === 0) { - const top = windowHeight / 5 + // a relative margin so that the tooltip doesn't start at the very top of the screen + const oneSixthOfScreenHeight = windowHeight / 6 setTooltipStyle({ left: tourMargin, right: tourMargin, - top, + top: oneSixthOfScreenHeight, }) // if spot is in the lower half of the screen } else if (spot.y >= windowHeight / 2) { @@ -75,7 +76,13 @@ export const TourOverlay = (props: TourOverlayProps) => { top, }) } - }, [spot.height, spot.width, spot.x, spot.y]) + }, [windowWidth, windowHeight, spot.width, spot.height, spot.x, spot.y]) + + useEffect(() => { + // + 1 pixel to account for an svg size rounding issue that would cause + // a tiny gap around the overlay + setViewBox(`0 0 ${windowWidth + 1} ${windowHeight + 1}`) + }, [windowWidth, windowHeight]) return ( { transparent={true} visible={currentStep !== undefined} > - + - - + + - + diff --git a/packages/legacy/core/__tests__/components/__snapshots__/TourOverlay.test.tsx.snap b/packages/legacy/core/__tests__/components/__snapshots__/TourOverlay.test.tsx.snap index 6309515cca..10acb8e6d7 100644 --- a/packages/legacy/core/__tests__/components/__snapshots__/TourOverlay.test.tsx.snap +++ b/packages/legacy/core/__tests__/components/__snapshots__/TourOverlay.test.tsx.snap @@ -12,18 +12,18 @@ Array [ @@ -92,7 +92,7 @@ Array [ @@ -113,7 +113,7 @@ Array [ "opacity": 1, "position": "absolute", "right": 25, - "top": 266.8, + "top": 222.33333333333334, } } testID="com.ariesbifold:id/SpotTooltip"