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