Skip to content
This repository was archived by the owner on Sep 28, 2025. It is now read-only.
Open
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
21 changes: 21 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@capacitor/cli": "^6.0.0",
"@types/isomorphic-fetch": "^0.0.36",
"babel-plugin-tsconfig-paths": "^1.0.3"
Expand Down
13 changes: 10 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import "./theme/globals.scss";

import Login from "./pages/Auth/Login";

import { StatusBar, Style } from "@capacitor/status-bar";
import { Style } from "@capacitor/status-bar";
import { setStatusBar } from "./utils/statusBar";
import { isNative } from "./utils/native";
import { useDarkMode } from "usehooks-ts";
import { ModalContextProvider } from "./contexts/modalContext";
import { ToastContextProvider } from "./contexts/toastContext";
Expand All @@ -37,8 +39,13 @@ dayjs.locale("fr");
dayjs.extend(relativeTime);
setupIonicReact();

StatusBar.setStyle({ style: Style.Dark });
StatusBar.setBackgroundColor({ color: "#3f2a56" });
setStatusBar(Style.Dark);
if (isNative) {
(async () => {
const { StatusBar } = await import("@capacitor/status-bar");
try { await StatusBar.setBackgroundColor({ color: "#3f2a56" }); } catch {}
})();
}

// Locks screen orientation to portrait
// window.screen.orientation.lock('portrait');
Expand Down
7 changes: 3 additions & 4 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import PageTemplate from "../Template";
import styles from "./Home.module.scss";
import clsx from "clsx";
import EventJunia from "../../components/Pages/Home/Events";
import { Capacitor } from "@capacitor/core";
import { LocalNotifications } from "@capacitor/local-notifications";
import { AppUpdate } from "@capawesome/capacitor-app-update";
import { getAppUpdateInfoSafe } from "../../utils/appUpdate";
import { MauriaNoteType } from "../../types/note";


