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(home): Ajout de rubriques quand vide #655

Merged
merged 7 commits into from
Jan 20, 2025
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
2 changes: 1 addition & 1 deletion src/components/Grades/AnimatedEmoji.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import { View, Text } from "react-native";
import { View } from "react-native";
import Animated, {
useAnimatedStyle,
useSharedValue,
Expand Down
4 changes: 1 addition & 3 deletions src/components/Grades/GradeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import {
Image,
TouchableOpacity,
Text,
Platform,
Alert
} from "react-native";
import { Download, Trash, Maximize2, Share, Delete } from "lucide-react-native";
import { Download, Trash, Share } from "lucide-react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { BlurView } from "expo-blur";
import { ScrollView } from "react-native-gesture-handler";
import * as Sharing from "expo-sharing";
import * as FileSystem from "expo-file-system";
import * as MediaLibrary from "expo-media-library";
Expand Down
8 changes: 3 additions & 5 deletions src/router/navigator/atoms/MenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as React from "react";
import { useCurrentAccount } from "@/stores/account";
import { useNavigationBuilder, useTheme } from "@react-navigation/native";
import { StyleSheet, View, Text, Platform } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useTheme } from "@react-navigation/native";
import { StyleSheet, Platform } from "react-native";
import LottieView from "lottie-react-native";
import colorsList from "@/utils/data/colors.json";
import { Pressable } from "react-native-gesture-handler";
import * as Haptics from "expo-haptics";
import Reanimated, { FadeIn, FadeOut, LinearTransition, ZoomIn } from "react-native-reanimated";
import Reanimated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
import { anim2Papillon } from "@/utils/ui/animations";

const MenuItem: React.FC<{
Expand Down
6 changes: 2 additions & 4 deletions src/router/navigator/atoms/TabItem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as React from "react";
import { useCurrentAccount } from "@/stores/account";
import { useNavigationBuilder, useTheme } from "@react-navigation/native";
import { StyleSheet, View, Text, Platform } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useTheme } from "@react-navigation/native";
import { StyleSheet, Platform } from "react-native";
import LottieView from "lottie-react-native";
import colorsList from "@/utils/data/colors.json";
import { Pressable } from "react-native-gesture-handler";
Expand Down
10 changes: 3 additions & 7 deletions src/router/navigator/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React, { useEffect, useMemo, useState } from "react";
import React, { useMemo, useState } from "react";
import { useCurrentAccount } from "@/stores/account";
import { useNavigationBuilder, useTheme } from "@react-navigation/native";
import { StyleSheet, View, ScrollView, Platform, Image, Text, StatusBar } from "react-native";
import { StyleSheet, Platform, Image, Text, StatusBar } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import TabItem from "./atoms/TabItem";

import Reanimated, { LinearTransition, useSharedValue } from "react-native-reanimated";
import Reanimated from "react-native-reanimated";
import MenuItem from "./atoms/MenuItem";
import AccountSwitcher from "@/components/Home/AccountSwitcher";
import ContextMenu from "@/components/Home/AccountSwitcherContextMenu";
import { NativeText } from "@/components/Global/NativeComponents";
import { defaultProfilePicture } from "@/utils/ui/default-profile-picture";
import { he } from "date-fns/locale";

const PapillonNavigatorMenu: React.FC<Omit<ReturnType<typeof useNavigationBuilder>, "NavigationContent">> = ({ state, descriptors, navigation }) => {
const theme = useTheme();
Expand Down
3 changes: 1 addition & 2 deletions src/router/navigator/navigator.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { BottomTabView } from "@react-navigation/bottom-tabs";
import { createNavigatorFactory, TabRouter, useNavigationBuilder } from "@react-navigation/native";
import PapillonNavigatorTabs from "./tabs";
import { memo, useEffect, useMemo, useState } from "react";
import { Dimensions, View } from "react-native";
import { View } from "react-native";
import PapillonNavigatorMenu from "./menu";
import useScreenDimensions from "@/hooks/useScreenDimensions";

Expand Down
4 changes: 2 additions & 2 deletions src/router/navigator/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useEffect, useMemo, useState } from "react";
import { useCurrentAccount } from "@/stores/account";
import { useNavigationBuilder, useTheme } from "@react-navigation/native";
import { StyleSheet, View, Platform } from "react-native";
import { StyleSheet, Platform } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import TabItem from "./atoms/TabItem";

