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

Add News Image Above Title #635

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 1 addition & 3 deletions src/views/account/News/Atoms/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ const NewsListItem: React.FC<NewsListItemProps> = ({ index, message, navigation,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
marginTop: 6,
}}
>
<NativeText
numberOfLines={1}
variant="subtitle"
style={{
marginTop: 6,
}}
>
{formatDate(message.date)}
</NativeText>
Expand Down
38 changes: 28 additions & 10 deletions src/views/account/News/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,28 @@ const NewsScreen: Screen<"News"> = ({ route, navigation }) => {
}
}, [informations, account.personalization.MagicNews]);

const renderItem: ListRenderItem<NewsItem> = useCallback(({ item, index }) => (
<NewsListItem
key={index}
index={index}
message={item}
navigation={navigation}
parentMessages={sortedMessages}
isED={account.service == AccountService.EcoleDirecte}
/>
), [navigation, sortedMessages]);
const renderItem: ListRenderItem<NewsItem> = useCallback(({ item, index }) => {
const imageUri = item.attachments?.[0]?.url;

return (
<View key={index} style={{ marginBottom: 16 }}>
{imageUri && (
<Image
source={{ uri: imageUri }}
style={styles.newsImage}
resizeMode="cover"
/>
)}
<NewsListItem
index={index}
message={item}
navigation={navigation}
parentMessages={sortedMessages}
isED={account.service == AccountService.EcoleDirecte}
/>
Kertie2 marked this conversation as resolved.
Show resolved Hide resolved
</View>
);
}, [navigation, sortedMessages]);

const NoNewsMessage = () => (
<View
Expand Down Expand Up @@ -185,6 +197,12 @@ const NewsScreen: Screen<"News"> = ({ route, navigation }) => {
};

const styles = StyleSheet.create({
newsImage: {
width: "100%",
height: 200,
borderRadius: 8,
marginBottom: 8,
},
Comment on lines +189 to +194

Choose a reason for hiding this comment

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

@Kertie2 tu peux retirer ça du coup vu que l'image n'est plus dans ce fichier

scrollViewContent: {
padding: 16,
paddingTop: 0,
Expand Down