From 4383161119549ce2f8f76b24ce6c7dbe421e7e78 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 22 Dec 2020 11:58:48 -0500 Subject: [TMA-345] Sticky Taggs Bar (#146) * sticks taggs bar to top while scrolling * used animated value for top padding Co-authored-by: Shravya Ramesh --- src/components/profile/Content.tsx | 1 + src/components/taggs/TaggsBar.tsx | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index 7064f775..71e4f195 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -271,6 +271,7 @@ const Content: React.FC = ({y, userXId, screenType}) => { bounces={shouldBounce} showsVerticalScrollIndicator={false} scrollEventThrottle={1} + stickyHeaderIndices={[4]} refreshControl={ }> diff --git a/src/components/taggs/TaggsBar.tsx b/src/components/taggs/TaggsBar.tsx index 795797ef..76833d65 100644 --- a/src/components/taggs/TaggsBar.tsx +++ b/src/components/taggs/TaggsBar.tsx @@ -1,6 +1,7 @@ -import React, {useEffect, useState} from 'react'; +import React, {Fragment, useEffect, useState} from 'react'; import {StyleSheet} from 'react-native'; import Animated from 'react-native-reanimated'; +import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {useDispatch, useSelector} from 'react-redux'; import { INTEGRATED_SOCIAL_LIST, @@ -8,10 +9,10 @@ import { SOCIAL_LIST, } from '../../constants'; import {getLinkedSocials} from '../../services'; -import Tagg from './Tagg'; +import {loadIndividualSocial, updateSocial} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {ScreenType} from '../../types'; -import {loadIndividualSocial, updateSocial} from '../../store/actions'; +import Tagg from './Tagg'; const {View, ScrollView, interpolate, Extrapolate} = Animated; interface TaggsBarProps { @@ -109,9 +110,19 @@ const TaggsBar: React.FC = ({ outputRange: [0, 0.2], extrapolate: Extrapolate.CLAMP, }); + const paddingTop: Animated.Node = interpolate(y, { + inputRange: [ + PROFILE_CUTOUT_BOTTOM_Y + + profileBodyHeight - + (useSafeAreaInsets().top + 10), + PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight, + ], + outputRange: [10, useSafeAreaInsets().top], + extrapolate: Extrapolate.CLAMP, + }); return taggs.length > 0 ? ( - + = ({ ) : ( - + ); }; @@ -132,7 +143,6 @@ const styles = StyleSheet.create({ shadowOffset: {width: 0, height: 2}, zIndex: 1, paddingBottom: 5, - paddingTop: 10, }, contentContainer: { alignItems: 'center', -- cgit v1.2.3-70-g09d2