aboutsummaryrefslogtreecommitdiff
path: root/src/components/taggs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/taggs')
-rw-r--r--src/components/taggs/TaggPostFooter.tsx2
-rw-r--r--src/components/taggs/TaggsBar.tsx93
2 files changed, 43 insertions, 52 deletions
diff --git a/src/components/taggs/TaggPostFooter.tsx b/src/components/taggs/TaggPostFooter.tsx
index ae9d889d..750f1793 100644
--- a/src/components/taggs/TaggPostFooter.tsx
+++ b/src/components/taggs/TaggPostFooter.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import {Linking, StyleSheet, View} from 'react-native';
+import {StyleSheet, View} from 'react-native';
import {Text} from 'react-native-animatable';
import {handleOpenSocialUrlOnBrowser} from '../../utils';
import {DateLabel} from '../common';
diff --git a/src/components/taggs/TaggsBar.tsx b/src/components/taggs/TaggsBar.tsx
index a87da3e2..87dabc3d 100644
--- a/src/components/taggs/TaggsBar.tsx
+++ b/src/components/taggs/TaggsBar.tsx
@@ -1,12 +1,16 @@
-import React, {Fragment, useEffect, useState} from 'react';
+import React, {useEffect, useState} from 'react';
import {StyleSheet} from 'react-native';
-import Animated from 'react-native-reanimated';
-import {useSafeAreaInsets} from 'react-native-safe-area-context';
+import Animated, {
+ useDerivedValue,
+ interpolate,
+ Extrapolate,
+ useAnimatedStyle,
+} from 'react-native-reanimated';
import {useDispatch, useSelector, useStore} from 'react-redux';
import {
INTEGRATED_SOCIAL_LIST,
- PROFILE_CUTOUT_BOTTOM_Y,
SOCIAL_LIST,
+ PROFILE_CUTOUT_BOTTOM_Y,
} from '../../constants';
import {getLinkedSocials} from '../../services';
import {loadIndividualSocial, updateSocial} from '../../store/actions';
@@ -14,14 +18,14 @@ import {RootState} from '../../store/rootReducer';
import {ScreenType} from '../../types';
import {canViewProfile} from '../../utils';
import Tagg from './Tagg';
+import {useSafeAreaInsets} from 'react-native-safe-area-context';
-const {View, ScrollView, interpolate, Extrapolate} = Animated;
+const {View, ScrollView} = Animated;
interface TaggsBarProps {
- y: Animated.Value<number>;
+ y: Animated.SharedValue<number>;
profileBodyHeight: number;
userXId: string | undefined;
screenType: ScreenType;
- whiteRing: boolean | undefined;
linkedSocials?: string[];
}
const TaggsBar: React.FC<TaggsBarProps> = ({
@@ -29,7 +33,6 @@ const TaggsBar: React.FC<TaggsBarProps> = ({
profileBodyHeight,
userXId,
screenType,
- whiteRing,
linkedSocials,
}) => {
let [taggs, setTaggs] = useState<Object[]>([]);
@@ -41,7 +44,7 @@ const TaggsBar: React.FC<TaggsBarProps> = ({
const allowTaggsNavigation = canViewProfile(state, userXId, screenType);
const dispatch = useDispatch();
-
+ const insetTop = useSafeAreaInsets().top;
/**
* Updates the individual social that needs update
* If username is empty, update nonintegrated socials like Snapchat and TikTok
@@ -80,13 +83,13 @@ const TaggsBar: React.FC<TaggsBarProps> = ({
isIntegrated={INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1}
setTaggsNeedUpdate={setTaggsNeedUpdate}
setSocialDataNeedUpdate={handleSocialUpdate}
- whiteRing={whiteRing ? whiteRing : undefined}
+ whiteRing={false}
allowNavigation={allowTaggsNavigation}
/>,
);
i++;
}
- if (!userXId && !whiteRing) {
+ if (!userXId) {
for (let social of unlinkedSocials) {
new_taggs.push(
<Tagg
@@ -98,7 +101,7 @@ const TaggsBar: React.FC<TaggsBarProps> = ({
setSocialDataNeedUpdate={handleSocialUpdate}
userXId={userXId}
user={user}
- whiteRing={whiteRing ? whiteRing : undefined}
+ whiteRing={false}
allowNavigation={allowTaggsNavigation}
/>,
);
@@ -112,67 +115,55 @@ const TaggsBar: React.FC<TaggsBarProps> = ({
loadData();
}
}, [taggsNeedUpdate, user]);
-// TODO: (Leon) use reanimated v2
- const shadowOpacity = 0;
- // const shadowOpacity: Animated.Node<number> = interpolate(y, {
- // inputRange: [
- // PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight,
- // PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight + 20,
- // ],
- // outputRange: [0, 0.2],
- // extrapolate: Extrapolate.CLAMP,
- // });
- // TODO: (Leon) use reanimated v2
- const paddingTop = 0;
- // const paddingTop: Animated.Node<number> = interpolate(y, {
- // inputRange: [
- // PROFILE_CUTOUT_BOTTOM_Y +
- // profileBodyHeight -
- // (useSafeAreaInsets().top + 10),
- // PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight,
- // ],
- // outputRange: [10, useSafeAreaInsets().top],
- // extrapolate: Extrapolate.CLAMP,
- // });
+ const paddingTopStylesProgress = useDerivedValue(() =>
+ interpolate(
+ y.value,
+ [PROFILE_CUTOUT_BOTTOM_Y, PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight],
+ [0, 1],
+ Extrapolate.CLAMP,
+ ),
+ );
+ const shadowOpacityStylesProgress = useDerivedValue(() =>
+ interpolate(
+ y.value,
+ [
+ PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight,
+ PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight + insetTop,
+ ],
+ [0, 1],
+ Extrapolate.CLAMP,
+ ),
+ );
+ const animatedStyles = useAnimatedStyle(() => ({
+ shadowOpacity: shadowOpacityStylesProgress.value / 5,
+ paddingTop: paddingTopStylesProgress.value * insetTop,
+ }));
return taggs.length > 0 ? (
- <View
- style={
- whiteRing
- ? [styles.spContainer]
- : [styles.container, {shadowOpacity, paddingTop}]
- }>
+ <View style={[styles.container, animatedStyles]}>
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
- contentContainerStyle={styles.contentContainer}>
+ contentContainerStyle={[styles.contentContainer]}>
{taggs}
</ScrollView>
</View>
) : (
- <Fragment />
+ <></>
);
};
const styles = StyleSheet.create({
- spContainer: {
- shadowColor: '#000',
- shadowRadius: 10,
- shadowOffset: {width: 0, height: 2},
- zIndex: 1,
- marginBottom: 25,
- },
container: {
backgroundColor: 'white',
shadowColor: '#000',
shadowRadius: 10,
shadowOffset: {width: 0, height: 2},
zIndex: 1,
- paddingBottom: 5,
},
contentContainer: {
alignItems: 'center',
- paddingBottom: 5,
+ paddingBottom: 15,
},
});