diff options
author | Brian Kim <brian@tagg.id> | 2021-06-15 12:28:32 +0900 |
---|---|---|
committer | Brian Kim <brian@tagg.id> | 2021-06-15 12:28:32 +0900 |
commit | db0678d647f774dcb1cd60513985d9b6fbd0e28b (patch) | |
tree | 00e62c1821d4973d214fdd47f8293749972c1925 /src/components/moments/MomentPost.tsx | |
parent | a249f2d027c9cd5d7f20602cf79ec2265f60a54c (diff) | |
parent | 78f32c1400eff46d4c768b78fbaf672826c74285 (diff) |
Merge branch 'master' of https://github.com/TaggiD-Inc/Frontend
Diffstat (limited to 'src/components/moments/MomentPost.tsx')
-rw-r--r-- | src/components/moments/MomentPost.tsx | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx index 7149a5b4..d87028e3 100644 --- a/src/components/moments/MomentPost.tsx +++ b/src/components/moments/MomentPost.tsx @@ -1,21 +1,25 @@ import React, {useEffect, useState} from 'react'; -import {StyleSheet, View} from 'react-native'; +import {StyleSheet} from 'react-native'; import {useSelector} from 'react-redux'; import {MomentPostContent, MomentPostHeader} from '.'; import {deleteMomentTag, loadMomentTags} from '../../services'; import {RootState} from '../../store/rootReducer'; -import {MomentTagType, MomentType, ScreenType} from '../../types'; -import {SCREEN_HEIGHT, SCREEN_WIDTH, StatusBarHeight} from '../../utils'; +import {MomentPostType, MomentTagType, ScreenType} from '../../types'; +import {normalize, SCREEN_HEIGHT} from '../../utils'; interface MomentPostProps { - item: MomentType; + moment: MomentPostType; userXId: string | undefined; screenType: ScreenType; + index: number; } -const ITEM_HEIGHT = SCREEN_HEIGHT * 0.9; - -const MomentPost: React.FC<MomentPostProps> = ({item, userXId, screenType}) => { +const MomentPost: React.FC<MomentPostProps> = ({ + moment, + userXId, + screenType, + index, +}) => { const {userId: loggedInUserId, username: loggedInUsername} = useSelector( (state: RootState) => state.user.user, ); @@ -30,16 +34,13 @@ const MomentPost: React.FC<MomentPostProps> = ({item, userXId, screenType}) => { const isOwnProfile = username === loggedInUsername; - const loadTags = async () => { - const response = await loadMomentTags(item.moment_id); - setTags(response ? response : []); - }; - /* * Load tags on initial render to pass tags data to moment header and content */ useEffect(() => { - loadTags(); + loadMomentTags(moment.moment_id).then((response) => { + setTags(response ? response : []); + }); }, []); /* @@ -71,52 +72,34 @@ const MomentPost: React.FC<MomentPostProps> = ({item, userXId, screenType}) => { }; return ( - <View style={styles.postContainer}> + <> <MomentPostHeader + style={styles.postHeader} userXId={userXId} screenType={screenType} username={isOwnProfile ? loggedInUsername : username} - momentId={item.moment_id} - style={styles.postHeader} momentTagId={momentTagId} removeTag={removeTag} + moment={moment} + tags={tags} /> <MomentPostContent style={styles.postContent} - momentId={item.moment_id} - caption={item.caption} - pathHash={item.moment_url} - dateTime={item.date_created} + moment={moment} screenType={screenType} momentTags={tags} + index={index} /> - </View> + </> ); }; const styles = StyleSheet.create({ - contentContainer: { - width: SCREEN_WIDTH, - height: SCREEN_HEIGHT, - paddingTop: StatusBarHeight, - flex: 1, - paddingBottom: 0, - }, - content: { - flex: 9, - }, - header: { - flex: 1, - }, - postContainer: { - height: ITEM_HEIGHT, - width: SCREEN_WIDTH, - flex: 1, - }, - postHeader: { - flex: 1, + postHeader: {}, + postContent: { + minHeight: SCREEN_HEIGHT * 0.8, + paddingBottom: normalize(20), }, - postContent: {flex: 9}, }); export default MomentPost; |