forked from keep-starknet-strange/joyboy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Add PostDetails view to see comments (keep-starknet-strange#104
- Loading branch information
1 parent
22e4951
commit 30a8017
Showing
8 changed files
with
388 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {createStackNavigator} from '@react-navigation/stack'; | ||
|
||
import PostDetails from '../../shared/components/PostDetails'; | ||
import Feed from '.'; | ||
|
||
const FeedStack = createStackNavigator(); | ||
|
||
function FeedStackScreen() { | ||
return ( | ||
<FeedStack.Navigator> | ||
<FeedStack.Screen name="Feed" component={Feed} /> | ||
<FeedStack.Screen | ||
name="PostDetails" | ||
component={PostDetails} | ||
options={{ | ||
title: 'Feed', | ||
headerLeft: () => null, | ||
}} | ||
/> | ||
</FeedStack.Navigator> | ||
); | ||
} | ||
|
||
export default FeedStackScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React from 'react'; | ||
import {FlatList, View} from 'react-native'; | ||
|
||
import PostComment from './PostComment'; | ||
|
||
const mockEvents = [ | ||
{ | ||
post: { | ||
content: 'mock content', | ||
author: 'Roronoa zoro', | ||
|
||
id: '1', | ||
created_at: '2021-09-01T00:00:00Z', | ||
pubkey: '1234567890', | ||
}, | ||
event: { | ||
content: 'Lets say that One Piece is awesome', | ||
created_at: 1680638952, | ||
id: '12e701f23d365c558e7aa1a6f75f0477fb8593d4ad8421c4b326f8193ed42fc7', | ||
kind: 1, | ||
pubkey: '49e2566f8b1ef0da8aeb89865a862ead30dd5e1fc1e540edebf980a04fe9e853', | ||
sig: 'c931395c5db7538d159d6012115b0db9b1d9a5ada52132437cddc1790982727555d0d618f109fce372f0ca0ae33d29a8d3ffae1af879e278fc2ce3c6d123c658', | ||
tags: [ | ||
['e', 'a8de2eb8a069fecd33246cd921124541d6242ea76ee85c38bf45ee9b5fb3feb5'], | ||
['p', '1989034e56b8f606c724f45a12ce84a11841621aaf7182a1f6564380b9c4276b'], | ||
], | ||
}, | ||
sourceUser: null, | ||
}, | ||
{ | ||
post: { | ||
content: 'mock content', | ||
author: 'Roronoa zoro', | ||
|
||
id: '1', | ||
created_at: '2021-09-01T00:00:00Z', | ||
pubkey: '1234567890', | ||
}, | ||
event: { | ||
content: 'What about Naruto?', | ||
created_at: 1680638952, | ||
id: '12e701f23d365c558e7aa1a6f75f0477fb8593d4ad8421c4b326f8193ed42fc7', | ||
kind: 1, | ||
pubkey: '49e2566f8b1ef0da8aeb89865a862ead30dd5e1fc1e540edebf980a04fe9e853', | ||
sig: 'c931395c5db7538d159d6012115b0db9b1d9a5ada52132437cddc1790982727555d0d618f109fce372f0ca0ae33d29a8d3ffae1af879e278fc2ce3c6d123c658', | ||
tags: [ | ||
['e', 'a8de2eb8a069fecd33246cd921124541d6242ea76ee85c38bf45ee9b5fb3feb5'], | ||
['p', '1989034e56b8f606c724f45a12ce84a11841621aaf7182a1f6564380b9c4276b'], | ||
], | ||
}, | ||
sourceUser: null, | ||
}, | ||
{ | ||
post: { | ||
content: 'mock content', | ||
author: 'Roronoa zoro', | ||
|
||
id: '1', | ||
created_at: '2021-09-01T00:00:00Z', | ||
pubkey: '1234567890', | ||
}, | ||
event: { | ||
content: 'Yeaaaah Naruto is sick', | ||
created_at: 1680638952, | ||
id: '12e701f23d365c558e7aa1a6f75f0477fb8593d4ad8421c4b326f8193ed42fc7', | ||
kind: 1, | ||
pubkey: '49e2566f8b1ef0da8aeb89865a862ead30dd5e1fc1e540edebf980a04fe9e853', | ||
sig: 'c931395c5db7538d159d6012115b0db9b1d9a5ada52132437cddc1790982727555d0d618f109fce372f0ca0ae33d29a8d3ffae1af879e278fc2ce3c6d123c658', | ||
tags: [ | ||
['e', 'a8de2eb8a069fecd33246cd921124541d6242ea76ee85c38bf45ee9b5fb3feb5'], | ||
['p', '1989034e56b8f606c724f45a12ce84a11841621aaf7182a1f6564380b9c4276b'], | ||
], | ||
}, | ||
sourceUser: null, | ||
}, | ||
]; | ||
function Comments() { | ||
return ( | ||
<FlatList | ||
horizontal={false} | ||
scrollEnabled={false} | ||
showsHorizontalScrollIndicator={false} | ||
data={mockEvents} | ||
ItemSeparatorComponent={() => <View style={{height: 18}} />} | ||
renderItem={({item}) => { | ||
return <PostComment event={item.event} post={item.post} sourceUser={item.sourceUser} />; | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
export default Comments; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {Octicons} from '@expo/vector-icons'; | ||
import {Event as EventNostr} from 'nostr-tools'; | ||
import React from 'react'; | ||
import {Image, Text, View} from 'react-native'; | ||
import styled from 'styled-components/native'; | ||
|
||
import {Post as PostType} from '../../types'; | ||
import {Icon} from './Post'; | ||
|
||
const PostCommentCard = styled(View)` | ||
padding: 18px 10px; | ||
border-bottom-width: 1; | ||
border-bottom-color: #eff0f1; | ||
`; | ||
|
||
const PostLayout = styled(View)` | ||
flex-direction: row; | ||
`; | ||
|
||
interface PostCommentProps { | ||
post?: PostType; | ||
event?: EventNostr; | ||
sourceUser?: string; | ||
} | ||
export const PostComment: React.FC<PostCommentProps> = (props) => { | ||
const {post, event, sourceUser} = props; | ||
|
||
return ( | ||
<PostCommentCard> | ||
<PostLayout> | ||
<View style={{marginRight: 10}}> | ||
<Image | ||
source={sourceUser ?? require('../../../assets/joyboy-logo.png')} | ||
style={{width: 44, height: 44}} | ||
/> | ||
</View> | ||
|
||
<View style={{gap: 4, flex: 1}}> | ||
<Text style={{color: 'black', fontWeight: '700'}}>{event?.pubkey}</Text> | ||
|
||
{post?.source && ( | ||
<Image | ||
source={{uri: post.source}} | ||
style={{ | ||
width: '100%', | ||
|
||
height: 200, | ||
borderRadius: 8, | ||
marginTop: 8, | ||
}} | ||
/> | ||
)} | ||
</View> | ||
|
||
<Icon as={Octicons} name="heart" size={24} color="black" style={{alignSelf: 'center'}} /> | ||
</PostLayout> | ||
<Text style={{color: 'black', marginTop: 10}}>{event?.content}</Text> | ||
</PostCommentCard> | ||
); | ||
}; | ||
|
||
export default PostComment; |
Oops, something went wrong.