diff --git a/package-lock.json b/package-lock.json index f880a86f..f1816583 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6373,13 +6373,13 @@ "version": "15.7.12", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz", "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==", - "devOptional": true + "dev": true }, "node_modules/@types/react": { "version": "18.2.73", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.73.tgz", "integrity": "sha512-XcGdod0Jjv84HOC7N5ziY3x+qL0AfmubvKOZ9hJjJ2yd5EE+KYjWhdOjt387e9HPheHkdggF9atTifMRtyAaRA==", - "devOptional": true, + "dev": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -7703,7 +7703,7 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", - "devOptional": true + "dev": true }, "node_modules/dag-map": { "version": "1.0.2", diff --git a/src/screens/UserAAuthorizedScreens/ClimateFeedScreen.tsx b/src/screens/UserAAuthorizedScreens/ClimateFeedScreen.tsx index 92906662..3f47c0b6 100644 --- a/src/screens/UserAAuthorizedScreens/ClimateFeedScreen.tsx +++ b/src/screens/UserAAuthorizedScreens/ClimateFeedScreen.tsx @@ -1,5 +1,5 @@ -import { useEffect, useState } from 'react'; -import { ActivityIndicator, FlatList, StyleSheet, View } from 'react-native'; +import { useEffect, useRef, useState } from 'react'; +import { ActivityIndicator, Animated, Dimensions, FlatList, StyleSheet, View } from 'react-native'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import { ClimateFeedStackParams } from 'src/navigation/Stacks/ClimateFeedStack'; @@ -9,6 +9,7 @@ import ClimateEffect from 'src/types/ClimateEffect'; import { CmTypography, Screen, Content, Section } from '@shared/components'; import { ClimateFeedCard } from '@features/climate-feed/components'; import { useAppSelector } from 'src/store/hooks'; +import { useCmTooltip } from 'src/shared/hooks'; type Props = NativeStackScreenProps; @@ -16,6 +17,18 @@ function ClimateFeedScreen({ navigation }: Props) { const apiClient = useApiClient(); const sessionId = useAppSelector((state) => state.auth.sessionId); const [climateFeed, setClimateFeed] = useState(); + const fadeAnim = useRef(new Animated.Value(0)).current; + const { fadeOut } = useCmTooltip(fadeAnim); + + const handleScroll = (event: { nativeEvent: { contentOffset: { y: number } } }) => { + // Set the threshold for scrolling + const threshold = Dimensions.get('window').height; + // Check if the user has scrolled beyond the threshold + if (event.nativeEvent.contentOffset.y > threshold) { + // Fade out the tooltip + fadeOut(); + } + }; function gotoDetailsScreen(climateEffect: ClimateEffect) { navigation.navigate('ClimateDetailsScreen', { climateEffect }); @@ -26,7 +39,7 @@ function ClimateFeedScreen({ navigation }: Props) { }, [sessionId]); if (climateFeed === undefined) { - return ; + return ; } return ( @@ -34,12 +47,14 @@ function ClimateFeedScreen({ navigation }: Props) {
- Explore climate change impacts - - This is your personalized homepage based on your unique climate personality. Check out - these articles to stay informed! + + Explore climate change impacts + + + This is your personalized homepage based on your unique climate personality. Check out these articles to stay informed! } diff --git a/src/shared/hooks/useCmTooltip.tsx b/src/shared/hooks/useCmTooltip.tsx index e2ed9eed..b778f397 100644 --- a/src/shared/hooks/useCmTooltip.tsx +++ b/src/shared/hooks/useCmTooltip.tsx @@ -40,6 +40,7 @@ function useCmTooltip(fadeAnim: Animated.Value | Animated.ValueXY) { activeTooltipIndex, toggleTooltip, handleCardPress, + fadeOut, }; }