Skip to content

Commit

Permalink
show images in preview
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius committed May 28, 2024
1 parent ccd2864 commit eb5cd47
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/screens/Messages/Conversation/MessageInputEmbed.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, {useCallback, useEffect, useMemo, useState} from 'react'
import {LayoutAnimation, View} from 'react-native'
import {
AppBskyEmbedImages,
AppBskyEmbedRecordWithMedia,
AppBskyFeedPost,
AppBskyRichtextFacet,
AtUri,
Expand All @@ -20,6 +22,7 @@ import {
} from '#/lib/strings/url-helpers'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {usePostQuery} from '#/state/queries/post'
import {ImageHorzList} from '#/view/com/util/images/ImageHorzList'
import {PostMeta} from '#/view/com/util/PostMeta'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonIcon} from '#/components/Button'
Expand Down Expand Up @@ -155,6 +158,13 @@ export function MessageInputEmbed({
return null
}

const images = AppBskyEmbedImages.isView(post.embed)
? post.embed.images
: AppBskyEmbedRecordWithMedia.isView(post.embed) &&
AppBskyEmbedImages.isView(post.embed.media)
? post.embed.media.images
: undefined

content = (
<View
style={[
Expand Down Expand Up @@ -190,6 +200,9 @@ export function MessageInputEmbed({
/>
</View>
)}
{images && images?.length > 0 && (
<ImageHorzList images={images} style={a.mt_xs} />
)}
</ContentHider>
</View>
)
Expand Down
2 changes: 1 addition & 1 deletion src/view/com/notifications/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function AdditionalPostText({post}: {post?: AppBskyFeedDefs.PostView}) {
return (
<>
{text?.length > 0 && <Text style={pal.textLight}>{text}</Text>}
{images && images?.length > 0 && (
{images && images.length > 0 && (
<ImageHorzList images={images} style={styles.additionalPostImages} />
)}
</>
Expand Down
11 changes: 7 additions & 4 deletions src/view/com/util/images/ImageHorzList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ export function ImageHorzList({images, style}: Props) {
}

const styles = StyleSheet.create({
flexRow: {flexDirection: 'row'},
flexRow: {
flexDirection: 'row',
gap: 5,
},
image: {
width: 100,
height: 100,
maxWidth: 100,
aspectRatio: 1,
flex: 1,
borderRadius: 4,
marginRight: 5,
},
})

0 comments on commit eb5cd47

Please sign in to comment.