diff options
| author | Ivan Chen <ivan@thetaggid.com> | 2020-12-14 19:22:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-14 19:22:35 -0500 |
| commit | b5ecbf3e421e9e6f1dbab9f3f851d265ae8470c6 (patch) | |
| tree | 4c1ee927a851649ef03c8a05619e2d78f2cdb1f4 /src/components/moments/MomentPostHeader.tsx | |
| parent | 3b7bf256d83e1898642c2aab9072ffbeec8cc032 (diff) | |
[TMA-406&201] User Handle UI for Individual Moments (#129)
* initial work
* made big progress towards flatlist moment view
* UI done, just need to pass in data now
* minor fixes to get things actually running correctly
* vertical scroll working
* initial index working
* moment drawer text color to red
* moved report to drawer
* removed garbage
* added ?
Diffstat (limited to 'src/components/moments/MomentPostHeader.tsx')
| -rw-r--r-- | src/components/moments/MomentPostHeader.tsx | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx new file mode 100644 index 00000000..810ccea9 --- /dev/null +++ b/src/components/moments/MomentPostHeader.tsx @@ -0,0 +1,84 @@ +import React, {useState} from 'react'; +import {StyleSheet, Text, View, ViewProps} from 'react-native'; +import {MomentMoreInfoDrawer} from '..'; +import {loadUserMoments} from '../../store/actions'; +import {useDispatch, useSelector} from 'react-redux'; +import {ScreenType} from '../../types'; +import Avatar from '../profile/Avatar'; +import {useNavigation} from '@react-navigation/native'; +import {RootState} from '../../store/rootReducer'; + +interface MomentPostHeaderProps extends ViewProps { + userXId?: string; + screenType: ScreenType; + username: string; + momentId: string; +} + +const MomentPostHeader: React.FC<MomentPostHeaderProps> = ({ + userXId, + screenType, + username, + momentId, + style, +}) => { + const [drawerVisible, setDrawerVisible] = useState(false); + const dispatch = useDispatch(); + const navigation = useNavigation(); + const {userId: loggedInUserId, username: loggedInUserName} = useSelector( + (state: RootState) => state.user.user, + ); + const isOwnProfile = loggedInUserName === username; + + return ( + <View style={[styles.container, style]}> + <View style={styles.header}> + <Avatar + style={styles.avatar} + userXId={userXId} + screenType={screenType} + /> + <Text style={styles.headerText}>{username}</Text> + </View> + <MomentMoreInfoDrawer + isOpen={drawerVisible} + setIsOpen={setDrawerVisible} + momentId={momentId} + isOwnProfile={isOwnProfile} + dismissScreenAndUpdate={() => { + dispatch(loadUserMoments(loggedInUserId)); + navigation.pop(); + }} + /> + </View> + ); +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'space-around', + flexDirection: 'row', + alignItems: 'center', + marginVertical: '2%', + }, + header: { + alignItems: 'center', + flexDirection: 'row', + flex: 1, + }, + avatar: { + flex: 0.2, + aspectRatio: 1, + borderRadius: 999999, + marginLeft: '3%', + }, + headerText: { + fontSize: 15, + fontWeight: 'bold', + color: 'white', + paddingHorizontal: '3%', + flex: 1, + }, +}); +export default MomentPostHeader; |
