Skip to content

Commit

Permalink
chore: adaptive news images size (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-hades authored Feb 6, 2024
1 parent 2725631 commit d4e3e4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/screens/News/components/FeaturedNewsArticle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {ClockIcon} from '@svg/ClockIcon';
import {EyeIcon} from '@svg/EyeIcon';
import {NewsFeaturedNewBadge} from '@svg/NewsFeaturedNewBadge';
import {t} from '@translations/i18n';
import {getImageUriForSize} from '@utils/file';
import {formatNumber} from '@utils/numbers';
import {font} from '@utils/styles';
import React, {memo} from 'react';
Expand All @@ -19,7 +20,7 @@ import LinearGradient from 'react-native-linear-gradient';
import Animated, {SharedValue} from 'react-native-reanimated';
import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
import {useSelector} from 'react-redux';
import {rem} from 'rn-units';
import {rem, screenWidth} from 'rn-units';

import {useLayoutAnimation} from './hooks/useLayoutAnimation';

Expand Down Expand Up @@ -70,7 +71,7 @@ export const FeaturedNewsArticle = memo(
<Image
style={StyleSheet.absoluteFill}
source={{
uri: imageUrl,
uri: getImageUriForSize(imageUrl, {width: screenWidth}),
}}
/>

Expand Down
7 changes: 5 additions & 2 deletions src/screens/News/components/NewsArticle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {ClockIcon} from '@svg/ClockIcon';
import {EyeIcon} from '@svg/EyeIcon';
import {NewsNewBadge} from '@svg/NewsNewBadge';
import {t} from '@translations/i18n';
import {getImageUriForSize} from '@utils/file';
import {formatNumber} from '@utils/numbers';
import {font} from '@utils/styles';
import React, {memo} from 'react';
Expand All @@ -23,6 +24,8 @@ type Props = {
newsArticleId: string;
};

const IMAGE_WIDTH = rem(80);

export const NewsArticle = memo(({newsArticleId}: Props) => {
const newsArticle = useSelector(NewsSelectors.getNewsArticle(newsArticleId));

Expand All @@ -43,7 +46,7 @@ export const NewsArticle = memo(({newsArticleId}: Props) => {
<Image
style={styles.image}
source={{
uri: imageUrl,
uri: getImageUriForSize(imageUrl, {width: IMAGE_WIDTH}),
}}
/>

Expand Down Expand Up @@ -135,7 +138,7 @@ const styles = StyleSheet.create({
},

image: {
width: rem(80),
width: IMAGE_WIDTH,
height: rem(72),
justifyContent: 'center',
alignItems: 'center',
Expand Down

0 comments on commit d4e3e4c

Please sign in to comment.