diff --git a/src/components/CopilotModal.js b/src/components/CopilotModal.js index 00a610fa..890ebd46 100644 --- a/src/components/CopilotModal.js +++ b/src/components/CopilotModal.js @@ -5,6 +5,7 @@ import Tooltip from './Tooltip'; import StepNumber from './StepNumber'; import styles, { MARGIN, ARROW_SIZE, STEP_NUMBER_DIAMETER, STEP_NUMBER_RADIUS } from './style'; import type { SvgMaskPathFn } from '../types'; +import { Dimensions } from 'react-native'; type Props = { stop: () => void, @@ -20,6 +21,7 @@ type Props = { tooltipComponent: ?React$Component, tooltipStyle?: Object, stepNumberComponent: ?React$Component, + stepCountInTooltip: any, overlay: 'svg' | 'view', animated: boolean, androidStatusBarVisible: boolean, @@ -49,7 +51,9 @@ class CopilotModal extends Component { animationDuration: 400, tooltipComponent: Tooltip, tooltipStyle: {}, + arrowConfiguration: {}, stepNumberComponent: StepNumber, + stepCountInTooltip: {}, // If react-native-svg native module was avaialble, use svg as the default overlay component overlay: typeof NativeModules.RNSVGSvgViewManager !== 'undefined' ? 'svg' : 'view', // If animated was not specified, rely on the default overlay type @@ -134,30 +138,45 @@ class CopilotModal extends Component { const verticalPosition = relativeToBottom > relativeToTop ? 'bottom' : 'top'; const horizontalPosition = relativeToLeft > relativeToRight ? 'left' : 'right'; - + const { arrowSize ,color ,position } = this.props.arrowConfiguration; const tooltip = {}; const arrow = {}; - if (verticalPosition === 'bottom') { - tooltip.top = obj.top + obj.height + MARGIN; - arrow.borderBottomColor = this.props.arrowColor; - arrow.top = tooltip.top - (ARROW_SIZE * 2); + tooltip.top = obj.top + obj.height + (arrowSize === 'large' ? 18 : MARGIN); + arrow.borderBottomColor = color || '#fff'; + arrow.top = tooltip.top - (arrowSize === 'large' ? 28 : ARROW_SIZE * 2); } else { - tooltip.bottom = layout.height - (obj.top - MARGIN); - arrow.borderTopColor = this.props.arrowColor; - arrow.bottom = tooltip.bottom - (ARROW_SIZE * 2); + tooltip.bottom = layout.height - (obj.top - (arrowSize === 'large' ? 18 : MARGIN)); + arrow.borderTopColor = color || '#fff'; + arrow.bottom = tooltip.bottom - (arrowSize === 'large' ? 24 : ARROW_SIZE * 2); + } if (horizontalPosition === 'left') { tooltip.right = Math.max(layout.width - (obj.left + obj.width), 0); tooltip.right = tooltip.right === 0 ? tooltip.right + MARGIN : tooltip.right; tooltip.maxWidth = layout.width - tooltip.right - MARGIN; - arrow.right = tooltip.right + MARGIN; - } else { + if(Dimensions.get('window').width - tooltip.maxWidth < 40 ) + { + if(position === 'center'){ + arrow.right = Math.round( tooltip.maxWidth/2); + } + else arrow.right = tooltip.right + MARGIN; + } + else arrow.right = tooltip.right + MARGIN; + } + else { tooltip.left = Math.max(obj.left, 0); tooltip.left = tooltip.left === 0 ? tooltip.left + MARGIN : tooltip.left; tooltip.maxWidth = layout.width - tooltip.left - MARGIN; - arrow.left = tooltip.left + MARGIN; + if(Dimensions.get('window').width - tooltip.maxWidth < 40 ) + { + if(position === 'center'){ + arrow.left = Math.round( tooltip.maxWidth/2); + } + else arrow.left = tooltip.left + MARGIN + } + else arrow.left = tooltip.left + MARGIN } const animate = { @@ -262,10 +281,11 @@ class CopilotModal extends Component { const { tooltipComponent: TooltipComponent, stepNumberComponent: StepNumberComponent, + stepCountInTooltip : { enable,marginRight,marginTop } } = this.props; return [ - { }, ]} > - , - , - + , + + {enable && 0 ? marginTop : 5 : 5, + zIndex: Math.pow(10,6) + }, + ]} + > + + } + { this.modal = modal; }} />