Skip to content

Commit

Permalink
Merge branch 'main' into feature/format-homework-content
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBnm committed Jan 20, 2025
2 parents 863e828 + 353ddef commit 1e2942b
Show file tree
Hide file tree
Showing 56 changed files with 969 additions and 573 deletions.
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ const unusedImports = require("eslint-plugin-unused-imports");
const typescript = require("@typescript-eslint/parser");

module.exports = [
{ // Ignored directory
ignores: [
"**/node_modules/",
"**/android/",
"**/ios/",
"**/.*"
]
},
{ // Apply to `cjs`, `.mjs` and `.js` files.
files: ["**/*.?([cm])js?(x)"]
},
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"@react-navigation/stack": "^6.4.0",
"alise-api": "^0.1.2",
"alise-api": "^0.1.3",
"axios": "^1.7.7",
"buffer": "^6.0.3",
"cal-parser": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Global/AnimatedNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const AnimatedNumber: React.FC<AnimatedNumberProps> = ({
}, contentContainerStyle]}
layout={animPapillon(LinearTransition)}
>
{value.toString().split("").map((n, i) => (
{value.toString().split("").map((n:number, i:number) => (
<Reanimated.View
key={i + "_" + n}
entering={animPapillon(FadeInDown).delay(i * 20 + 20).mass(1).damping(30).stiffness(700)}
Expand Down
7 changes: 4 additions & 3 deletions src/components/Global/PapillonPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { NativeText } from "./NativeComponents";
import { BlurView } from "expo-blur";
import { Check } from "lucide-react-native";

type PickerData = string[] | { label: string, icon?: JSX.Element, onPress: () => unknown }[];
export type PickerDataItem = { index?: number, label: string, icon?: JSX.Element, onPress?: () => unknown };
export type PickerData = string[] | PickerDataItem[];

interface PapillonPickerProps {
children: React.ReactNode
data: PickerData
selected?: string
selected?: string | PickerDataItem
contentContainerStyle?: StyleProp<AnimatedStyle<StyleProp<ViewStyle>>>
delay?: number,
direction?: "left" | "right",
Expand Down Expand Up @@ -204,4 +205,4 @@ const styles = StyleSheet.create({
},
});

export default PapillonPicker;
export default PapillonPicker;
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
6 changes: 2 additions & 4 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 Expand Up @@ -46,7 +44,7 @@ const GradeModal: React.FC<GradeModalProps> = ({
await FileSystem.writeAsStringAsync(fileUri, imageBase64, { encoding: FileSystem.EncodingType.Base64 });
const asset = await MediaLibrary.createAssetAsync(fileUri);
await MediaLibrary.createAlbumAsync("Download", asset, false);
Alert.alert("Image sauvegardée", "L'image a été sauvegardée dans votre galerie.");
Alert.alert("Image sauvegardée", "L'image a été sauvegardée dans ta galerie.");
} catch (error) {
console.error("Failed to save image:", error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/ApparenceContainerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ApparenceContainerCard = () => {
Mode d'affichage
</NativeText>
<NativeText variant="subtitle">
Par défaut, Papillon s'adapte à votre thème système. Mais vous pouvez choisir un thème clair ou sombre.
Par défaut, Papillon s'adapte à ton thème système. Mais tu peux choisir un thème clair ou sombre.
</NativeText>
</NativeItem>
</NativeList>
Expand Down
2 changes: 1 addition & 1 deletion src/consts/DefaultTabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const defaultTabs = [
{
tab: "Evaluation",
label: "Compétences",
description: "Vos compétences et évaluations",
description: "Tes compétences et évaluations",
icon: require("@/../assets/lottie/tab_evaluations.json"),
enabled: true,
}
Expand Down
2 changes: 1 addition & 1 deletion src/router/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export type RouteParameters = {

Menu?: undefined;
RestaurantQrCode: {
QrCodes: string[];
QrCodes: Array<string | Blob>;
};
RestaurantHistory: {
histories: ReservationHistory[];
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
6 changes: 6 additions & 0 deletions src/services/alise/qrcode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { AliseAccount } from "@/stores/account/types";

export const getQRCode = async (account: AliseAccount): Promise<Blob | null> => {
const barcode = await account.authentication.session.getBarcode();
return barcode ?? null;
};
14 changes: 7 additions & 7 deletions src/services/ecoledirecte/grades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ const decodeGradeValue = (
value: ecoledirecte.GradeValue | undefined,
): GradeValue => {
if (typeof value === "undefined")
return { value: null, disabled: true };
return { value: null, disabled: true, status: null };

switch (value.kind) {
case GradeKind.Grade:
return { value: value.points ?? 0, disabled: false };
return { value: value.points ?? 0, disabled: false, status: null };
case GradeKind.Absent:
return { value: value.points ?? 0, disabled: true, information: GradeInformation.Absent };
return { value: value.points ?? 0, disabled: true, status: "Abs" };
case GradeKind.Exempted:
return { value: value.points ?? 0, disabled: true, information: GradeInformation.Exempted };
return { value: value.points ?? 0, disabled: true, status: "Disp" };
case GradeKind.NotGraded:
return { value: value.points ?? 0, disabled: true, information: GradeInformation.NotGraded };
return { value: value.points ?? 0, disabled: true, status: "N. Not" };
default:
return { value: value.points ?? 0, disabled: true };
return { value: value.points ?? 0, disabled: true, status: null };
}
};

const getGradeValue = (value: number | string | undefined): GradeValue => {
return {
disabled: false,
value: value ? Number(value) : 0,
information: undefined,
status: null,
};
};

Expand Down
8 changes: 4 additions & 4 deletions src/services/grades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export async function updateGradesAndAveragesInCache <T extends Account> (accoun
let grades: Grade[] = [];
let averages: AverageOverview = {
subjects: [],
overall: { value: null, disabled: true },
classOverall: { value: null, disabled: true }
overall: { value: null, disabled: true, status: null },
classOverall: { value: null, disabled: true, status: null}
};

try {
Expand Down Expand Up @@ -100,8 +100,8 @@ export async function updateGradesAndAveragesInCache <T extends Account> (accoun
grades = [];
averages = {
subjects: [],
overall: { value: 0, disabled: true },
classOverall: { value: 0, disabled: true }
overall: { value: 0, disabled: true, status: null },
classOverall: { value: 0, disabled: true, status: null }
};
}

Expand Down
14 changes: 14 additions & 0 deletions src/services/iutlan/grades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export const saveIUTLanGrades = async (account: LocalAccount): Promise<{
classOverall: {
value: null,
disabled: true,
status: null,
},
overall: {
value: null,
disabled: true,
status: null,
},
subjects: []
};
Expand All @@ -63,24 +65,29 @@ export const saveIUTLanGrades = async (account: LocalAccount): Promise<{
student: {
value: parseFloat(note.note.value),
disabled: parsedStudent === null || isNaN(parsedStudent),
status: null,
},
min: {
value: parseFloat(note.note.min),
disabled: parsedMin === null || isNaN(parsedMin),
status: null,
},
max: {
value: parseFloat(note.note.max),
disabled: parsedMax === null || isNaN(parsedMax),
status: null,
},
average: {
value: parseFloat(note.note.moy),
disabled: parsedAverage === null || isNaN(parsedAverage),
status: null,
},

id: uuid(),
outOf: {
value: 20,
disabled: false,
status: null,
},
description: note.description,
timestamp: new Date(note.date).getTime(),
Expand Down Expand Up @@ -112,24 +119,29 @@ export const saveIUTLanGrades = async (account: LocalAccount): Promise<{
classAverage: {
value: classAverage,
disabled: false,
status: null,
},
color: "#888888",
max: {
value: max,
disabled: false,
status: null,
},
subjectName: subject.name,
min: {
value: min,
disabled: false,
status: null,
},
average: {
value: average,
disabled: false,
status: null,
},
outOf: {
value: 20,
disabled: false,
status: null,
},
});
});
Expand All @@ -144,10 +156,12 @@ export const saveIUTLanGrades = async (account: LocalAccount): Promise<{
classOverall: {
value: null,
disabled: true,
status: null,
},
overall: {
value: null,
disabled: true,
status: null,
},
subjects: []
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/pronote/evaluations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const getTab = (account: PronoteAccount): pronote.Tab => {

const tab = account.instance.user.resources[0].tabs.get(pronote.TabLocation.Evaluations);
if (!tab)
throw new Error("Vous n'avez pas accès à l'onglet 'Compétences' dans PRONOTE");
throw new Error("Tu n'as pas accès à l'onglet 'Compétences' dans PRONOTE");

return tab;
};
Expand Down
Loading

0 comments on commit 1e2942b

Please sign in to comment.