Skip to content

Commit

Permalink
Merge branch 'main' into feat/newOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kgeek33 committed Jan 28, 2025
2 parents 66d74fd + 0fca92b commit 959a5b3
Show file tree
Hide file tree
Showing 20 changed files with 228 additions and 184 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXPO_ENV=expo
8 changes: 4 additions & 4 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
import { useAccounts, useCurrentAccount } from "@/stores/account";
import {AccountService, PrimaryAccount} from "@/stores/account/types";
import { log } from "@/utils/logger/logger";
import { expoGoWrapper } from "@/utils/native/expoGoAlert";
import { isExpoGo } from "@/utils/native/expoGoAlert";
import { atobPolyfill, btoaPolyfill } from "js-base64";
import { registerBackgroundTasks } from "@/background/BackgroundTasks";
import { SoundHapticsProvider } from "@/hooks/Theme_Sound_Haptics";

SplashScreen.preventAutoHideAsync();
Expand Down Expand Up @@ -106,10 +107,9 @@ export default function App () {
"[Reanimated] Property ",
]);

expoGoWrapper(async () => {
const { registerBackgroundTasks } = await import("@/background/BackgroundTasks");
if (!isExpoGo()) {
registerBackgroundTasks();
});
};
}, []);

const applyGlobalPolyfills = useCallback(() => {
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<queries>
<package android:name="com.facebook.katana"/>
<package android:name="com.instagram.android"/>
<package android:name="com.twitter.android"/>
<package android:name="com.zhiliaoapp.musically"/>
<intent>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
Expand Down
3 changes: 3 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export default (): ExpoConfig => ({
"android.permission.ACCESS_FINE_LOCATION",
],
},
extra: {
EXPO_ENV: "expo",
},
plugins: [
[
"expo-font",
Expand Down
42 changes: 9 additions & 33 deletions ios/Papillon/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
{
"images" : [
"images": [
{
"filename" : "Icon-Light-1024x1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Icon-Dark-1024x1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"filename" : "Icon-Tinted-1024x1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
"filename": "[email protected]",
"idiom": "universal",
"platform": "ios",
"size": "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
"info": {
"version": 1,
"author": "expo"
}
}
}
11 changes: 9 additions & 2 deletions ios/Papillon/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>7.7.2</string>
<string>7.8.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -36,6 +36,13 @@
<string>1</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
<string>instagram</string>
<string>twitter</string>
<string>tiktoksharesdk</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand All @@ -46,7 +53,7 @@
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>Papillon utilise ta caméra pour scanner des QR-codes pour te connecter, pour capturer des documents, ou pour des fonctionnalités amusantes telles que les réaction.</string>
<string>Papillon utilise ta caméra pour scanner des QR-codes pour te connecter, pour capturer des documents, ou pour des fonctionnalités amusantes telles que les réactions.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Autoriser $(PRODUCT_NAME) à utiliser ta localisation.</string>
<key>NSLocationAlwaysUsageDescription</key>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "papillonvex",
"version": "7.8.0",
"version": "7.9.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
Expand Down
6 changes: 3 additions & 3 deletions src/background/BackgroundTasks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as BackgroundFetch from "expo-background-fetch";
import * as TaskManager from "expo-task-manager";
import { BackgroundFetchResult } from "expo-background-fetch";
import { expoGoWrapper } from "@/utils/native/expoGoAlert";
import { isExpoGo } from "@/utils/native/expoGoAlert";
import { useAccounts, useCurrentAccount } from "@/stores/account";

import { fetchNews } from "./data/News";
Expand All @@ -26,7 +26,7 @@ const backgroundFetch = async () => {
};

const registerBackgroundTasks = async () => {
expoGoWrapper(async () => {
if (!isExpoGo()) {
TaskManager.defineTask("background-fetch", () => backgroundFetch());

BackgroundFetch?.registerTaskAsync("background-fetch", {
Expand All @@ -38,7 +38,7 @@ const registerBackgroundTasks = async () => {
backgroundFetch();

console.log("[background fetch] Registered background fetch");
});
};
};

const unsetBackgroundFetch = async () => {
Expand Down
23 changes: 14 additions & 9 deletions src/background/Notifications.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { expoGoWrapper } from "@/utils/native/expoGoAlert";
import {Notification} from "@notifee/react-native";
import { alertExpoGo, isExpoGo } from "@/utils/native/expoGoAlert";
import { Notification } from "@notifee/react-native";

const requestNotificationPermission = async () => {
return expoGoWrapper(async () => {
const notifee = (await import("@notifee/react-native")).default;
await notifee.requestPermission();
}, true);
const requestNotificationPermission = () => {
return async () => {
if (!isExpoGo()) {
const notifee = (await import("@notifee/react-native")).default;
await notifee.requestPermission();
} else {
alertExpoGo();
return false;
}
};
};

const papillonNotify = async (props: Notification) => {
expoGoWrapper(async () => {
if (!isExpoGo()) {
const notifee = (await import("@notifee/react-native")).default;
await notifee.displayNotification({
...props,
title: props.title || "Coucou, c'est Papillon 👋",
});
});
}
};

export {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Templates/LoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const LoginView: React.FC<{
}}
>
<NativeItem icon={<AlertTriangle />}>
<NativeText variant="subtitle">{error}</NativeText>
<NativeText variant="subtitle">Impossible de se connecter, vérifie tes identifiants ou utilise le portail de ton ENT pour te connecter.</NativeText>
</NativeItem>
</NativeList>
)}
Expand Down
32 changes: 26 additions & 6 deletions src/router/screens/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,41 @@ export default [
}),
createScreen("LessonDocument", LessonDocument, {
headerTitle: "Cours",
presentation: "modal",
presentation: "formSheet",
gestureDirection: "vertical",
animation: "slide_from_bottom",
sheetGrabberVisible: false,
sheetInitialDetentIndex: 0,
sheetAllowedDetents: [0.5, 1.0],
headerShown: false,
}),
createScreen("HomeworksDocument", HomeworksDocument, {
headerTitle: "Devoir",
presentation: "modal",
presentation: "formSheet",
gestureDirection: "vertical",
animation: "slide_from_bottom",
sheetGrabberVisible: false,
sheetInitialDetentIndex: 0,
sheetAllowedDetents: [0.5, 1.0],
headerShown: false,
}),
createScreen("GradeSubject", GradeSubjectScreen, {
headerTitle: "Détail de la matière",
presentation: "modal",
presentation: "formSheet",
gestureDirection: "vertical",
animation: "slide_from_bottom",
sheetGrabberVisible: true,
sheetInitialDetentIndex: 0,
sheetAllowedDetents: [0.5, 1.0],
}),
createScreen("GradeDocument", GradeDocument, {
headerTitle: "Détail de la note",
presentation: "modal",
presentation: "formSheet",
gestureDirection: "vertical",
animation: "slide_from_bottom",
sheetGrabberVisible: false,
sheetInitialDetentIndex: 0,
sheetAllowedDetents: [0.5, 1.0],
headerShown: Platform.OS !== "ios",
}),
createScreen("ChatCreate", ChatCreate, {
Expand All @@ -90,12 +110,12 @@ export default [
createScreen("ChatDetails", ChatDetails, {
headerTitle: "Discussions",
headerShown: false,
presentation: "modal"
presentation: "modal",
}),
createScreen("ChatThemes", ChatThemes, {
headerTitle: "Thèmes",
headerShown: true,
presentation: "modal"
presentation: "modal",
}),
createScreen("BackgroundIUTLannion", BackgroundIUTLannion, {
headerTitle: "IUT de Lannion",
Expand Down
17 changes: 1 addition & 16 deletions src/utils/native/expoGoAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Alert } from "react-native";
import Constants from "expo-constants";

export const isExpoGo = () => {
return Constants.appOwnership === "expo";
return Constants.expoConfig?.extra?.EXPO_ENV === "expo";
};

export const alertExpoGo = async () => {
Expand All @@ -11,18 +11,3 @@ export const alertExpoGo = async () => {
"Sous Expo Go, les appels aux API natives sont indisponibles. Utilise un build de développement pour accéder à toutes les fonctionnalités.",
);
};
/**
* Function wrapper that only calls the function if the app is not Expo Go
* @param fn Founciton to call if not Expo Go
* @param alert Show an alert if the app is Expo Go
* @returns Execute the function if not Expo Go
*/
export const expoGoWrapper = (fn: () => void, alert?: boolean) => {
if (!isExpoGo()) {
return fn();
}
else if (alert) {
alertExpoGo();
return false;
}
};
3 changes: 2 additions & 1 deletion src/views/account/Grades/Atoms/GradesScodocUE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const GradesScodocUE = ({ account, navigation }: { account: PrimaryAccount, navi
return (
<>
<NativeListHeader
animated
label="Unités d'enseignement"
trailing={
<TouchableOpacity
Expand All @@ -64,7 +65,7 @@ const GradesScodocUE = ({ account, navigation }: { account: PrimaryAccount, navi
}
/>

<NativeList>
<NativeList animated>
{finalUes.map((ue) => {
interface ueGrade {
key: string,
Expand Down
43 changes: 25 additions & 18 deletions src/views/account/Home/Elements/AttendanceElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,31 @@ const AttendanceElement: React.FC<AttendanceElementProps> = ({ onImportance }) =

if (!totalMissed || totalMissed.absences.length === 0) {
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>
<>
<NativeListHeader label={"Vie scolaire"}
trailing={(
<RedirectButton navigation={PapillonNavigation.current} redirect="Attendance" />
)}
/>
<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>
</>
);
}

Expand Down
Loading

0 comments on commit 959a5b3

Please sign in to comment.