aboutsummaryrefslogtreecommitdiff
path: root/src/components/taggs/TaggsBar.tsx
blob: 88f670b5f89a65d808d560651d7204a3a64ef4ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// @refresh react
import React from 'react';
import {StyleSheet} from 'react-native';
import Animated from 'react-native-reanimated';
import Tagg from './Tagg';
import {PROFILE_CUTOUT_BOTTOM_Y} from '../../constants';
import {StatusBarHeight} from '../../utils';

const {View, ScrollView, interpolate, Extrapolate} = Animated;
interface TaggsBarProps {
  y: Animated.Value<number>;
  profileBodyHeight: number;
  isProfileView: boolean;
}
const TaggsBar: React.FC<TaggsBarProps> = ({
  y,
  profileBodyHeight,
  isProfileView,
}) => {
  const taggs: Array<JSX.Element> = [];

  taggs.push(
    <Tagg
      key={0}
      style={styles.tagg}
      social={'Instagram'}
      isProfileView={isProfileView}
    />,
  );
  taggs.push(
    <Tagg
      key={1}
      style={styles.tagg}
      social={'Facebook'}
      isProfileView={isProfileView}
    />,
  );
  taggs.push(
    <Tagg
      key={2}
      style={styles.tagg}
      social={'Twitter'}
      isProfileView={isProfileView}
    />,
  );

  for (let i = 3; i < 10; i++) {
    taggs.push(
      <Tagg
        key={i}
        style={styles.tagg}
        social={'Instagram'}
        isProfileView={isProfileView}
      />,
    );
  }
  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,
  });
  const paddingTop: Animated.Node<number> = interpolate(y, {
    inputRange: [
      0,
      PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight - 30,
      PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight,
    ],
    outputRange: [20, 20, StatusBarHeight],
    extrapolate: Extrapolate.CLAMP,
  });
  const paddingBottom: Animated.Node<number> = interpolate(y, {
    inputRange: [
      0,
      PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight - 30,
      PROFILE_CUTOUT_BOTTOM_Y + profileBodyHeight,
    ],
    outputRange: [30, 30, 15],
    extrapolate: Extrapolate.CLAMP,
  });
  return (
    <View style={[styles.container, {shadowOpacity}]}>
      <ScrollView
        horizontal
        showsHorizontalScrollIndicator={false}
        style={{paddingTop, paddingBottom}}
        contentContainerStyle={styles.contentContainer}>
        {taggs}
      </ScrollView>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    backgroundColor: 'white',
    shadowColor: '#000',
    shadowRadius: 10,
    shadowOffset: {width: 0, height: 2},
    zIndex: 1,
  },
  contentContainer: {
    alignItems: 'center',
    paddingHorizontal: 15,
  },
  tagg: {
    marginHorizontal: 14,
  },
});

export default TaggsBar;