Adjust gap in small embed variant

This commit is contained in:
Eric Bailey
2024-09-04 20:40:41 -05:00
parent 8ea6155bb4
commit 77323aa466
4 changed files with 29 additions and 24 deletions
+2 -2
View File
@@ -147,8 +147,8 @@ export function AutoSizedImage({
{
gap: 3,
padding: 3,
bottom: a.p_sm.padding,
right: a.p_sm.padding,
bottom: a.p_xs.padding,
right: a.p_xs.padding,
opacity: 0.8,
},
largeAlt && [
+7 -4
View File
@@ -6,6 +6,7 @@ import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge'
import {PostEmbedViewContext} from '#/view/com/util/post-embeds/types'
import {atoms as a, useTheme} from '#/alf'
import {Crop_Stroke2_Corner0_Rounded as Crop} from '#/components/icons/Crop'
import {Text} from '#/components/Typography'
@@ -19,7 +20,7 @@ interface GalleryItemProps {
onLongPress?: EventFunction
onPressIn?: EventFunction
imageStyle: ComponentProps<typeof Image>['style']
hideBadges?: boolean
viewContext?: PostEmbedViewContext
}
export const GalleryItem: FC<GalleryItemProps> = ({
@@ -29,7 +30,7 @@ export const GalleryItem: FC<GalleryItemProps> = ({
onPress,
onPressIn,
onLongPress,
hideBadges,
viewContext,
}) => {
const t = useTheme()
const {_} = useLingui()
@@ -41,6 +42,8 @@ export const GalleryItem: FC<GalleryItemProps> = ({
const aspect = image.aspectRatio.width / image.aspectRatio.height
return aspect !== 1
}, [image.aspectRatio])
const hideBadges =
viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
return (
<View style={a.flex_1}>
<Pressable
@@ -78,8 +81,8 @@ export const GalleryItem: FC<GalleryItemProps> = ({
{
gap: 3,
padding: 3,
bottom: a.p_sm.padding,
right: a.p_sm.padding,
bottom: a.p_xs.padding,
right: a.p_xs.padding,
opacity: 0.8,
},
largeAltBadge && [
+19 -15
View File
@@ -3,6 +3,8 @@ import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
import {AppBskyEmbedImages} from '@atproto/api'
import {isWeb} from 'platform/detection'
import {PostEmbedViewContext} from '#/view/com/util/post-embeds/types'
import {atoms as a} from '#/alf'
import {GalleryItem} from './Gallery'
interface ImageLayoutGridProps {
@@ -11,13 +13,17 @@ interface ImageLayoutGridProps {
onLongPress?: (index: number) => void
onPressIn?: (index: number) => void
style?: StyleProp<ViewStyle>
hideBadges?: boolean
viewContext?: PostEmbedViewContext
}
export function ImageLayoutGrid({style, ...props}: ImageLayoutGridProps) {
const gap =
props.viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
? a.gap_2xs
: a.gap_xs
return (
<View style={style}>
<View style={styles.container}>
<View style={[styles.container, gap]}>
<ImageLayoutGridInner {...props} />
</View>
</View>
@@ -29,15 +35,20 @@ interface ImageLayoutGridInnerProps {
onPress?: (index: number) => void
onLongPress?: (index: number) => void
onPressIn?: (index: number) => void
viewContext?: PostEmbedViewContext
}
function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
const count = props.images.length
const gap =
props.viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
? a.gap_2xs
: a.gap_xs
switch (count) {
case 2:
return (
<View style={styles.flexRow}>
<View style={[a.flex_row, gap]}>
<View style={styles.smallItem}>
<GalleryItem {...props} index={0} imageStyle={styles.image} />
</View>
@@ -49,11 +60,11 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
case 3:
return (
<View style={styles.flexRow}>
<View style={[a.flex_row, gap]}>
<View style={styles.threeSingle}>
<GalleryItem {...props} index={0} imageStyle={styles.image} />
</View>
<View style={styles.threeDouble}>
<View style={[styles.threeDouble, gap]}>
<View style={styles.smallItem}>
<GalleryItem {...props} index={1} imageStyle={styles.image} />
</View>
@@ -67,7 +78,7 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
case 4:
return (
<>
<View style={styles.flexRow}>
<View style={[a.flex_row, gap]}>
<View style={styles.smallItem}>
<GalleryItem {...props} index={0} imageStyle={styles.image} />
</View>
@@ -75,7 +86,7 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
<GalleryItem {...props} index={1} imageStyle={styles.image} />
</View>
</View>
<View style={styles.flexRow}>
<View style={[a.flex_row, gap]}>
<View style={styles.smallItem}>
<GalleryItem {...props} index={2} imageStyle={styles.image} />
</View>
@@ -104,13 +115,7 @@ const styles = StyleSheet.create({
marginHorizontal: -IMAGE_GAP / 2,
marginVertical: -IMAGE_GAP / 2,
}
: {
gap: IMAGE_GAP,
},
flexRow: {
flexDirection: 'row',
gap: isWeb ? undefined : IMAGE_GAP,
},
: {},
smallItem: {flex: 1, aspectRatio: 1},
image: isWeb
? {
@@ -123,6 +128,5 @@ const styles = StyleSheet.create({
},
threeDouble: {
flex: 1,
gap: isWeb ? undefined : IMAGE_GAP,
},
})
+1 -3
View File
@@ -164,9 +164,7 @@ export function PostEmbeds({
images={embed.images}
onPress={_openLightbox}
onPressIn={onPressIn}
hideBadges={
viewContext === PostEmbedViewContext.FeedEmbedRecordWithMedia
}
viewContext={viewContext}
/>
</View>
</ContentHider>