From 586778b74f5655c1b478ba6cbbb40cc62228af99 Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:24:05 +0100 Subject: [PATCH 01/11] Update News.tsx --- src/views/account/News/News.tsx | 38 ++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/views/account/News/News.tsx b/src/views/account/News/News.tsx index bbe55936c..30839c2e4 100644 --- a/src/views/account/News/News.tsx +++ b/src/views/account/News/News.tsx @@ -91,16 +91,28 @@ const NewsScreen: Screen<"News"> = ({ route, navigation }) => { } }, [informations, account.personalization.MagicNews]); - const renderItem: ListRenderItem = useCallback(({ item, index }) => ( - - ), [navigation, sortedMessages]); + const renderItem: ListRenderItem = useCallback(({ item, index }) => { + const imageUri = item.attachments?.[0]?.url; + + return ( + + {imageUri && ( + + )} + + + ); + }, [navigation, sortedMessages]); const NoNewsMessage = () => ( = ({ route, navigation }) => { }; const styles = StyleSheet.create({ + newsImage: { + width: "100%", + height: 200, + borderRadius: 8, + marginBottom: 8, + }, scrollViewContent: { padding: 16, paddingTop: 0, From 7439809b85a65dedc877b68fb197c0de8cb1e72e Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 01:01:04 +0100 Subject: [PATCH 02/11] Update Item.tsx --- src/views/account/News/Atoms/Item.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index e67293df0..860edef14 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -72,14 +72,12 @@ const NewsListItem: React.FC = ({ index, message, navigation, flexDirection: "row", alignItems: "center", justifyContent: "space-between", + marginTop: 6, }} > {formatDate(message.date)} From 6fb6df4ac7419cd0b75450c93a8d1d3d3732487d Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 15:25:28 +0100 Subject: [PATCH 03/11] Update Item.tsx --- src/views/account/News/Atoms/Item.tsx | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index 860edef14..f01657158 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -1,12 +1,13 @@ import { useTheme } from "@react-navigation/native"; import React from "react"; -import { View } from "react-native"; +import { Image, StyleSheet, View } from "react-native"; import { NativeItem, NativeText } from "@/components/Global/NativeComponents"; import parse_news_resume from "@/utils/format/format_pronote_news"; import formatDate from "@/utils/format/format_date_complets"; import { NativeStackNavigationProp } from "@react-navigation/native-stack"; import { RouteParameters } from "@/router/helpers/types"; import { Information } from "@/services/shared/Information"; +import { AttachmentType } from "@/services/shared/Attachment"; type NewsItem = Omit & { date: string, important: boolean }; @@ -20,6 +21,17 @@ interface NewsListItemProps { const NewsListItem: React.FC = ({ index, message, navigation, parentMessages, isED }) => { const theme = useTheme(); + const newsImage = message.attachments.find((attachment) => { + if (attachment.type !== AttachmentType.File) { + return + } + const extension = attachment.name.split(".").pop()?.split("?")[0].toLowerCase(); + if (!extension) { + return + } + console.log(extension); + return ["jpg", "jpeg", "png"].includes(extension); + }) return ( { @@ -32,6 +44,13 @@ const NewsListItem: React.FC = ({ index, message, navigation, chevron={false} separator={index !== parentMessages.length - 1} > + {newsImage && ( + + )} = ({ index, message, navigation, ); }; +const styles = StyleSheet.create({ + newsImage: { + width: "100%", + height: 200, + borderRadius: 8, + marginBottom: 8, + }, +}); + export default NewsListItem; From 6edb40c5a8baa41075bd1743014107fc077dcbbd Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 15:26:36 +0100 Subject: [PATCH 04/11] Update News.tsx --- src/views/account/News/News.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/views/account/News/News.tsx b/src/views/account/News/News.tsx index 30839c2e4..834dafe82 100644 --- a/src/views/account/News/News.tsx +++ b/src/views/account/News/News.tsx @@ -91,18 +91,8 @@ const NewsScreen: Screen<"News"> = ({ route, navigation }) => { } }, [informations, account.personalization.MagicNews]); - const renderItem: ListRenderItem = useCallback(({ item, index }) => { - const imageUri = item.attachments?.[0]?.url; - + const renderItem: ListRenderItem = useCallback(({ item, index }) => { return ( - - {imageUri && ( - - )} = ({ route, navigation }) => { parentMessages={sortedMessages} isED={account.service == AccountService.EcoleDirecte} /> - ); }, [navigation, sortedMessages]); From 29d3ba29e4491e6957898051e8cb727ea28f8d72 Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:23:24 +0100 Subject: [PATCH 05/11] Update src/views/account/News/Atoms/Item.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 𝕂𝕪𝕝𝕚𝕒𝕟 <164187100+Kgeek33@users.noreply.github.com> --- src/views/account/News/Atoms/Item.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index f01657158..56622d61d 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -21,7 +21,7 @@ interface NewsListItemProps { const NewsListItem: React.FC = ({ index, message, navigation, parentMessages, isED }) => { const theme = useTheme(); - const newsImage = message.attachments.find((attachment) => { + const newsImage = message.attachments.find((attachment) => { if (attachment.type !== AttachmentType.File) { return } From 819959963d79105f0ad78b876196e9456d2aa853 Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:23:34 +0100 Subject: [PATCH 06/11] Update src/views/account/News/Atoms/Item.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 𝕂𝕪𝕝𝕚𝕒𝕟 <164187100+Kgeek33@users.noreply.github.com> --- src/views/account/News/Atoms/Item.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index 56622d61d..550b792d3 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -23,7 +23,7 @@ const NewsListItem: React.FC = ({ index, message, navigation, const theme = useTheme(); const newsImage = message.attachments.find((attachment) => { if (attachment.type !== AttachmentType.File) { - return + return; } const extension = attachment.name.split(".").pop()?.split("?")[0].toLowerCase(); if (!extension) { From e7bd7bc8a7087d5aea6ebe4ec8ed9fc5abaa809b Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:23:41 +0100 Subject: [PATCH 07/11] Update src/views/account/News/Atoms/Item.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 𝕂𝕪𝕝𝕚𝕒𝕟 <164187100+Kgeek33@users.noreply.github.com> --- src/views/account/News/Atoms/Item.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index 550b792d3..5185f03f9 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -27,7 +27,7 @@ const NewsListItem: React.FC = ({ index, message, navigation, } const extension = attachment.name.split(".").pop()?.split("?")[0].toLowerCase(); if (!extension) { - return + return; } console.log(extension); return ["jpg", "jpeg", "png"].includes(extension); From bc40660d5becbbafd099ae4e0121113e3299ed7f Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:23:49 +0100 Subject: [PATCH 08/11] Update src/views/account/News/Atoms/Item.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 𝕂𝕪𝕝𝕚𝕒𝕟 <164187100+Kgeek33@users.noreply.github.com> --- src/views/account/News/Atoms/Item.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index 5185f03f9..f97c888b3 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -29,7 +29,6 @@ const NewsListItem: React.FC = ({ index, message, navigation, if (!extension) { return; } - console.log(extension); return ["jpg", "jpeg", "png"].includes(extension); }) return ( From 3e3303f6ac2aae8654799e28457de8cb321e687e Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:23:57 +0100 Subject: [PATCH 09/11] Update src/views/account/News/Atoms/Item.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 𝕂𝕪𝕝𝕚𝕒𝕟 <164187100+Kgeek33@users.noreply.github.com> --- src/views/account/News/Atoms/Item.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index f97c888b3..c6561b96c 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -30,7 +30,7 @@ const NewsListItem: React.FC = ({ index, message, navigation, return; } return ["jpg", "jpeg", "png"].includes(extension); - }) + }); return ( { From aadc453b716b7175d4c7e32f8f43fc6510739b96 Mon Sep 17 00:00:00 2001 From: Kertie2 <138666415+Kertie2@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:24:06 +0100 Subject: [PATCH 10/11] Update src/views/account/News/News.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 𝕂𝕪𝕝𝕚𝕒𝕟 <164187100+Kgeek33@users.noreply.github.com> --- src/views/account/News/News.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/account/News/News.tsx b/src/views/account/News/News.tsx index 834dafe82..36643e7f5 100644 --- a/src/views/account/News/News.tsx +++ b/src/views/account/News/News.tsx @@ -91,7 +91,7 @@ const NewsScreen: Screen<"News"> = ({ route, navigation }) => { } }, [informations, account.personalization.MagicNews]); - const renderItem: ListRenderItem = useCallback(({ item, index }) => { + const renderItem: ListRenderItem = useCallback(({ item, index }) => { return ( Date: Sun, 12 Jan 2025 20:24:16 +0100 Subject: [PATCH 11/11] Update src/views/account/News/News.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 𝕂𝕪𝕝𝕚𝕒𝕟 <164187100+Kgeek33@users.noreply.github.com> --- src/views/account/News/News.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/views/account/News/News.tsx b/src/views/account/News/News.tsx index 36643e7f5..e9cec6832 100644 --- a/src/views/account/News/News.tsx +++ b/src/views/account/News/News.tsx @@ -93,13 +93,13 @@ const NewsScreen: Screen<"News"> = ({ route, navigation }) => { const renderItem: ListRenderItem = useCallback(({ item, index }) => { return ( - + ); }, [navigation, sortedMessages]);