aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShravya Ramesh <shravs1208@gmail.com>2021-06-21 13:45:55 -0700
committerShravya Ramesh <shravs1208@gmail.com>2021-06-21 13:45:55 -0700
commit7e7da1aece223d25b5b4720e85994153f1c18e04 (patch)
tree5507f673565804f8922c8c9298ba88925f2b98c8
parenta4d9a5fe38aaa4b6347edfb942375fa882f53ad7 (diff)
Organise declarations, import statements
-rw-r--r--src/components/moments/MomentPost.tsx84
1 files changed, 22 insertions, 62 deletions
diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx
index c010e2cb..c7224566 100644
--- a/src/components/moments/MomentPost.tsx
+++ b/src/components/moments/MomentPost.tsx
@@ -1,5 +1,5 @@
import {useNavigation} from '@react-navigation/native';
-import React, {useContext, useEffect, useMemo, useRef, useState} from 'react';
+import React, {useContext, useEffect, useRef, useState} from 'react';
import {
Image,
KeyboardAvoidingView,
@@ -18,15 +18,8 @@ import {MomentContext} from '../../screens/profile/IndividualMoment';
import {deleteMomentTag, loadMomentTags} from '../../services';
import {loadUserMoments} from '../../store/actions';
import {RootState} from '../../store/rootReducer';
+import {MomentPostType, MomentTagType, ScreenType, UserType} from '../../types';
import {
- MomentCommentPreviewType,
- MomentPostType,
- MomentTagType,
- ScreenType,
- UserType,
-} from '../../types';
-import {
- getLoggedInUserAsProfilePreview,
getTimePosted,
HeaderHeight,
navigateToProfile,
@@ -39,30 +32,46 @@ import {AddComment} from '../comments';
import CommentsCount from '../comments/CommentsCount';
import {MomentTags} from '../common';
import {MomentMoreInfoDrawer, TaggAvatar} from '../profile';
+import IndividualMomentTitleBar from './IndividualMomentTitleBar';
interface MomentPostProps {
moment: MomentPostType;
userXId: string | undefined;
screenType: ScreenType;
- index: number;
}
const MomentPost: React.FC<MomentPostProps> = ({
moment,
userXId,
screenType,
- index,
}) => {
+ const navigation = useNavigation();
+ const dispatch = useDispatch();
const {userId: loggedInUserId, username: loggedInUsername} = useSelector(
(state: RootState) => state.user.user,
);
-
const {user} = useSelector((state: RootState) =>
userXId ? state.userX[screenType][userXId] : state.user,
);
+ const state: RootState = useStore().getState();
+ const isOwnProfile = user.username === loggedInUsername;
+
const [tags, setTags] = useState<MomentTagType[]>([]);
+ const [visible, setVisible] = useState(false);
+ const [drawerVisible, setDrawerVisible] = useState(false);
+ const [hideText, setHideText] = useState(false);
+ const [isFullScreen, setIsFullScreen] = useState<boolean>(false);
+
+ const [fadeValue, setFadeValue] = useState<Animated.Value<number>>(
+ new Animated.Value(0),
+ );
+ const [commentCount, setCommentCount] = useState<number>(
+ moment.comments_count,
+ );
+ const [aspectRatio, setAspectRatio] = useState<number>(1);
const [momentTagId, setMomentTagId] = useState<string>('');
- const isOwnProfile = user.username === loggedInUsername;
+ const imageRef = useRef(null);
+ const {keyboardVisible} = useContext(MomentContext);
/*
* Load tags on initial render to pass tags data to moment header and content
@@ -101,28 +110,6 @@ const MomentPost: React.FC<MomentPostProps> = ({
}
};
- // const [tags, setTags] = useState<MomentTagType[]>(momentTags);
- const state: RootState = useStore().getState();
- const navigation = useNavigation();
- const dispatch = useDispatch();
- const imageRef = useRef(null);
- const [visible, setVisible] = useState(false);
- const [fadeValue, setFadeValue] = useState<Animated.Value<number>>(
- new Animated.Value(0),
- );
- const [commentCount, setCommentCount] = useState<number>(
- moment.comments_count,
- );
- const [commentPreview, setCommentPreview] =
- useState<MomentCommentPreviewType | null>(moment.comment_preview);
- const {keyboardVisible} = useContext(MomentContext);
- const [hideText, setHideText] = useState(false);
-
- const [isFullScreen, setIsFullScreen] = useState<boolean>(false);
- const [aspectRatio, setAspectRatio] = useState<number>(1);
-
- const [drawerVisible, setDrawerVisible] = useState(false);
-
useEffect(
() =>
navigation.setOptions({
@@ -163,15 +150,6 @@ const MomentPost: React.FC<MomentPostProps> = ({
}
}, [keyboardVisible, hideText]);
- const tagsIcon = useMemo(() => {
- tags.length > 0 && (
- <Image
- source={require('../../assets/icons/tag_indicate.png')}
- style={styles.tagIcon}
- />
- );
- }, [tags]);
-
const MomentPosterPreview = () => (
<View style={styles.momentPosterContainer}>
<TouchableOpacity
@@ -190,24 +168,6 @@ const MomentPost: React.FC<MomentPostProps> = ({
</View>
);
- const TagsIcon = () => {
- return tags.length > 0 ? (
- <TouchableWithoutFeedback
- onPress={() => {
- setVisible(!visible);
- setFadeValue(new Animated.Value(0));
- }}>
- <Image
- source={require('../../assets/icons/tag_indicate.png')}
- style={styles.tagIcon}
- />
- </TouchableWithoutFeedback>
- ) : (
- <React.Fragment />
- );
- };
-
- const [verticalOffset, setVerticalOffset] = useState<number>(0);
return (
<>
<StatusBar barStyle={'light-content'} />