NTP-7917 | PR comments resolved

This commit is contained in:
Aman Chaturvedi
2024-11-12 17:43:50 +05:30
parent 7faf744ac1
commit 7fe396cf70
9 changed files with 32 additions and 49 deletions

View File

@@ -30,7 +30,7 @@ module.exports = {
}, },
], ],
'jest-hoist', 'jest-hoist',
'react-native-reanimated/plugin' 'react-native-reanimated/plugin',
], ],
env: { env: {
production: { production: {

View File

@@ -57,6 +57,7 @@ const AnimatedRenderMask: React.FC<IAnimatedRenderMask> = ({ maskRect }) => {
], ],
})); }));
// TODO: Can use for ripple animation in future
// const animatedRectProps = useAnimatedProps(() => { // const animatedRectProps = useAnimatedProps(() => {
// const animatedExpansion = interpolate(rippleAnimation.value, [0, 1], [0, 10]); // const animatedExpansion = interpolate(rippleAnimation.value, [0, 1], [0, 10]);
// return { // return {
@@ -94,6 +95,7 @@ const AnimatedRenderMask: React.FC<IAnimatedRenderMask> = ({ maskRect }) => {
opacity={0.8} opacity={0.8}
/> />
</G> </G>
{/* Can use this for ripple animation in future */}
{/* <AnimatedRect {/* <AnimatedRect
x={highlightAreaX} x={highlightAreaX}
y={highlightAreaY} y={highlightAreaY}

View File

@@ -136,6 +136,8 @@ export const CopilotModal = forwardRef<CopilotModalHandle, CopilotOptions>(funct
return null; return null;
} }
const showMask = containerVisible && maskRect;
return ( return (
<ModalWrapperForAlfredV2 <ModalWrapperForAlfredV2
animationType="none" animationType="none"
@@ -143,8 +145,8 @@ export const CopilotModal = forwardRef<CopilotModalHandle, CopilotOptions>(funct
style={{ backgroundColor: 'transparent' }} style={{ backgroundColor: 'transparent' }}
> >
<View style={styles.container}> <View style={styles.container}>
{containerVisible && maskRect ? <AnimatedRenderMask maskRect={maskRect} /> : null} {showMask ? <AnimatedRenderMask maskRect={maskRect} /> : null}
{containerVisible && maskRect ? ( {showMask ? (
<View style={[styles.tooltip, tooltipStyles, tooltipStyle]}> <View style={[styles.tooltip, tooltipStyles, tooltipStyle]}>
<TooltipComponent labels={labels} maskRect={maskRect} /> <TooltipComponent labels={labels} maskRect={maskRect} />
</View> </View>

View File

@@ -70,7 +70,7 @@ export const Tooltip: React.FC<ITooltip> = ({ labels }) => {
<View style={[GenericStyles.row, GenericStyles.mh12]}> <View style={[GenericStyles.row, GenericStyles.mh12]}>
<Button <Button
onPress={handleStop} onPress={handleStop}
title={isLastStep ? labels?.finish || 'Got it' : labels?.skip || 'Skip'} title={isLastStep ? labels?.finish : labels?.skip}
style={GenericStyles.mr10} style={GenericStyles.mr10}
buttonStyle={styles.nextBtn} buttonStyle={styles.nextBtn}
pressableWidthChange={false} pressableWidthChange={false}

View File

@@ -125,8 +125,6 @@ export const CopilotProvider = ({
[getFirstStep, moveModalToStep, scrollView, setCurrentStep, setVisibility, steps] [getFirstStep, moveModalToStep, scrollView, setCurrentStep, setVisibility, steps]
); );
console.log("currentStep", currentStep);
const stop = useCallback(async () => { const stop = useCallback(async () => {
await setVisibility(false); await setVisibility(false);
}, [setVisibility]); }, [setVisibility]);

View File

@@ -1,3 +1,4 @@
import { noop } from "@rn-ui-lib/utils/common";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
/** /**
@@ -6,7 +7,7 @@ import { useEffect, useRef, useState } from "react";
export const useStateWithAwait = <T = any>( export const useStateWithAwait = <T = any>(
initialState: T initialState: T
): [T, (newValue: T) => Promise<void>] => { ): [T, (newValue: T) => Promise<void>] => {
const endPending = useRef(() => {}); const endPending = useRef(noop);
const newDesiredValue = useRef(initialState); const newDesiredValue = useRef(initialState);
const [state, setState] = useState(initialState); const [state, setState] = useState(initialState);

View File

@@ -1,28 +1,26 @@
import { useCallback, useMemo, useReducer, useState } from "react"; import { useCallback, useMemo, useReducer, useState } from 'react';
import { type Step, type StepsMap } from "../types"; import { type Step, type StepsMap } from '../types';
type Action = type Action =
| { | {
type: "register"; type: 'register';
step: Step; step: Step;
} }
| { | {
type: "unregister"; type: 'unregister';
stepName: string; stepName: string;
}; };
export const useStepsMap = () => { export const useStepsMap = () => {
const [currentStep, setCurrentStepState] = useState<Step | undefined>( const [currentStep, setCurrentStepState] = useState<Step | undefined>(undefined);
undefined
);
const [steps, dispatch] = useReducer((state: StepsMap, action: Action) => { const [steps, dispatch] = useReducer((state: StepsMap, action: Action) => {
switch (action.type) { switch (action.type) {
case "register": case 'register':
return { return {
...state, ...state,
[action.step.name]: action.step, [action.step.name]: action.step,
}; };
case "unregister": { case 'unregister': {
const { [action.stepName]: _, ...rest } = state; const { [action.stepName]: _, ...rest } = state;
return rest; return rest;
} }
@@ -36,15 +34,9 @@ export const useStepsMap = () => {
[steps] [steps]
); );
console.log("orderedSteps", orderedSteps);
const stepIndex = useCallback( const stepIndex = useCallback(
(step = currentStep) => (step = currentStep) =>
step step ? orderedSteps.findIndex((stepCandidate) => stepCandidate.order === step.order) : -1,
? orderedSteps.findIndex(
(stepCandidate) => stepCandidate.order === step.order
)
: -1,
[currentStep, orderedSteps] [currentStep, orderedSteps]
); );
@@ -55,13 +47,6 @@ export const useStepsMap = () => {
const totalStepsNumber = useMemo(() => orderedSteps.length, [orderedSteps]); const totalStepsNumber = useMemo(() => orderedSteps.length, [orderedSteps]);
const getFirstStep = useCallback(() => orderedSteps[0], [orderedSteps]);
const getLastStep = useCallback(
() => orderedSteps[orderedSteps.length - 1],
[orderedSteps]
);
const getPrevStep = useCallback( const getPrevStep = useCallback(
(step = currentStep) => step && orderedSteps[stepIndex(step) - 1], (step = currentStep) => step && orderedSteps[stepIndex(step) - 1],
[currentStep, stepIndex, orderedSteps] [currentStep, stepIndex, orderedSteps]
@@ -72,31 +57,24 @@ export const useStepsMap = () => {
[currentStep, stepIndex, orderedSteps] [currentStep, stepIndex, orderedSteps]
); );
const getNthStep = useCallback( const getNthStep = useCallback((n: number) => orderedSteps[n - 1], [orderedSteps]);
(n: number) => orderedSteps[n - 1],
[orderedSteps]
);
const isFirstStep = useMemo( const getFirstStep = useCallback(() => getNthStep(1), [orderedSteps]);
() => currentStep === getFirstStep(),
[currentStep, getFirstStep]
);
const isLastStep = useMemo( const getLastStep = useCallback(() => getNthStep(orderedSteps.length), [orderedSteps]);
() => currentStep === getLastStep(),
[currentStep, getLastStep] const isFirstStep = useMemo(() => currentStep === getFirstStep(), [currentStep, getFirstStep]);
);
const isLastStep = useMemo(() => currentStep === getLastStep(), [currentStep, getLastStep]);
const registerStep = useCallback((step: Step) => { const registerStep = useCallback((step: Step) => {
dispatch({ type: "register", step }); dispatch({ type: 'register', step });
}, []); }, []);
const unregisterStep = useCallback((stepName: string) => { const unregisterStep = useCallback((stepName: string) => {
dispatch({ type: "unregister", stepName }); dispatch({ type: 'unregister', stepName });
}, []); }, []);
console.log("steps", steps);
return { return {
currentStepNumber, currentStepNumber,
totalStepsNumber, totalStepsNumber,

View File

@@ -90,7 +90,7 @@ export interface CopilotContextType {
export interface ITooltip { export interface ITooltip {
maskRect: LayoutRectangle; maskRect: LayoutRectangle;
labels?: Labels; labels: Labels;
} }
export interface IAnimatedRenderMask { export interface IAnimatedRenderMask {

View File

@@ -108,8 +108,9 @@ const FiltersContainer: React.FC<FilterContainerProps> = (props) => {
const handleOnClose = () => { const handleOnClose = () => {
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.AV_FILTERS_CLOSE_CLICKED); addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.AV_FILTERS_CLOSE_CLICKED);
copilot.start(); // TODO: For Yash Mantri to refer how to start the coach marks
//closeFilterModal(); // copilot.start();
closeFilterModal();
}; };
const handleOptionFilterChange = (value: string) => { const handleOptionFilterChange = (value: string) => {
@@ -188,6 +189,7 @@ const FiltersContainer: React.FC<FilterContainerProps> = (props) => {
}} }}
> >
{filters[filterGroupKey].filters[filterKey].displayText === 'Feedback' ? ( {filters[filterGroupKey].filters[filterKey].displayText === 'Feedback' ? (
// TODO: For Yash Mantri to refer how to start the coach marks
<CopilotStep <CopilotStep
order={1} order={1}
name="Bucket" name="Bucket"