import Reanimated, { LinearTransition } from "react-native-reanimated";
import Reanimated from "react-native-reanimated";

const PapillonNavigatorTabs: React.FC<Omit<ReturnType<typeof useNavigationBuilder>, "NavigationContent">> = ({ state, descriptors, navigation }) => {
const theme = useTheme();
Expand Down
2 changes: 1 addition & 1 deletion src/views/account/Chat/Modals/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {Screen} from "@/router/helpers/types";
import { NativeText,} from "@/components/Global/NativeComponents";
import {useCurrentAccount} from "@/stores/account";
import type {ChatMessage, ChatRecipient} from "@/services/shared/Chat";
import {ChevronLeft, File, Link, Send} from "lucide-react-native";
import {ChevronLeft, Send} from "lucide-react-native";
import parse_initials from "@/utils/format/format_pronote_initials";
import InitialIndicator from "@/components/News/InitialIndicator";
import {PapillonModernHeader} from "@/components/Global/PapillonModernHeader";
Expand Down
6 changes: 1 addition & 5 deletions src/views/account/Grades/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ import {
import { getSubjectData } from "@/services/shared/Subject";
import { useTheme } from "@react-navigation/native";
import React, { useCallback, useEffect, useLayoutEffect, useState } from "react";
import { Image, ScrollView, Text, View, Platform, TouchableOpacity, Modal } from "react-native";
import { Image, ScrollView, Text, View, Platform, TouchableOpacity } from "react-native";
import * as StoreReview from "expo-store-review";
import {
Asterisk,
Calculator,
Download,
Expand,
Maximize2,
Scale,
School,
SmilePlus,
Trash,
UserMinus,
UserPlus,
Users,
Expand Down
40 changes: 20 additions & 20 deletions src/views/account/Grades/Graph/GradesAverage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,26 +329,26 @@ const GradesAverageGraph: React.FC<GradesAverageGraphProps> = ({
</Reanimated.View>
</View>
<View style={[styles.gradeInfo, styles.gradeRight]}>
<NativeText numberOfLines={1}>Moyenne classe</NativeText>
<Reanimated.View
style={[styles.gradeValue]}
layout={animPapillon(LinearTransition)}
>
{classAvg !== null ? (
<>
<AnimatedNumber
value={classAvg.toFixed(2)}
style={styles.gradeNumberClass}
/>
<Reanimated.View layout={animPapillon(LinearTransition)}>
<NativeText style={[styles.gradeOutOf]}>/20</NativeText>
</Reanimated.View>
</>
) : (
<NativeText style={styles.gradeNumberClass}>Inconnue</NativeText>
)}
</Reanimated.View>
</View>
<NativeText numberOfLines={1}>Moyenne classe</NativeText>
<Reanimated.View
style={[styles.gradeValue]}
layout={animPapillon(LinearTransition)}
>
{classAvg !== null ? (
<>
<AnimatedNumber
value={classAvg.toFixed(2)}
style={styles.gradeNumberClass}
/>
<Reanimated.View layout={animPapillon(LinearTransition)}>
<NativeText style={[styles.gradeOutOf]}>/20</NativeText>
</Reanimated.View>
</>
) : (
<NativeText style={styles.gradeNumberClass}>Inconnue</NativeText>
)}
</Reanimated.View>
</View>
</Reanimated.View>

{showDetails && maxAvg > 0 && minAvg > 0 ? (
Expand Down
25 changes: 23 additions & 2 deletions src/views/account/Home/Elements/AttendanceElement.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useEffect } from "react";
import { NativeListHeader } from "@/components/Global/NativeComponents";
import { NativeItem, NativeList, NativeListHeader } from "@/components/Global/NativeComponents";
import { updateGradesPeriodsInCache } from "@/services/grades";
import { useCurrentAccount } from "@/stores/account";
import { useAttendanceStore } from "@/stores/attendance";
Expand All @@ -10,6 +10,8 @@ import RedirectButton from "@/components/Home/RedirectButton";
import { PapillonNavigation } from "@/router/refs";
import { log } from "@/utils/logger/logger";
import type { Attendance } from "@/services/shared/Attendance";
import { FadeInDown, FadeOut } from "react-native-reanimated";
import MissingItem from "@/components/Global/MissingItem";


interface AttendanceElementProps {
Expand Down Expand Up @@ -89,7 +91,26 @@ const AttendanceElement: React.FC<AttendanceElementProps> = ({ onImportance }) =
};

if (!totalMissed || totalMissed.absences.length === 0) {
return null;
return (
<NativeList
animated
key="emptyAttendance"
entering={FadeInDown.springify().mass(1).damping(20).stiffness(300)}
exiting={FadeOut.duration(300)}
>
<NativeItem animated style={{ paddingVertical: 10 }}>
<MissingItem
title="Aucune absence"
description={
defaultPeriod
? `Tu n'as pas d'absences au ${defaultPeriod}.`
: "Tu n'as pas d'absences pour cette période."
}
emoji="🎉"
/>
</NativeItem>
</NativeList>
);
}

return (
Expand Down
28 changes: 25 additions & 3 deletions src/views/account/Home/Elements/GradesElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeList, NativeListHeader } from "@/components/Global/NativeComponents";
import { NativeItem, NativeList, NativeListHeader } from "@/components/Global/NativeComponents";
import { PapillonNavigation } from "@/router/refs";
import { updateGradesAndAveragesInCache, updateGradesPeriodsInCache } from "@/services/grades";
import { useCurrentAccount } from "@/stores/account";
Expand All @@ -7,6 +7,8 @@ import React, { useEffect, useState } from "react";
import GradeItem from "../../Grades/Subject/GradeItem";
import type { Grade } from "@/services/shared/Grade";
import RedirectButton from "@/components/Home/RedirectButton";
import { FadeInDown, FadeOut } from "react-native-reanimated";
import MissingItem from "@/components/Global/MissingItem";

interface GradesElementProps {
onImportance: (value: number) => unknown
Expand Down Expand Up @@ -69,7 +71,27 @@ const GradesElement: React.FC<GradesElementProps> = ({ onImportance }) => {
}, [grades]);

if (!grades || lastThreeGrades.length === 0) {
return null;
return (
<NativeList
animated
key="emptyGrades"
entering={FadeInDown.springify().mass(1).damping(20).stiffness(300)}
exiting={FadeOut.duration(300)}
>
<NativeItem animated style={{ paddingVertical: 10 }}>
<MissingItem
style={{ marginHorizontal: 16 }}
emoji="📚"
title="Aucune note disponible"
description={
defaultPeriod
? `Tu n'as aucune note au ${defaultPeriod}.`
: "Tu n'as aucune note pour cette période."
}
/>
</NativeItem>
</NativeList>
);
}

return (
Expand All @@ -90,7 +112,7 @@ const GradesElement: React.FC<GradesElementProps> = ({ onImportance }) => {
navigation={PapillonNavigation.current}
index={index}
totalItems={lastThreeGrades.length}
allGrades={[]}
allGrades={grades[defaultPeriod] || []}
/>
))}
</NativeList>
Expand Down
48 changes: 30 additions & 18 deletions src/views/account/Home/Elements/HomeworksElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeList, NativeListHeader } from "@/components/Global/NativeComponents";
import { NativeItem, NativeList, NativeListHeader } from "@/components/Global/NativeComponents";
import { useCurrentAccount } from "@/stores/account";
import React, { useCallback, useEffect, useMemo } from "react";
import { useHomeworkStore } from "@/stores/homework";
Expand All @@ -11,6 +11,8 @@ import RedirectButton from "@/components/Home/RedirectButton";
import { dateToEpochWeekNumber } from "@/utils/epochWeekNumber";
import {NativeStackNavigationProp} from "@react-navigation/native-stack";
import {RouteParameters} from "@/router/helpers/types";
import { FadeInDown, FadeOut } from "react-native-reanimated";
import MissingItem from "@/components/Global/MissingItem";

interface HomeworksElementProps {
onImportance: (value: number) => unknown
Expand Down Expand Up @@ -58,23 +60,33 @@ const HomeworksElement: React.FC<HomeworksElementProps> = ({ navigation, onImpor
[account, updateHomeworks]
);

if (
!homeworks[dateToEpochWeekNumber(actualDay)]?.filter(
(hw) => hw.due / 1000 >= startTime && hw.due / 1000 <= endTime
) &&
!homeworks[dateToEpochWeekNumber(actualDay) + 1]?.filter(
(hw) => hw.due / 1000 >= startTime && hw.due / 1000 <= endTime
)
) {
return null;
}
const startTime = Date.now() / 1000; // Convertir en millisecondes
const endTime = startTime + 7 * 24 * 60 * 60 * 1000; // Ajouter 7 jours en millisecondes
const startTime = Date.now() / 1000;
const endTime = startTime + 7 * 24 * 60 * 60 * 1000;

const hwFinalList = homeworks[dateToEpochWeekNumber(actualDay)]?.filter(hw => hw.due / 1000 >= startTime && hw.due / 1000 <= endTime);
const hwSemaineActuelle = homeworks[dateToEpochWeekNumber(actualDay)]?.filter(
(hw) => hw.due / 1000 >= startTime && hw.due / 1000 <= endTime
) ?? [];
const hwSemaineProchaine = homeworks[dateToEpochWeekNumber(actualDay) + 1]?.filter(
(hw) => hw.due / 1000 >= startTime && hw.due / 1000 <= endTime
) ?? [];

if(hwFinalList.length === 0) {
return null;
if (hwSemaineActuelle.length === 0 && hwSemaineProchaine.length === 0) {
return (
<NativeList
animated
key="emptyHomeworks"
entering={FadeInDown.springify().mass(1).damping(20).stiffness(300)}
exiting={FadeOut.duration(300)}
>
<NativeItem animated style={{ paddingVertical: 10 }}>
<MissingItem
emoji="📚"
title="Aucun devoir"
description="Tu n'as aucun devoir pour cette semaine et la semaine prochaine."
/>
</NativeItem>
</NativeList>
);
}

return (
Expand All @@ -85,7 +97,7 @@ const HomeworksElement: React.FC<HomeworksElementProps> = ({ navigation, onImpor
)}
/>
<NativeList>
{hwFinalList.map((hw, index) => (
{hwSemaineActuelle.map((hw, index) => (
<HomeworkItem
navigation={navigation}
homework={hw}
Expand All @@ -97,7 +109,7 @@ const HomeworksElement: React.FC<HomeworksElementProps> = ({ navigation, onImpor
}}
/>
))}
{new Date().getDay() >= 2 && homeworks[dateToEpochWeekNumber(actualDay) + 1]?.filter(hw => hw.due / 1000 >= startTime && hw.due / 1000 <= endTime).map((hw, index) => (
{new Date().getDay() >= 2 && hwSemaineProchaine.map((hw, index) => (
<HomeworkItem
homework={hw}
key={index}
Expand Down
2 changes: 1 addition & 1 deletion src/views/account/Home/Elements/TimetableElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const TimetableElement: React.FC<TimetableElementProps> = ({ onImportance }) =>
>
<NativeItem animated style={{ paddingVertical: 10 }}>
<MissingItem
emoji="📚"
emoji="📆"
title="Aucun cours à venir"
description="Il n'y a pas de cours à venir pour les prochains jours."
/>
Expand Down
1 change: 0 additions & 1 deletion src/views/login/pronote/PronoteInstanceSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ActivityIndicator,
Keyboard,
KeyboardEvent,
Text,
} from "react-native";
import pronote from "pawnote";
import Reanimated, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from "react";
import React from "react";
import type { Screen } from "@/router/helpers/types";
import { useTheme } from "@react-navigation/native";
import { BellRing } from "lucide-react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Image, View, StyleSheet, Text } from "react-native";
import { NativeText, } from "@/components/Global/NativeComponents";
import { useAccounts, useCurrentAccount } from "@/stores/account";
import { useCurrentAccount } from "@/stores/account";
import { TouchableOpacity } from "react-native-gesture-handler";
import BetaIndicator from "@/components/News/Beta";

Expand Down
3 changes: 1 addition & 2 deletions src/views/settings/ExternalAccount/ServiceSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { AccountService } from "@/stores/account/types";
import { useCurrentAccount } from "@/stores/account";
import DuoListPressable from "@/components/FirstInstallation/DuoListPressable";
import ButtonCta from "@/components/FirstInstallation/ButtonCta";
import { LinearGradient } from "expo-linear-gradient";


const ExternalAccountSelector: Screen<"ExternalAccountSelector"> = ({ navigation, route }) => {
const theme = useTheme();
const { colors } = theme;
Expand Down
Loading
Loading