Expand Down Expand Up @@ -81,8 +80,8 @@ const intervalFetch = async () => {
setTimeout(intervalFetch, 14400000);

// setTimeout(intervalFetch, 30000);
if (Capacitor) {
const available = await AppUpdate.getAppUpdateInfo();
const available = await getAppUpdateInfoSafe();
if (available) {
console.log(available);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Planning/ModifyEventModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ const ModifyEventModalContent = ({ setUserEvents, ...event }: any) => {
</div>
</header>
<span className={styles["date"]}>
{newCurrentEvent.type} avec {newCurrentEvent.teacher || "Professeur non renseigné"}
{newCurrentEvent.type === "est-epreuve"
? <>Bonnes révisions et bon courage !</>
: newCurrentEvent.type === "est-perso"
? null
: <>{newCurrentEvent.type} avec {newCurrentEvent.teacher || "un professeur non renseigné"}</>}
</span>
<div className={modalStyles["content"]}>
{newCurrentEvent.type === "est-perso" && (
Expand Down
11 changes: 11 additions & 0 deletions src/utils/appUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { isNative } from "./native";

export async function getAppUpdateInfoSafe() {
if (!isNative) return null;
try {
const { AppUpdate } = await import("@capawesome/capacitor-app-update");
return await AppUpdate.getAppUpdateInfo();
} catch {
return null;
}
}
62 changes: 52 additions & 10 deletions src/utils/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,58 @@ export const fetchTomorrowLessons = (): MauriaEventType[] => {


export const fetchEvent = (event: AurionEventType): MauriaEventType => {
const data = event.title.split("\n\n");

// Exemple d'event :
// {
// id: "67476251",
// title: "IC2 C406 - Salle Prépa OZANAM - VidéoProj\n\nMathématiques - 1er semestre\nCOURS_TD\nMonsieur LUQUET",
// OU "\nInterrogation en C854\nMathématiques - 1er semestre\nDS_SURV\n "
// OU "Je suis un test\n 14:15:00 - 14:45:00"
// start: "10:10",
// end: "12:00",
// allDay: false,
// className: "COURS_TD",
// OU "est_epreuve"
// OU "est_perso"
// editable: undefined
// }

const isCurrent = isInInterval(event.start, event.end);

const startTime = event.start;
const endTime = event.end;

// const title = data[2] ? (data[2].length > 0 ? data[2] : data[1]) : data[1];
const salle = data[0];
const reste = data[1].split("\n");

const title = reste[0];
const teacher = reste[reste.length - 1];
let salle = "";
let title = "";
let teacher = "";

// SI C'EST UNE EPREUVE --------------------------------------------------------------------------------------------------------------------
if (event.className === "est-epreuve") {
const data = strip(event.title).split("\n"); // ["\nInterrogation en C854", "Mathématiques - 1er semestre", "DS_SURV", " "]

const reste = data[0].split(" en "); // ["Interrogation", "C854"]
salle = "Salle " + reste[1]; // Salle C854
title = data[1] + " - " + reste[0]; // Mathématiques - 1er semestre - Interrogation

// SI C'EST UN EVENEMENT PERSO -------------------------------------------------------------------------------------------------------------
} else if (event.className === "est-perso") {
title = event.title.split("\n")[0]; // "Je suis un test"

// AUTRE (COURS, TD, ATERLIERS) ------------------------------------------------------------------------------------------------------------
} else {
const data = event.title.split("\n\n"); // ["Salle Prépa OZANAM - VidéoProj", "Mathématiques - 1er semestre\nCOURS_TD\nMonsieur LUQUET"]

salle = data[0]; // "Salle Prépa OZANAM - VidéoProj"
const reste = data[1].split("\n"); // ["Mathématiques - 1er semestre", "COURS_TD", "Monsieur LUQUET"]

title = reste[0]; // "Mathématiques - 1er semestre"
teacher = reste[reste.length - 1]; // "Monsieur LUQUET"
}

const cours = Object.assign({
id: event.id,
isCurrent,
data: event,
title: title,
type: event.className,
type: formatClassName(event.className),
room: salle,
teacher: teacher,
start: startTime,
Expand All @@ -167,3 +199,13 @@ export const fetchEvent = (event: AurionEventType): MauriaEventType => {

return cours;
};

function formatClassName(input: string): string {
return input
.replace("COURS_TD", "Cours / TD")
.replace("ATELIER", "Atelier");
}

function strip(input: string): string {
return input.replace(/^\s+|\s+$/g, "");
}
7 changes: 7 additions & 0 deletions src/utils/haptics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Haptics, ImpactStyle } from "@capacitor/haptics";
import { isNative } from "./native";

export async function hapticImpact(style: ImpactStyle = ImpactStyle.Medium) {
if (!isNative) return;
try { await Haptics.impact({ style }); } catch {}
}
9 changes: 5 additions & 4 deletions src/utils/hooks/useHaptics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLocalStorage } from "usehooks-ts";
import { Haptics, ImpactStyle } from "@capacitor/haptics";
import { ImpactStyle } from "@capacitor/haptics";
import { hapticImpact } from "../haptics";

export const useHaptics = () => {
const [haptics, setHaptics] = useLocalStorage("useHaptics", true);
Expand All @@ -17,15 +18,15 @@ export const useHaptics = () => {
};

const hapticsImpactHeavy = async () => {
haptics && (await Haptics.impact({ style: ImpactStyle.Heavy }));
haptics && (await hapticImpact(ImpactStyle.Heavy));
};

const hapticsImpactMedium = async () => {
haptics && (await Haptics.impact({ style: ImpactStyle.Medium }));
haptics && (await hapticImpact(ImpactStyle.Medium));
};

const hapticsImpactLight = async () => {
haptics && (await Haptics.impact({ style: ImpactStyle.Light }));
haptics && (await hapticImpact(ImpactStyle.Light));
};

return {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Capacitor } from "@capacitor/core";
export const isNative = Capacitor.isNativePlatform();
7 changes: 7 additions & 0 deletions src/utils/statusBar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Style, StatusBar } from "@capacitor/status-bar";
import { isNative } from "./native";

export async function setStatusBar(style: Style) {
if (!isNative) return;
try { await StatusBar.setStyle({ style }); } catch {}
}