diff --git a/App/Container/Navi-Insurance/Styles/index.ts b/App/Container/Navi-Insurance/Styles/index.ts index a1bb5140d3..41ba0fd397 100644 --- a/App/Container/Navi-Insurance/Styles/index.ts +++ b/App/Container/Navi-Insurance/Styles/index.ts @@ -1,4 +1,10 @@ import { StyleSheet } from "react-native"; +import { SharedValue, useAnimatedStyle } from "react-native-reanimated"; +import Colors from "../../../../assets/colors/colors"; +import { + CommonHeaderShadowStyleProperties, + INITIAL_Y_VALUE, +} from "../../../common/constants"; export const commonStyles = StyleSheet.create({ container: { @@ -34,10 +40,41 @@ export const commonStyles = StyleSheet.create({ height54: { height: 54, }, + height108: { + height: 108, + }, height8: { height: 8, }, flexStart: { alignItems: "flex-start", }, + ctaButton: { + height: 54, + flex: 1, + }, + width16: { + width: 16, + }, }); + +export const commonHeaderShadowStyle = ( + derivedY: Readonly>, +) => { + return useAnimatedStyle(() => { + const isScrolled = derivedY.value > INITIAL_Y_VALUE; + + return { + shadowColor: isScrolled ? Colors.black : Colors.transparent, + shadowOpacity: isScrolled + ? CommonHeaderShadowStyleProperties.SHADOW_OPACITY + : CommonHeaderShadowStyleProperties.INITIAL_SHADOW_OPACITY, + shadowRadius: isScrolled + ? CommonHeaderShadowStyleProperties.SHADOW_RADIUS + : CommonHeaderShadowStyleProperties.INITIAL_SHADOW_RADIUS, + elevation: isScrolled + ? CommonHeaderShadowStyleProperties.ELEVATION + : CommonHeaderShadowStyleProperties.INITIAL_ELEVATION, + }; + }); +}; diff --git a/App/Container/Navi-Insurance/screen/benefit-screen/BenefitScreen.tsx b/App/Container/Navi-Insurance/screen/benefit-screen/BenefitScreen.tsx index 79784b6ce1..b29178639a 100644 --- a/App/Container/Navi-Insurance/screen/benefit-screen/BenefitScreen.tsx +++ b/App/Container/Navi-Insurance/screen/benefit-screen/BenefitScreen.tsx @@ -1,41 +1,43 @@ import { useNavigation } from "@react-navigation/native"; import { useEffect } from "react"; -import { NativeScrollEvent, NativeSyntheticEvent, View } from "react-native"; +import { + BackHandler, + NativeScrollEvent, + NativeSyntheticEvent, + StatusBar, + View, +} from "react-native"; import Animated, { - useAnimatedStyle, useDerivedValue, useSharedValue, - withTiming, } from "react-native-reanimated"; -import { StyledImage, StyledText } from "../../../../../components/widgets"; -import BaseWidget from "../../../../../components/widgets/BaseWidget"; +import Colors from "../../../../../assets/colors/colors"; import { - BaseActionTypes, - GenericActionPayload, -} from "../../../../common/actions/GenericAction"; + CommonContentWidgets, + CommonFooter, +} from "../../../../../components/reusable"; +import { StyledImage, StyledText } from "../../../../../components/widgets"; +import { BaseActionTypes } from "../../../../common/actions/GenericAction"; import { AnalyticsEventNameConstants, AnalyticsFlowNameConstant, - AnalyticsMethodNameConstant, BENEFIT_SCREEN, ConstantCta, + HARDWARE_BACK_PRESS, INITIAL_Y_VALUE, - NAVIGATION_ERROR, - THRESHOLD_Y_BENEFIT, } from "../../../../common/constants"; -import { NaviLinearGradient } from "../../../../common/hooks/useGradient"; +import { sendAsAnalyticsEvent } from "../../../../common/hooks/useAnalyticsEvent"; import { AnalyticsEvent, CtaData } from "../../../../common/interface"; -import { Widget } from "../../../../common/interface/widgets/Widget"; import { BenefitScreenHeaderData } from "../../../../common/interface/widgets/widgetData"; import { BenefitScreenProps } from "../../../../common/interface/widgets/widgetData/BenefitScreenHeaderData"; import { ScreenState } from "../../../../common/screen/BaseScreen"; import { ScreenActionTypes } from "../../../../common/screen/ScreenActionTypes"; import { extractCtaParameters } from "../../../../common/utilities/CtaParamsUtils"; import { globalHandleClick } from "../../../../common/utilities/NavigationUtil"; -import GenericShimmerScreen from "../generic-shimmer-screen/GenericShimmerScreen"; +import { isValidHexColor } from "../../../../common/utilities/ValidateColors"; import QuoteOfferErrorScreen from "../quote-offer-screen/error-screen/QuoteOfferErrorScreen"; +import WaitingPeriodShimmerScreen from "../waiting-period-screen/shimmer-screen/WaitingPeriodShimmerScreen"; import styles from "./BenefitScreenStyles"; -import { sendAsAnalyticsEvent } from "../../../../common/hooks/useAnalyticsEvent"; const BenefitScreen = ({ ctaData, @@ -86,74 +88,67 @@ const BenefitScreen = ({ }); }, [ctaData]); - const headerStyle = useAnimatedStyle(() => { - return { - maxHeight: withTiming(derivedY.value > THRESHOLD_Y_BENEFIT ? 0 : 200, { - duration: derivedY.value > THRESHOLD_Y_BENEFIT ? 600 : 800, - }), - // Updating maxHeight to 0 when derivedY.value > 0 to hide the header icon - // and updating to 200 [> icon height] when derivedY.value <= 0 to show the header icon - opacity: withTiming(derivedY.value > THRESHOLD_Y_BENEFIT ? 0 : 1, { - duration: derivedY.value > THRESHOLD_Y_BENEFIT ? 600 : 800, - }), + let headerData = screenData?.screenWidgets?.headerWidgets?.at( + 0, + ) as BenefitScreenHeaderData; + let headerColor = isValidHexColor(headerData?.backgroundColor || "") + ? headerData?.backgroundColor + : Colors.white; + + const handleBackButtonClick = () => { + let backCta = headerData?.leftIcon?.cta; + handleClick && backCta && handleClick(backCta); + return true; + }; + + useEffect(() => { + BackHandler.addEventListener(HARDWARE_BACK_PRESS, handleBackButtonClick); + return () => { + BackHandler.removeEventListener( + HARDWARE_BACK_PRESS, + handleBackButtonClick, + ); }; - }); + }, [screenData]); const Header = () => { let headerData = screenData?.screenWidgets?.headerWidgets?.at( 0, ) as BenefitScreenHeaderData; return ( - THRESHOLD_Y_BENEFIT - ? headerData?.scrolledGradient - : headerData?.defaultGradient - } - > - - - - {headerData?.leftIcon && ( - - )} - {headerData?.title && ( - - )} - {headerData?.rightIcon ? ( - - ) : ( - - )} - - {headerData?.subtitle && ( - - )} - {} - {headerData?.description?.url && ( - - - - )} - - - + + + {headerData?.leftIcon && ( + + )} + {headerData?.title && ( + + )} + {headerData?.rightIcon ? ( + + ) : ( + + )} + + {headerData?.subtitle && ( + + )} + + ); }; - const Footer = () => { + const TopSection = () => { return ( - - {getWidgetViews( - screenData?.screenWidgets?.footerWidgets, - handleActions, - screenData?.screenState, - handleClick, + + + {headerData?.description?.url && ( + + + )} ); @@ -191,7 +186,7 @@ const BenefitScreen = ({ }, [screenData?.screenState]); if (screenData?.screenState === ScreenState.LOADING) { - return ; + return ; } if (screenData?.screenState === ScreenState.ERROR) { @@ -210,6 +205,7 @@ const BenefitScreen = ({ return ( +
- {getWidgetViews( - screenData?.screenWidgets?.contentWidgets, - handleActions, - screenData?.screenState, - handleClick, - )} + + -