diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-12-16 11:57:45 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-12-16 11:57:45 -0600 |
commit | 3aded6887d8b89bccd7c8aa31306f94336ee1123 (patch) | |
tree | 184e7f732f244b1b64505df7a8e945efbc03f22f /src/view/com/util/PostEmbeds.tsx | |
parent | 3a44a1cfdcd664ebf71fdf7edc89c460acdaa558 (diff) | |
download | voidsky-3aded6887d8b89bccd7c8aa31306f94336ee1123.tar.zst |
Add swipe gestures to the lightbox
Diffstat (limited to 'src/view/com/util/PostEmbeds.tsx')
-rw-r--r-- | src/view/com/util/PostEmbeds.tsx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/view/com/util/PostEmbeds.tsx b/src/view/com/util/PostEmbeds.tsx index 5e886409e..ae9212a72 100644 --- a/src/view/com/util/PostEmbeds.tsx +++ b/src/view/com/util/PostEmbeds.tsx @@ -1,25 +1,19 @@ -import React, {useEffect, useState} from 'react' +import React from 'react' import { - ActivityIndicator, - Image, ImageStyle, StyleSheet, StyleProp, Text, - TouchableWithoutFeedback, View, ViewStyle, } from 'react-native' -import { - Record as PostRecord, - Entity, -} from '../../../third-party/api/src/client/types/app/bsky/feed/post' import * as AppBskyEmbedImages from '../../../third-party/api/src/client/types/app/bsky/embed/images' import * as AppBskyEmbedExternal from '../../../third-party/api/src/client/types/app/bsky/embed/external' import {Link} from '../util/Link' -import {LinkMeta, getLikelyType, LikelyType} from '../../../lib/link-meta' import {colors} from '../../lib/styles' import {AutoSizedImage} from './images/AutoSizedImage' +import {ImagesLightbox} from '../../../state/models/shell-ui' +import {useStores} from '../../../state' type Embed = | AppBskyEmbedImages.Presented @@ -33,14 +27,19 @@ export function PostEmbeds({ embed?: Embed style?: StyleProp<ViewStyle> }) { + const store = useStores() if (embed?.$type === 'app.bsky.embed.images#presented') { const imgEmbed = embed as AppBskyEmbedImages.Presented if (imgEmbed.images.length > 0) { + const uris = imgEmbed.images.map(img => img.fullsize) + const openLightbox = (index: number) => { + store.shell.openLightbox(new ImagesLightbox(uris, index)) + } const Thumb = ({i, style}: {i: number; style: StyleProp<ImageStyle>}) => ( <AutoSizedImage style={style} uri={imgEmbed.images[i].thumb} - fullSizeUri={imgEmbed.images[i].fullsize} + onPress={() => openLightbox(i)} /> ) if (imgEmbed.images.length === 4) { |