forked from noelzappy/gptalks
-
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.
- Loading branch information
Showing
8 changed files
with
342 additions
and
17 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
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,126 @@ | ||
import React, { useRef, useState } from 'react'; | ||
import { View, Text, TouchableOpacity } from 'react-native'; | ||
import { useTheme } from '@/hooks'; | ||
import { Post } from 'types/post'; | ||
import { Avatar, ListItem } from '@rneui/base'; | ||
import ImageView from 'react-native-image-viewing'; | ||
import ViewShot from 'react-native-view-shot'; | ||
import ChatBubble from './ChatBubble'; | ||
|
||
type Props = { | ||
item: Post; | ||
onPress: () => void; | ||
}; | ||
|
||
const PostHead = ({ item, onPress }: Props) => { | ||
const { Fonts, Common, Layout, Gutters } = useTheme(); | ||
|
||
const shotRef = useRef<any>(null); | ||
const [showImagViewer, setShowImagViewer] = useState(false); | ||
const [imageUri, setImageUri] = useState(undefined); | ||
|
||
const onCapture = () => { | ||
shotRef.current?.capture().then((uri: any) => { | ||
setImageUri(uri); | ||
setShowImagViewer(true); | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<View | ||
style={[Layout.row, Layout.alignItemsCenter, Gutters.regularTMargin]} | ||
> | ||
<Avatar | ||
source={{ uri: 'https://picsum.photos/200' }} | ||
rounded | ||
size="small" | ||
containerStyle={[ | ||
Gutters.smallRMargin, | ||
{ | ||
marginLeft: 10, | ||
}, | ||
]} | ||
/> | ||
<View> | ||
<Text style={[Fonts.textSmall, Fonts.textBold]} numberOfLines={1}> | ||
{item.user.name} | ||
</Text> | ||
|
||
<Text | ||
style={[ | ||
Fonts.textSmall, | ||
{ | ||
fontSize: 12, | ||
}, | ||
]} | ||
numberOfLines={1} | ||
> | ||
@{item.user.name} | ||
</Text> | ||
</View> | ||
</View> | ||
|
||
<ListItem bottomDivider onPress={onPress}> | ||
<ListItem.Content> | ||
<View | ||
style={[ | ||
{ | ||
paddingBottom: 3, | ||
}, | ||
]} | ||
> | ||
<Text style={[Fonts.textSmall]}>{item.description}</Text> | ||
</View> | ||
|
||
<TouchableOpacity | ||
style={[Common.viewImage]} | ||
onPress={onCapture} | ||
activeOpacity={0.8} | ||
> | ||
<ViewShot | ||
ref={shotRef} | ||
options={{ | ||
fileName: `post-${item.id}`, | ||
format: 'jpg', | ||
quality: 0.9, | ||
}} | ||
> | ||
<View | ||
style={[ | ||
{ | ||
padding: 5, | ||
}, | ||
]} | ||
> | ||
<ChatBubble | ||
item={item.prompt} | ||
showSender | ||
disabled | ||
fontSize={13} | ||
/> | ||
<ChatBubble | ||
item={item.response} | ||
showSender | ||
disabled | ||
fontSize={13} | ||
/> | ||
</View> | ||
</ViewShot> | ||
</TouchableOpacity> | ||
</ListItem.Content> | ||
</ListItem> | ||
|
||
<ImageView | ||
images={[{ uri: imageUri }]} | ||
imageIndex={0} | ||
visible={showImagViewer && !!imageUri} | ||
onRequestClose={() => { | ||
setShowImagViewer(false); | ||
}} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default PostHead; |
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,83 @@ | ||
import React from 'react'; | ||
import { View, Text, TouchableOpacity } from 'react-native'; | ||
import { useTheme } from '@/hooks'; | ||
import { PostReply } from 'types/post'; | ||
import { Avatar, ListItem } from '@rneui/base'; | ||
|
||
type Props = { | ||
item: PostReply; | ||
onPress: () => void; | ||
}; | ||
|
||
const ReplyItem = ({ item, onPress }: Props) => { | ||
const { Fonts, Layout, Gutters } = useTheme(); | ||
|
||
return ( | ||
<TouchableOpacity | ||
style={[ | ||
{ | ||
paddingLeft: 10, | ||
}, | ||
]} | ||
onPress={onPress} | ||
> | ||
<View | ||
style={[Layout.row, Layout.alignItemsCenter, Gutters.regularTMargin]} | ||
> | ||
<Avatar | ||
source={{ uri: 'https://picsum.photos/200' }} | ||
rounded | ||
size="small" | ||
/> | ||
|
||
<View | ||
style={[ | ||
{ | ||
marginLeft: 10, | ||
}, | ||
]} | ||
> | ||
<Text style={[Fonts.textSmall, Fonts.textBold]} numberOfLines={1}> | ||
{item.user.name} | ||
</Text> | ||
|
||
<Text | ||
style={[ | ||
Fonts.textSmall, | ||
{ | ||
fontSize: 12, | ||
}, | ||
]} | ||
numberOfLines={1} | ||
> | ||
@{item.user.name} | ||
</Text> | ||
</View> | ||
</View> | ||
<ListItem | ||
bottomDivider | ||
containerStyle={[ | ||
{ | ||
alignItems: 'stretch', | ||
}, | ||
]} | ||
> | ||
<View /> | ||
<ListItem.Content> | ||
<View | ||
style={[ | ||
{ | ||
paddingBottom: 3, | ||
marginLeft: 10, | ||
}, | ||
]} | ||
> | ||
<Text style={[Fonts.textSmall]}>{item.text}</Text> | ||
</View> | ||
</ListItem.Content> | ||
</ListItem> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
export default ReplyItem; |
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
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
Oops, something went wrong.