Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve] repositioned promoted text #2804

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/postCard/children/postCardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { TouchableOpacity, Text, View } from 'react-native';

// Utils
import FastImage from 'react-native-fast-image';
import { get } from 'lodash';
import { useIntl } from 'react-intl';

// Components

Expand Down Expand Up @@ -36,12 +38,14 @@ export const PostCardContent = ({
setImageRatio,
handleCardInteraction,
}: Props) => {
const intl = useIntl();
const imgWidth = dim.width - 18;
const [calcImgHeight, setCalcImgHeight] = useState(imageRatio ? imgWidth / imageRatio : 300);

const resizeMode = useMemo(() => {
return calcImgHeight < dim.height ? FastImage.resizeMode.contain : FastImage.resizeMode.cover;
}, [dim.height]);
const isPromoted = get(content, 'is_promoted', false);

const _onPress = () => {
handleCardInteraction(PostCardActionIds.NAVIGATE, {
Expand Down Expand Up @@ -92,6 +96,9 @@ export const PostCardContent = ({
)}

<View style={[styles.postDescripton]}>
{!!isPromoted && (
<Text style={styles.promotedText}>{intl.formatMessage({ id: 'post.promoted' })}</Text>
)}
<Text style={styles.title}>{content.title}</Text>
<Text style={styles.summary}>{content.summary}</Text>
</View>
Expand Down
6 changes: 6 additions & 0 deletions src/components/postCard/children/postCardStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,10 @@ export default EStyleSheet.create({
textAlign: 'center',
fontSize: 18,
},
promotedText: {
fontSize: 14,
fontWeight: '300',
color: '$primaryDarkGray',
marginTop: 6,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be try adding negative bottom margin/padding here to make upper and lower spacing more fine tuned
Screenshot 2023-12-18 at 15 38 19

},
});
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ class PostHeaderDescription extends PureComponent {
<Text style={styles.name}>{name}</Text>
</TouchableOpacity>

{inlineTime && (
<Text style={styles.date}>
{isPromoted ? intl.formatMessage({ id: 'post.promoted' }) : date}
</Text>
)}
{inlineTime && <Text style={styles.date}>{date}</Text>}

{isShowOwnerIndicator && (
<Icon style={styles.ownerIndicator} name="stars" iconType="MaterialIcons" />
Expand Down Expand Up @@ -165,11 +161,7 @@ class PostHeaderDescription extends PureComponent {
</TouchableOpacity>
)}

{!inlineTime && (
<Text style={styles.date}>
{isPromoted ? intl.formatMessage({ id: 'post.promoted' }) : date}
</Text>
)}
{!inlineTime && <Text style={styles.date}>{date}</Text>}
</View>
</View>
</View>
Expand Down