Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 22 additions & 7 deletions src/screens/UserAAuthorizedScreens/ClimateFeedScreen.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,13 +9,26 @@ 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<ClimateFeedStackParams, 'ClimateFeedScreen'>;

function ClimateFeedScreen({ navigation }: Props) {
const apiClient = useApiClient();
const sessionId = useAppSelector((state) => state.auth.sessionId);
const [climateFeed, setClimateFeed] = useState<ClimateEffect[]>();
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 });
Expand All @@ -26,20 +39,22 @@ function ClimateFeedScreen({ navigation }: Props) {
}, [sessionId]);

if (climateFeed === undefined) {
return <ActivityIndicator size='large' color='black' style={{ marginTop: 100 }} />;
return <ActivityIndicator size="large" color="black" style={{ marginTop: 100 }} />;
}

return (
<Screen view="View">
<Section style={{ paddingVertical: 0 }}>
<Content style={{ alignItems: 'stretch' }}>
<FlatList
onScroll={handleScroll}
ListHeaderComponent={
<>
<CmTypography variant='h1' style={styles.heading}>Explore climate change impacts</CmTypography>
<CmTypography variant='body' style={styles.text}>
This is your personalized homepage based on your unique climate personality. Check out
these articles to stay informed!
<CmTypography variant="h1" style={styles.heading}>
Explore climate change impacts
</CmTypography>
<CmTypography variant="body" style={styles.text}>
This is your personalized homepage based on your unique climate personality. Check out these articles to stay informed!
</CmTypography>
</>
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/hooks/useCmTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function useCmTooltip(fadeAnim: Animated.Value | Animated.ValueXY) {
activeTooltipIndex,
toggleTooltip,
handleCardPress,
fadeOut,
};
}

Expand Down