aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/Content.tsx
blob: 8d368747d5e510bac1f8dc31428f3eabfd96281a (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
import React, {useState} from 'react';
import {LayoutChangeEvent, StyleSheet, View} from 'react-native';
import {Text} from 'react-native-animatable';
import Animated from 'react-native-reanimated';
import {defaultMoments} from '../../constants';
import {SCREEN_HEIGHT} from '../../utils';
import TaggsBar from '../taggs/TaggsBar';
import Moment from './Moment';
import ProfileBody from './ProfileBody';
import ProfileCutout from './ProfileCutout';
import ProfileHeader from './ProfileHeader';

interface ContentProps {
  y: Animated.Value<number>;
  isProfileView: boolean;
}
const Content: React.FC<ContentProps> = ({y, isProfileView}) => {
  const [profileBodyHeight, setProfileBodyHeight] = useState(0);
  const onLayout = (e: LayoutChangeEvent) => {
    const {height} = e.nativeEvent.layout;
    setProfileBodyHeight(height);
  };
  return (
    <Animated.ScrollView
      style={styles.container}
      onScroll={(e) => y.setValue(e.nativeEvent.contentOffset.y)}
      showsVerticalScrollIndicator={false}
      scrollEventThrottle={1}
      stickyHeaderIndices={[2, 4]}>
      <ProfileCutout>
        <ProfileHeader {...{isProfileView}} />
      </ProfileCutout>
      <ProfileBody {...{onLayout, isProfileView}} />
      <TaggsBar {...{y, profileBodyHeight, isProfileView}} />
      {!isProfileView ? (
        <View style={styles.momentsContainer}>
          {defaultMoments.map((title, index) => (
            <Moment key={index} title={title} images={[]} />
          ))}
        </View>
      ) : (
        <React.Fragment />
      )}
    </Animated.ScrollView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  momentsContainer: {
    backgroundColor: '#f2f2f2',
    paddingBottom: SCREEN_HEIGHT / 10,
  },
});

export default Content;