-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [IOPAE-1142] Added featured carousels in
ServicesHomeScreen
(#…
…5793) ## Short description This PR refactors the `ServicesHomeScreen` screen by adding the featured services and the featured institutions carousels. <details open><summary>Details</summary> <p> | New services tab | | - | | <video src="https://github.com/pagopa/io-app/assets/29163287/6602ddc9-da5a-49d1-b61c-c21dbd7cc642" width="300"/> | </p> </details> ## List of changes proposed in this pull request - Added `CardPressableBase` component - Updated carousels by adding the `CardPressableBase` component - Updated `ServicesHomeScreen` screen to display the national institutions and featured carousels - Updated locales ## How to test Using `io-dev-api-server`, navigate to the services tab. Check that the screen is displayed correctly
- Loading branch information
Showing
17 changed files
with
2,610 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
ts/features/services/common/components/CardPressableBase.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from "react"; | ||
import { Pressable } from "react-native"; | ||
import Animated from "react-native-reanimated"; | ||
import { PressableBaseProps, WithTestID } from "@pagopa/io-app-design-system"; | ||
import { useSpringPressScaleAnimation } from "../../../../components/ui/utils/hooks/useSpringPressScaleAnimation"; | ||
|
||
type CardPressableBaseProps = WithTestID<PressableBaseProps>; | ||
|
||
export const CardPressableBase = ({ | ||
onPress, | ||
testID, | ||
accessibilityLabel, | ||
children | ||
}: React.PropsWithChildren<CardPressableBaseProps>) => { | ||
const { onPressIn, onPressOut, animatedScaleStyle } = | ||
useSpringPressScaleAnimation(); | ||
|
||
if (onPress === undefined) { | ||
return <>{children}</>; | ||
} | ||
|
||
return ( | ||
<Pressable | ||
onPress={onPress} | ||
testID={testID} | ||
accessible={true} | ||
accessibilityLabel={accessibilityLabel} | ||
onPressIn={onPressIn} | ||
onPressOut={onPressOut} | ||
onTouchEnd={onPressOut} | ||
> | ||
<Animated.View style={animatedScaleStyle}>{children}</Animated.View> | ||
</Pressable> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
ts/features/services/home/components/FeaturedInstitutionList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { useCallback, useMemo } from "react"; | ||
import { ListItemHeader, VSpacer } from "@pagopa/io-app-design-system"; | ||
import { Institution } from "../../../../../definitions/services/Institution"; | ||
import I18n from "../../../../i18n"; | ||
import { useIONavigation } from "../../../../navigation/params/AppParamsList"; | ||
import { useIODispatch, useIOSelector } from "../../../../store/hooks"; | ||
import { useOnFirstRender } from "../../../../utils/hooks/useOnFirstRender"; | ||
import { SERVICES_ROUTES } from "../../common/navigation/routes"; | ||
import { featuredInstitutionsGet } from "../store/actions"; | ||
import { | ||
featuredInstitutionsSelector, | ||
isErrorFeaturedInstitutionsSelector, | ||
isLoadingFeaturedInstitutionsSelector | ||
} from "../store/reducers"; | ||
import { | ||
FeaturedInstitutionsCarousel, | ||
FeaturedInstitutionsCarouselSkeleton | ||
} from "./FeaturedInstitutionsCarousel"; | ||
|
||
export const FeaturedInstitutionList = () => { | ||
const dispatch = useIODispatch(); | ||
const navigation = useIONavigation(); | ||
|
||
const featuredInstitutions = useIOSelector(featuredInstitutionsSelector); | ||
const isError = useIOSelector(isErrorFeaturedInstitutionsSelector); | ||
const isLoading = useIOSelector(isLoadingFeaturedInstitutionsSelector); | ||
|
||
useOnFirstRender(() => dispatch(featuredInstitutionsGet.request())); | ||
|
||
const handlePress = useCallback( | ||
({ fiscal_code, name }: Institution) => { | ||
navigation.navigate(SERVICES_ROUTES.SERVICES_NAVIGATOR, { | ||
screen: SERVICES_ROUTES.INSTITUTION_SERVICES, | ||
params: { | ||
institutionId: fiscal_code, | ||
institutionName: name | ||
} | ||
}); | ||
}, | ||
[navigation] | ||
); | ||
|
||
const mappedFeaturedInstitutions = useMemo( | ||
() => | ||
featuredInstitutions.map(props => ({ | ||
...props, | ||
onPress: () => handlePress(props) | ||
})), | ||
[featuredInstitutions, handlePress] | ||
); | ||
|
||
const isVisible = useMemo( | ||
() => isLoading || mappedFeaturedInstitutions.length > 0, | ||
[isLoading, mappedFeaturedInstitutions] | ||
); | ||
|
||
if (isError || !isVisible) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<ListItemHeader | ||
label={I18n.t("services.home.featured.institutions.title")} | ||
/> | ||
{isLoading ? ( | ||
<FeaturedInstitutionsCarouselSkeleton /> | ||
) : ( | ||
<FeaturedInstitutionsCarousel | ||
institutions={mappedFeaturedInstitutions} | ||
/> | ||
)} | ||
<VSpacer size={24} /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.