diff --git a/src/components/Timeline/Shared/Attachment.tsx b/src/components/Timeline/Shared/Attachment.tsx index 4ff5ab84..174894cc 100644 --- a/src/components/Timeline/Shared/Attachment.tsx +++ b/src/components/Timeline/Shared/Attachment.tsx @@ -45,6 +45,21 @@ const TimelineAttachment = () => { } const [sensitiveShown, setSensitiveShown] = useState(defaultSensitive()) + // const testHorizontal: Mastodon.Attachment[] = Array(2).fill({ + // id: Math.random().toString(), + // type: 'image', + // url: 'https://images.unsplash.com/photo-1670870764013-f0e36aa376b0?w=1000', + // preview_url: 'https://images.unsplash.com/photo-1543968996-ee822b8176ba?w=300', + // meta: { original: { width: 1000, height: 625 } } + // }) + // const testVertical: Mastodon.Attachment[] = Array(7).fill({ + // id: Math.random().toString(), + // type: 'image', + // url: 'https://images.unsplash.com/photo-1670842587871-326b95acbc8c?w=1000', + // preview_url: 'https://images.unsplash.com/photo-1670833288990-64b2f4ef7290?w=300', + // meta: { original: { width: 987, height: 1480 } } + // }) + // @ts-ignore const imageUrls: RootStackParamList['Screen-ImagesViewer']['imageUrls'] = status.media_attachments .map(attachment => { diff --git a/src/components/Timeline/Shared/Attachment/Audio.tsx b/src/components/Timeline/Shared/Attachment/Audio.tsx index 83ec4f82..9e4cc767 100644 --- a/src/components/Timeline/Shared/Attachment/Audio.tsx +++ b/src/components/Timeline/Shared/Attachment/Audio.tsx @@ -8,7 +8,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react' import { AppState, AppStateStatus, StyleSheet, View } from 'react-native' import { Blurhash } from 'react-native-blurhash' import AttachmentAltText from './AltText' -import attachmentAspectRatio from './aspectRatio' +import { aspectRatio } from './dimensions' export interface Props { total: number @@ -64,7 +64,7 @@ const AttachmentAudio: React.FC = ({ total, index, sensitiveShown, audio styles.base, { backgroundColor: colors.disabled, - aspectRatio: attachmentAspectRatio({ total, index }) + aspectRatio: aspectRatio({ total, index, ...audio.meta?.original }) } ]} > diff --git a/src/components/Timeline/Shared/Attachment/Image.tsx b/src/components/Timeline/Shared/Attachment/Image.tsx index 814d41b2..1069a36a 100644 --- a/src/components/Timeline/Shared/Attachment/Image.tsx +++ b/src/components/Timeline/Shared/Attachment/Image.tsx @@ -1,9 +1,10 @@ import GracefullyImage from '@components/GracefullyImage' import { StyleConstants } from '@utils/styles/constants' +import { useTheme } from '@utils/styles/ThemeManager' import React from 'react' import { View } from 'react-native' import AttachmentAltText from './AltText' -import attachmentAspectRatio from './aspectRatio' +import { aspectRatio } from './dimensions' export interface Props { total: number @@ -20,6 +21,8 @@ const AttachmentImage = ({ image, navigateToImagesViewer }: Props) => { + const { colors } = useTheme() + return ( - ) diff --git a/src/components/Timeline/Shared/Attachment/Unsupported.tsx b/src/components/Timeline/Shared/Attachment/Unsupported.tsx index f1c7f347..7fa9d89d 100644 --- a/src/components/Timeline/Shared/Attachment/Unsupported.tsx +++ b/src/components/Timeline/Shared/Attachment/Unsupported.tsx @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next' import { View } from 'react-native' import { Blurhash } from 'react-native-blurhash' import AttachmentAltText from './AltText' -import attachmentAspectRatio from './aspectRatio' +import { aspectRatio } from './dimensions' export interface Props { total: number @@ -29,7 +29,7 @@ const AttachmentUnsupported: React.FC = ({ total, index, sensitiveShown, padding: StyleConstants.Spacing.XS / 2, justifyContent: 'center', alignItems: 'center', - aspectRatio: attachmentAspectRatio({ total, index }) + aspectRatio: aspectRatio({ total, index, ...attachment.meta?.original }) }} > {attachment.blurhash ? ( diff --git a/src/components/Timeline/Shared/Attachment/Video.tsx b/src/components/Timeline/Shared/Attachment/Video.tsx index b9ce9d98..78e53ac4 100644 --- a/src/components/Timeline/Shared/Attachment/Video.tsx +++ b/src/components/Timeline/Shared/Attachment/Video.tsx @@ -4,10 +4,10 @@ import { ResizeMode, Video, VideoFullscreenUpdate } from 'expo-av' import React, { useRef, useState } from 'react' import { Pressable, View } from 'react-native' import { Blurhash } from 'react-native-blurhash' -import attachmentAspectRatio from './aspectRatio' import AttachmentAltText from './AltText' import { Platform } from 'expo-modules-core' import { useAccessibility } from '@utils/accessibility/AccessibilityManager' +import { aspectRatio } from './dimensions' export interface Props { total: number @@ -49,7 +49,7 @@ const AttachmentVideo: React.FC = ({ flex: 1, flexBasis: '50%', padding: StyleConstants.Spacing.XS / 2, - aspectRatio: attachmentAspectRatio({ total, index }) + aspectRatio: aspectRatio({ total, index, ...video.meta?.original }) }} >