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

[home] Update content card #63

Merged
merged 22 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion src/app/(tabs)/author/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { SafeAreaView } from 'react-native-safe-area-context';

import styles from './styles';
import BackButton from '../../../components/BackButton/BackButton';
import ContentCard from '../../../components/ContentCard/ContentCard';
import HorizontalLine from '../../../components/HorizontalLine/HorizontalLine';
import PreviewCard from '../../../components/PreviewCard/PreviewCard';
import {
Expand Down
7 changes: 5 additions & 2 deletions src/app/(tabs)/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function HomeScreen() {
fetchRecommendedStories().catch(() => []),
fetchNewStories().catch(() => []),
]);

setUsername(usernameResponse);
setFeaturedStories(featuredStoryResponse);
setFeaturedStoriesDescription(featuredStoryDescriptionResponse);
Expand Down Expand Up @@ -115,13 +116,14 @@ function HomeScreen() {
horizontal
showsHorizontalScrollIndicator={false}
bounces={false}
style={styles.scrollView}
style={styles.scrollView1}
>
{recommendedStories.map(story => (
<ContentCard
key={story.title}
title={story.title}
author={story.author_name}
authorImage={story.author_image}
pressFunction={() =>
router.push({
pathname: '/story',
Expand All @@ -143,13 +145,14 @@ function HomeScreen() {
horizontal
showsHorizontalScrollIndicator={false}
bounces={false}
style={styles.scrollView}
style={styles.scrollView2}
>
{newStories.map(story => (
<ContentCard
key={story.title}
title={story.title}
author={story.author_name}
authorImage={story.author_image}
pressFunction={() =>
router.push({
pathname: '/story',
Expand Down
10 changes: 8 additions & 2 deletions src/app/(tabs)/home/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ const styles = StyleSheet.create({
marginTop: 12,
marginBottom: 16,
},
scrollView: {
marginBottom: 20,
scrollView1: {
paddingBottom: 16,
flexGrow: 0,
padding: 8,
},
scrollView2: {
paddingBottom: 80,
flexGrow: 0,
padding: 8,
},
headerContainer: {
flexDirection: 'row',
Expand Down
7 changes: 4 additions & 3 deletions src/app/(tabs)/search/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import { SearchBar } from '@rneui/themed';
import { router } from 'expo-router';
import { useEffect, useState } from 'react';
import { Fragment, useEffect, useState } from 'react';
import {
Button,
FlatList,
Expand Down Expand Up @@ -286,7 +286,7 @@ function SearchScreen() {
contentContainerStyle={{ paddingHorizontal: 8 }}
>
{allGenres.map((genre, index) => (
<>
<Fragment key={index}>
<View style={styles.genreText}>
<Text style={styles.parentName}>{genre.parent_name}</Text>
<Text style={styles.seeAll}>See All</Text>
Expand All @@ -299,13 +299,14 @@ function SearchScreen() {
>
{genre.subgenres.map(subgenre => (
<GenreCard
key={subgenre.id}
subgenres={subgenre.name}
cardColor={getColor(index)}
pressFunction={() => null}
/>
))}
</ScrollView>
</>
</Fragment>
))}
</ScrollView>
) : (
Expand Down
3 changes: 1 addition & 2 deletions src/app/(tabs)/story/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ function StoryScreen() {
ref={scrollRef}
showsVerticalScrollIndicator={false}
>
{/* <Image style={styles.image} source={{ uri: story.featured_media }} /> */}

<Text style={[globalStyles.h1, styles.title]}>{story?.title}</Text>

<TouchableOpacity
onPress={() => {
router.push({
Expand Down
5 changes: 0 additions & 5 deletions src/app/(tabs)/story/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ const styles = StyleSheet.create({
paddingRight: 24,
paddingTop: 48,
},
image: {
width: '100%',
height: 153,
marginBottom: 16,
},
authorImage: {
backgroundColor: '#D9D9D9',
width: 21,
Expand Down
66 changes: 61 additions & 5 deletions src/components/ContentCard/ContentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Pressable,
Text,
View,
TouchableOpacity,
} from 'react-native';

import styles from './styles';
Expand All @@ -13,26 +14,81 @@ type ContentCardProps = {
title: string;
author: string;
image: string;
authorImage: string;
pressFunction: (event: GestureResponderEvent) => void;
};

function ContentCard({
title,
author,
image,
authorImage,
pressFunction,
}: ContentCardProps) {
const saveStory = () => {
console.log("testing '+' icon does something for story " + title);
};

return (
<Pressable onPress={pressFunction}>
<View style={styles.contentCard}>
<Image style={styles.image} source={{ uri: image }} />
<View style={{ flexDirection: 'row' }}>
<Image style={styles.image} source={{ uri: image }} />
<Image
style={styles.authors}
source={{
uri: authorImage,
}}
/>
</View>

<View style={styles.textContainer}>
<Text style={[globalStyles.h3, styles.title]} numberOfLines={1}>
<Text
style={[globalStyles.subHeading2, styles.title]}
numberOfLines={1}
>
{title}
</Text>
<Text style={globalStyles.body1} numberOfLines={1}>
{author}
</Text>
<View style={styles.authorSpacing}>
<Text style={styles.by} numberOfLines={1}>
By
</Text>
<Text style={globalStyles.subtext} numberOfLines={1}>
{author}
</Text>
</View>
<View style={styles.buttons}>
<View>
<TouchableOpacity
onPress={() => null}
style={{ flexDirection: 'row' }}
>
<Image
style={styles.reactions}
source={require('./savedStoriesIcon.png')}
/>
<Image
style={styles.reactions}
source={require('./savedStoriesIcon.png')}
/>
<Image
style={styles.reactions}
source={require('./savedStoriesIcon.png')}
/>
<View style={styles.reactionNumber}>
<Text style={[globalStyles.subtext, styles.reactionText]}>
14{/*change number to work*/}
</Text>
</View>
</TouchableOpacity>
</View>
<TouchableOpacity onPress={() => saveStory()}>
<Image
style={{ width: 30, height: 30 }}
source={require('./savedStoriesIcon.png')}
/>
</TouchableOpacity>
</View>
</View>
</View>
</Pressable>
Expand Down
Binary file added src/components/ContentCard/savedStoriesIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 60 additions & 2 deletions src/components/ContentCard/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,77 @@ const styles = StyleSheet.create({
marginRight: 20,
flexDirection: 'column',
justifyContent: 'space-between',
backgroundColor: '#FFF',
borderRadius: 6,
shadowColor: colors.black,
shadowOpacity: 0.5,
shadowOffset: { width: 0, height: 4 },
shadowRadius: 5,
elevation: 4,
},
image: {
margin: 10,
justifyContent: 'center',
alignItems: 'center',
height: 140,
width: 148,
backgroundColor: colors.lime,
borderRadius: 4,
marginBottom: 8,
},
authors: {
width: 30,
height: 30,
borderRadius: 30,
borderWidth: 1,
backgroundColor: '#89CFF0',
borderColor: 'white',
marginTop: 15,
marginLeft: -45,
flexDirection: 'row',
},
textContainer: {
width: 148,
width: 166,
paddingLeft: 10,
paddingRight: 10,
paddingBottom: 10,
},
title: {
marginBottom: 4,
marginBottom: 8,
padding: 0,
},
reactionText: {
color: colors.grey,
},
reactionNumber: {
marginLeft: 15,
marginTop: 10,
},
reactions: {
width: 20,
height: 20,
borderRadius: 20 / 2,
borderWidth: 1,
backgroundColor: '#89CFF0', //different per emoji reaction
borderColor: 'white',
marginTop: 10,
marginRight: -10,
},
buttons: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 5,
},
by: {
fontFamily: 'Manrope-Regular',
fontSize: 10,
color: colors.grey,
},
authorSpacing: {
flexDirection: 'row',
alignItems: 'center',
gap: 4,
overflow: 'hidden',
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/PreviewCard/PreviewCard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as cheerio from 'cheerio';
import {
GestureResponderEvent,
Image,
Pressable,
Text,
View,
} from 'react-native';
import * as cheerio from 'cheerio';

import styles from './styles';
import globalStyles from '../../styles/globalStyles';
Expand Down
1 change: 1 addition & 0 deletions src/queries/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface StoryCard {
title: string;
author_name: string;
featured_media: string;
author_image: string;
}

export interface Subgenre {
Expand Down
Loading