import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import React, {useEffect} from 'react'; import {ScrollView, StatusBar, StyleSheet, View} from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; import { AvatarTitle, SocialMediaInfo, TabsGradient, TaggPost, TwitterTaggPost, } from '../../components'; import {AVATAR_GRADIENT} from '../../constants'; import {AuthContext, ProfileContext, ProfileStackParams} from '../../routes'; import {SimplePostType, TwitterPostType} from '../../types'; import {AvatarHeaderHeight, SCREEN_HEIGHT} from '../../utils'; type SocialMediaTaggsRouteProp = RouteProp< ProfileStackParams, 'SocialMediaTaggs' >; type SocialMediaTaggsNavigationProp = StackNavigationProp< ProfileStackParams, 'SocialMediaTaggs' >; interface SocialMediaTaggsProps { route: SocialMediaTaggsRouteProp; navigation: SocialMediaTaggsNavigationProp; } const SocialMediaTaggs: React.FC = ({ route, navigation, }) => { const {socialMediaType, isProfileView} = route.params; const context = isProfileView ? React.useContext(ProfileContext) : React.useContext(AuthContext); const { profile: {name}, socialAccounts, } = context; let accountData = socialAccounts[socialMediaType]; /** * Skip setting the header while defining routes and instead let the component itself handle it. * This lets us pass props dynamically to the header. */ useEffect(() => { navigation.setOptions({ headerTitle: () => { return ; }, headerStyle: {height: AvatarHeaderHeight}, }); }, [isProfileView, navigation]); return ( {/* Cropping the scroll view to mimic the presence of a header while preserving the gradient background */} {(accountData?.posts as Array< SimplePostType | TwitterPostType >).map((post, index) => socialMediaType === 'Twitter' ? ( ) : ( ), )} ); }; const styles = StyleSheet.create({ contentContainer: { paddingBottom: SCREEN_HEIGHT / 15, }, flex: { flex: 1, }, }); export default SocialMediaTaggs;