Skip to content

Commit

Permalink
Move Image component to content folder
Browse files Browse the repository at this point in the history
  • Loading branch information
NuckChorris committed Sep 19, 2024
1 parent 9bfae3f commit e5f773d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Image as ExpoImage, ImageProps as ExpoImageProps } from 'expo-image';
import {
Image as ExpoImage,
type ImageProps as ExpoImageProps,
} from 'expo-image';
import React from 'react';
import Animated from 'react-native-reanimated';

import { FragmentOf, graphql } from '@/utils/graphql';
import { graphql, type FragmentOf } from '@/utils/graphql';

export const ImageFragment = graphql(`
fragment ImageFragment on Image @_unmask {
Expand Down Expand Up @@ -35,13 +39,19 @@ export type ImageProps = {
source?: FragmentOf<typeof ImageFragment> | null;
} & Omit<ExpoImageProps, 'source'>;

export default function Image({ source, ...props }: ImageProps) {
return source ? (
<ExpoImage
source={viewsToSource(source?.views)}
placeholder={source.blurhash ? { blurhash: source.blurhash } : null}
transition={500}
{...props}
/>
) : null;
}
export default Animated.createAnimatedComponent(
React.forwardRef<ExpoImage, ImageProps>(function Image(
{ source, ...props }: ImageProps,
ref
) {
return (
<ExpoImage
ref={ref}
source={source ? viewsToSource(source?.views) : null}
placeholder={source?.blurhash ? { blurhash: source.blurhash } : null}
transition={500}
{...props}
/>
);
})
);
2 changes: 2 additions & 0 deletions src/components/content/Image/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './Image';
export * from './Image';
9 changes: 7 additions & 2 deletions src/screens/Landing/Intro/ScrollingPosters.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from 'react';
import { StyleSheet, View, ViewStyle, useWindowDimensions } from 'react-native';
import {
StyleSheet,
View,
useWindowDimensions,
type ViewStyle,
} from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import Animated, {
useDerivedValue,
Expand All @@ -9,7 +14,7 @@ import Animated, {
} from 'react-native-reanimated';
import { useQuery } from 'urql';

import Image, { ImageFragment } from '@/components/Image';
import Image, { ImageFragment } from '@/components/content/Image';
import { graphql } from '@/utils/graphql';

const ScrollingPostersQuery = graphql(
Expand Down

0 comments on commit e5f773d

Please sign in to comment.