From 8fce513f63e58b5dc58ada323be04bfd1c654252 Mon Sep 17 00:00:00 2001 From: Frederik Batuna Date: Fri, 18 Oct 2024 17:39:26 +0200 Subject: [PATCH] chore: [PE-678] CGN partner detail change go to website from button to list item (#6300) ## Short description CGN partner detail change go to website from button to list item. ## List of changes proposed in this pull request - remove bottom button - update translation files - add list item with same behavior as button had ## How to test - login into the app - go to cgn card brought wallet (add it if necessary) - go to opportunities list - trough categories list or partner list go to a partner detail screen - check if the new design at the bottom of the screen ![image-20240917-152239](https://github.com/user-attachments/assets/7cfb8b6a-0a66-41b0-a7f9-3bc36f5ec2d3) --- locales/en/index.yml | 2 +- locales/it/index.yml | 2 +- .../merchants/CgnMerchantDetailScreen.tsx | 224 +++++++----------- 3 files changed, 88 insertions(+), 140 deletions(-) diff --git a/locales/en/index.yml b/locales/en/index.yml index 34529d22731..75c565e21ec 100644 --- a/locales/en/index.yml +++ b/locales/en/index.yml @@ -2717,7 +2717,7 @@ bonus: description: Description contactInfo: Addresses cta: - website: Go to partner's website + website: Visit the partner's website categories: counting: and other {{count}} cultureAndEntertainment: Culture and entertainment diff --git a/locales/it/index.yml b/locales/it/index.yml index 3463f58c649..a72b72be972 100644 --- a/locales/it/index.yml +++ b/locales/it/index.yml @@ -2717,7 +2717,7 @@ bonus: description: Descrizione contactInfo: Contatti e informazioni cta: - website: Vai al sito del partner + website: Visita il sito del partner categories: counting: e altre {{count}} cultureAndEntertainment: Cultura e tempo libero diff --git a/ts/features/bonus/cgn/screens/merchants/CgnMerchantDetailScreen.tsx b/ts/features/bonus/cgn/screens/merchants/CgnMerchantDetailScreen.tsx index df7626d04f0..f8978172d2d 100644 --- a/ts/features/bonus/cgn/screens/merchants/CgnMerchantDetailScreen.tsx +++ b/ts/features/bonus/cgn/screens/merchants/CgnMerchantDetailScreen.tsx @@ -1,27 +1,22 @@ import { ContentWrapper, - GradientBottomActions, + Divider, GradientScrollView, H1, - IOSpacer, - IOSpacingScale, IOToast, IOVisualCostants, + ListItemAction, ListItemHeader, ListItemInfo, - VSpacer, - buttonSolidHeight + VSpacer } from "@pagopa/io-app-design-system"; import Placeholder from "rn-placeholder"; import { Route, useRoute } from "@react-navigation/native"; import * as React from "react"; import { useCallback, useEffect, useMemo } from "react"; import Animated, { - Easing, useAnimatedScrollHandler, - useAnimatedStyle, - useSharedValue, - withTiming + useSharedValue } from "react-native-reanimated"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { @@ -31,7 +26,6 @@ import { StyleSheet, View } from "react-native"; -import { Address } from "../../../../../../definitions/cgn/merchants/Address"; import { Discount } from "../../../../../../definitions/cgn/merchants/Discount"; import { Merchant } from "../../../../../../definitions/cgn/merchants/Merchant"; import { isReady } from "../../../../../common/model/RemoteValue"; @@ -51,15 +45,10 @@ export type CgnMerchantDetailScreenNavigationParams = Readonly<{ const scrollTriggerOffsetValue: number = 88; -const gradientSafeArea: IOSpacingScale = 80; -const contentEndMargin: IOSpacingScale = 32; -const spaceBetweenActions: IOSpacer = 24; - const CgnMerchantDetailScreen = () => { // ------- hooks const safeAreaInsets = useSafeAreaInsets(); - const gradientOpacity = useSharedValue(1); const scrollTranslationY = useSharedValue(0); const [titleHeight, setTitleHeight] = React.useState(0); @@ -76,7 +65,7 @@ const CgnMerchantDetailScreen = () => { dispatch(cgnSelectedMerchant.request(merchantID)); }, [merchantID, dispatch]); - const bottomMargin: number = React.useMemo( + const paddingBottom: number = React.useMemo( () => safeAreaInsets.bottom === 0 ? IOVisualCostants.appMarginDefault @@ -84,16 +73,6 @@ const CgnMerchantDetailScreen = () => { [safeAreaInsets] ); - const safeBottomAreaHeight: number = React.useMemo( - () => bottomMargin + buttonSolidHeight + contentEndMargin, - [bottomMargin] - ); - - const gradientAreaHeight: number = React.useMemo( - () => bottomMargin + buttonSolidHeight + gradientSafeArea, - [bottomMargin] - ); - useEffect(loadMerchantDetail, [loadMerchantDetail]); // ------- utils/logic @@ -115,19 +94,10 @@ const CgnMerchantDetailScreen = () => { } }; - const scrollHandler = useAnimatedScrollHandler( - ({ contentOffset, layoutMeasurement, contentSize }) => { - // eslint-disable-next-line functional/immutable-data - scrollTranslationY.value = contentOffset.y; - - const isEndReached = - Math.floor(layoutMeasurement.height + contentOffset.y) >= - Math.floor(contentSize.height); - - // eslint-disable-next-line functional/immutable-data - gradientOpacity.value = isEndReached ? 0 : 1; - } - ); + const scrollHandler = useAnimatedScrollHandler(({ contentOffset }) => { + // eslint-disable-next-line functional/immutable-data + scrollTranslationY.value = contentOffset.y; + }); const getTitleHeight = (event: LayoutChangeEvent) => { const { height } = event.nativeEvent.layout; @@ -148,89 +118,86 @@ const CgnMerchantDetailScreen = () => { } }); - const footerCta = (url: string) => ({ - label: I18n.t("bonus.cgn.merchantDetail.cta.website"), - onPress: () => handlePressMerchantWebsite(url) - }); - - const footerGradientOpacityTransition = useAnimatedStyle(() => ({ - opacity: withTiming(gradientOpacity.value, { - duration: 200, - easing: Easing.ease - }) - })); - - const footerComponent = isReady(merchantDetail) && - merchantDetail.value.websiteUrl && ( - 0; + + const showGotToWebsite = + isReady(merchantDetail) && merchantDetail.value.websiteUrl !== undefined; + + if (isReady(merchantDetail)) { + return ( + - ); - - return ( - <> - {isReady(merchantDetail) ? ( - <> - - - {merchantDetail.value.imageUrl !== undefined && ( - - - - - )} -

{merchantDetail.value.name}

- - - {renderDiscountsList(merchantDetail.value.discounts)} - - + + {merchantDetail.value.imageUrl !== undefined && ( + + - {renderMerchantAddressesList( - merchantDetail.value.addresses, - merchantDetail.value.allNationalAddresses - )} - - -
- {footerComponent} - - ) : ( - - - - )} - - ); + + )} +

{merchantDetail.value.name}

+ + + {renderDiscountsList(merchantDetail.value.discounts)} + + + + {(showAddresses || showGotToWebsite) && ( + + )} + {showGotToWebsite && ( + + handlePressMerchantWebsite(merchantDetail.value.websiteUrl) + } + /> + )} + {showGotToWebsite && showAddresses && } + {merchantDetail.value.addresses?.map((address, index) => ( + + ))} + + +
+ ); + } else { + return ( + + + + ); + } }; // ------------------------ render utils @@ -258,25 +225,6 @@ const CgnMerchantDetailScreenSkeleton = () => ( ); -const renderMerchantAddressesList = ( - addresses: ReadonlyArray
| undefined, - isAllNationalAddressMerchant: boolean -) => - addresses !== undefined && addresses.length > 0 ? ( - <> - - {addresses.map((address, index) => ( - - ))} - - ) : null; - // ------------------------ styles - consts - export const styles = StyleSheet.create({