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

Feat(News): intégration "J'ai pris connaissance..." + changes #281

Merged
merged 33 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
64b0cac
intégration acknowledge + changes
Kgeek33 Oct 9, 2024
2635045
Merge branch 'PapillonApp:main' into feat/accuseNews
Kgeek33 Oct 9, 2024
29ff543
quelques fix
Kgeek33 Oct 11, 2024
7927e0b
Merge branch 'PapillonApp:main' into feat/accuseNews
Kgeek33 Oct 11, 2024
f6e5bdc
Merge branch 'main' into feat/accuseNews
Kgeek33 Oct 13, 2024
5ce6b8b
fix conflit + supp "contentContainerStyle "
Kgeek33 Oct 13, 2024
01905e3
Merge remote-tracking branch 'upstream/main' into feat/accuseNews
Kgeek33 Oct 15, 2024
7f01527
correction des conflits !!
Kgeek33 Oct 15, 2024
3890f62
correction d'un affichage aléatoire
Kgeek33 Oct 15, 2024
f7a6ca3
Merge remote-tracking branch 'upstream/main' into feat/accuseNews
Kgeek33 Oct 18, 2024
9583102
Merge remote-tracking branch 'upstream/main' into feat/accuseNews
Kgeek33 Oct 19, 2024
7edd528
marquer comme lu/non lu disponible sauf pour ED
Kgeek33 Oct 19, 2024
6e58c5b
correction indentation Prettier + _ sur la variable event
Kgeek33 Oct 21, 2024
c53f2f4
Merge remote-tracking branch 'upstream/main' into feat/accuseNews
Kgeek33 Oct 21, 2024
6d266c7
Merge remote-tracking branch 'upstream/main' into feat/accuseNews
Kgeek33 Oct 22, 2024
12628f9
Merge remote-tracking branch 'upstream/main' into feat/accuseNews
Kgeek33 Oct 25, 2024
e62f59c
Merge branch 'main' into feat/accuseNews
Kgeek33 Oct 26, 2024
1c77526
fix typage
Kgeek33 Oct 26, 2024
756dced
Merge branch 'main' into feat/accuseNews
Kgeek33 Oct 27, 2024
41c27d8
Merge branch 'main' into feat/accuseNews
Kgeek33 Oct 30, 2024
211ce4e
Merge branch 'main' into feat/accuseNews
Kgeek33 Nov 3, 2024
107f3e0
Merge branch 'main' into feat/accuseNews
Kgeek33 Nov 11, 2024
ce47924
Merge branch 'main' into feat/accuseNews
Kgeek33 Nov 11, 2024
de4983a
Merge branch 'PapillonApp:main' into feat/accuseNews
Kgeek33 Nov 15, 2024
a3484d4
correction suppression actualités lors du filtrage avec Papillon Magic
Kgeek33 Nov 16, 2024
36ecda3
correction conflit ed et les autres services
Kgeek33 Nov 16, 2024
ad52a75
intrégration fix erreur <FlatList>
Kgeek33 Nov 16, 2024
b0761e0
Merge branch 'main' into feat/accuseNews
Kgeek33 Nov 16, 2024
2b28196
fix erreur translation
Kgeek33 Nov 16, 2024
de7ac99
Merge branch 'main' into feat/accuseNews
Kgeek33 Nov 18, 2024
6917567
Merge branch 'main' into feat/accuseNews
Kgeek33 Nov 21, 2024
91ad2fa
Merge branch 'main' into feat/accuseNews
Kgeek33 Nov 25, 2024
9487cdc
fix(ui): Apparence du "j'ai pris connaissance"
ecnivtwelve Nov 26, 2024
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: 1 addition & 0 deletions src/router/screens/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default [
headerTitle: "Item",
presentation: "modal",
headerShown: false,
animation: "slide_from_right",
}),
createScreen("AddonLogs", AddonLogs, {
headerTitle: "Logs",
Expand Down
137 changes: 99 additions & 38 deletions src/views/account/News/Document.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import InsetsBottomView from "@/components/Global/InsetsBottomView";
import { NativeItem, NativeList, NativeListHeader, NativeText } from "@/components/Global/NativeComponents";
import {
NativeItem,
NativeList,
NativeListHeader,
NativeText,
} from "@/components/Global/NativeComponents";
import InitialIndicator from "@/components/News/InitialIndicator";
import { Information } from "@/services/shared/Information";
import formatDate from "@/utils/format/format_date_complets";
Expand All @@ -11,22 +16,25 @@ import {
Link,
MoreHorizontal,
} from "lucide-react-native";
import React, { useEffect, useLayoutEffect } from "react";
import {View, Dimensions, Linking, TouchableOpacity, type GestureResponderEvent} from "react-native";
import React, { useEffect, useLayoutEffect, useState } from "react";
import {View, Dimensions, Linking, TouchableOpacity, type GestureResponderEvent, Text} from "react-native";
import { ScrollView } from "react-native-gesture-handler";
import RenderHtml from "react-native-render-html";
import { PapillonModernHeader} from "@/components/Global/PapillonModernHeader";
import {LinearGradient} from "expo-linear-gradient";
import {setNewsRead} from "@/services/news";
import {useCurrentAccount} from "@/stores/account";
import { PapillonModernHeader } from "@/components/Global/PapillonModernHeader";
import { LinearGradient } from "expo-linear-gradient";
import { setNewsRead } from "@/services/news";
import { useCurrentAccount } from "@/stores/account";
import PapillonPicker from "@/components/Global/PapillonPicker";
import {Screen} from "@/router/helpers/types";
import {AttachmentType} from "@/services/shared/Attachment";
import PapillonCheckbox from "@/components/Global/PapillonCheckbox";
import { newsInformationAcknowledge } from "pawnote";
import parse_initials from "@/utils/format/format_pronote_initials";
import { selectColorSeed } from "@/utils/format/select_color_seed";
import { AccountService } from "@/stores/account/types";

const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {
let message = JSON.parse(route.params.message) as Information;
const [message, setMessage] = useState<Information>(JSON.parse(route.params.message) as Information);
const important = route.params.important;
const isED = route.params.isED;
const account = useCurrentAccount((store) => store.account!);
Expand All @@ -41,7 +49,10 @@ const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {

useEffect(() => {
setNewsRead(account, message, true);
message.read = true;
setMessage((prev) => ({
...prev,
read: true,
}));
}, [account.instance]);

const tagsStyles = {
Expand All @@ -60,14 +71,14 @@ const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {

const renderersProps = {
a: {
onPress: onPress
}
onPress: onPress,
},
};

return (
<View style={{flex: 1}}>
<View style={{ flex: 1 }}>
<PapillonModernHeader native height={110} outsideNav={true}>
<View style={{flexDirection: "row", gap: 12, alignItems: "center"}}>
<View style={{ flexDirection: "row", gap: 12, alignItems: "center" }}>
<InitialIndicator
initial={parse_initials(message.author)}
color={selectColorSeed(message.author)}
Expand All @@ -76,30 +87,41 @@ const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {
<NativeText variant="title" numberOfLines={1}>{message.title === "" ? message.author : message.title}</NativeText>
<NativeText variant="subtitle" numberOfLines={1}>{message.title === "" ? formatDate(message.date.toDateString()) : message.author}</NativeText>
</View>
{isED && <PapillonPicker
animated
direction="right"
delay={0}
data={[
{
icon: message.read ? <EyeOff /> : <Eye />,
label: message.read ? "Marquer comme non lu" : "Marquer comme lu",
onPress: () => {
setNewsRead(account, message, !message.read);
message.read = !message.read;
}
}
]}
>
<TouchableOpacity>
<MoreHorizontal size={24} color={theme.colors.text} />
</TouchableOpacity>
</PapillonPicker>}
{!isED && (
<PapillonPicker
animated
direction="right"
delay={0}
data={[
{
icon: message.read ? <EyeOff /> : <Eye />,
label: message.read
? "Marquer comme non lu"
: "Marquer comme lu",
onPress: () => {
setNewsRead(account, message, !message.read);
setMessage((prev) => ({
...prev,
read: !prev.read,
}));
},
},
]}
>
<TouchableOpacity>
<MoreHorizontal size={24} color={theme.colors.text} />
</TouchableOpacity>
</PapillonPicker>
)}
</View>
</PapillonModernHeader>
{important && (
<LinearGradient
colors={!theme.dark ? [theme.colors.card, "#BFF6EF"] : [theme.colors.card, "#2C2C2C"]}
colors={
!theme.dark
? [theme.colors.card, "#BFF6EF"]
: [theme.colors.card, "#2C2C2C"]
}
start={[0, 0]}
end={[2, 2]}
style={{
Expand All @@ -117,15 +139,54 @@ const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {
<ScrollView
style={{
flex: 1,
}}
contentContainerStyle={{
paddingBottom: 16,
paddingTop: 106,
}}
>
<View style={{paddingHorizontal: 16}}>
<View
style={{
paddingHorizontal: 16,
}}
>
{account.service === AccountService.Pronote && message.ref.needToAcknowledge && (
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: 10,
marginBottom: 25,
}}
>
<PapillonCheckbox
checked={message.acknowledged}
onPress={async () => {
if (!message.acknowledged && account.instance) {
await newsInformationAcknowledge(
account.instance,
message.ref
);

setMessage((prev) => ({
...prev,
read: true,
acknowledged: true,
}));
}
}}
style={{ marginLeft: 25 }}
color="green"
/>
<Text
style={{
color: message.acknowledged ? "grey" : theme.colors.text,
}}
>
J'ai lu et pris connaissance
</Text>
</View>
)}
<RenderHtml
contentWidth={Dimensions.get("window").width - (16 * 2)}
contentWidth={Dimensions.get("window").width - 16 * 2}
source={{
html: message.content,
}}
Expand Down Expand Up @@ -164,7 +225,7 @@ const NewsItem: Screen<"NewsItem"> = ({ route, navigation }) => {
</ScrollView>}

{message.attachments.length > 0 && (
<View style={{paddingHorizontal: 16}}>
<View style={{ paddingHorizontal: 16 }}>
<NativeListHeader label="Pièces jointes" />
<NativeList>
{message.attachments.map((attachment, index) => (
Expand Down
Loading