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: Papillon 100% hors connexion #346

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
99cb9f5
page d'accueil 100% hors connexion
Kgeek33 Oct 30, 2024
822671f
page des notes (et un de ces composants) 100% hors connexion
Kgeek33 Oct 30, 2024
417011f
optimisation du code (page d'accueil)
Kgeek33 Oct 30, 2024
5978b00
page d'actualités 100% hors connexion
Kgeek33 Oct 30, 2024
bd219e1
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 3, 2024
116dbfc
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 10, 2024
5eb11a3
update `package-lock.json`
Kgeek33 Nov 10, 2024
e923e99
ajout mode hors connexion sur la vie scolaire
Kgeek33 Nov 10, 2024
01a0852
impossible de mettre une actualité en lu/non lu
Kgeek33 Nov 10, 2024
f26be76
généralisation du msg
Kgeek33 Nov 10, 2024
8f1d84f
devoir 100% hors connexion + impossibilité de cocher des devoirs
Kgeek33 Nov 10, 2024
2cacae4
la page cantine disponible hors connexion
Kgeek33 Nov 10, 2024
3280b97
chat disponible en mode hors connexion
Kgeek33 Nov 10, 2024
61f26b1
impossible d'ajouter un compte en mode hors connexion
Kgeek33 Nov 10, 2024
4c3fd99
suppression <WifiIcon>
Kgeek33 Nov 10, 2024
0228866
texte correct en mode hors connexion
Kgeek33 Nov 10, 2024
3761280
delete console.log
Kgeek33 Nov 10, 2024
b7d8f1d
fix padding Grades !== Messages
Kgeek33 Nov 10, 2024
b45ad93
affichage du mode hors connexion avant les nouveautés
Kgeek33 Nov 10, 2024
e34e72f
d'ailleurs, n'affiche pas les nouveautés en mode hors connexion
Kgeek33 Nov 10, 2024
cfdbb09
fhow banderole sur les devoirs
Kgeek33 Nov 10, 2024
a4253ea
intégration banderole sur emploi du temps
Kgeek33 Nov 10, 2024
f7d510e
oups
Kgeek33 Nov 10, 2024
01b65f6
correction rendu incorrect lors du défilement
Kgeek33 Nov 10, 2024
b82d382
1ère erreur
Kgeek33 Nov 10, 2024
7ee30cb
fix affichage sur l'emploi du temps
Kgeek33 Nov 10, 2024
507d4c0
fix affichage sur les devoirs
Kgeek33 Nov 10, 2024
f458ade
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 11, 2024
62dcf19
variables non utilisées supprimé
Kgeek33 Nov 11, 2024
36b71cc
Update Homeworks.tsx, buy Yanice
Kgeek33 Nov 11, 2024
9851d90
Update Page.tsx, buy Yanice
Kgeek33 Nov 11, 2024
6d13e9a
suppression duplication de code + variables non utilisées
Kgeek33 Nov 11, 2024
adfecf1
Update src/views/account/Home/ModalContent.tsx
Kgeek33 Nov 11, 2024
a261225
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 11, 2024
d1031e6
Merge branch 'PapillonApp:main' into feat/horsCo
Kgeek33 Nov 15, 2024
a23c92e
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 16, 2024
7671e4c
erreur de ma part
Kgeek33 Nov 16, 2024
50516fb
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 18, 2024
2e9ee17
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 21, 2024
96442ca
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 25, 2024
5f52750
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 26, 2024
8c68816
Merge branch 'main' into feat/horsCo
Kgeek33 Nov 29, 2024
ac13e94
Merge branch 'main' into feat/horsCo
Kgeek33 Dec 8, 2024
ae49b8e
Merge branch 'main' into feat/horsCo
Kgeek33 Dec 11, 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
44 changes: 33 additions & 11 deletions package-lock.json

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

36 changes: 15 additions & 21 deletions src/components/Global/PapillonModernHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
import React, { Children, useEffect, useRef, useState } from "react";
import { Button, StyleSheet, View } from "react-native";

import { Screen } from "@/router/helpers/types";
import { NativeText } from "@/components/Global/NativeComponents";
import InfiniteDatePager from "@/components/Global/InfiniteDatePager";
import { useCurrentAccount } from "@/stores/account";
import { useTimetableStore } from "@/stores/timetable";
import { AccountService } from "@/stores/account/types";
import { updateTimetableForWeekInCache } from "@/services/timetable";
import { set } from "lodash";
import { dateToEpochWeekNumber } from "@/utils/epochWeekNumber";

import Reanimated, { FadeIn, FadeInDown, FadeInLeft, FadeOut, FadeOutLeft, FadeOutRight, FadeOutUp, LinearTransition, ZoomIn, ZoomOut } from "react-native-reanimated";
import React, { useEffect, useState } from "react";
import { StyleSheet, View } from "react-native";
import Reanimated, { FadeIn, FadeOut, LinearTransition, ZoomIn, ZoomOut } from "react-native-reanimated";
import { animPapillon } from "@/utils/ui/animations";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import PapillonSpinner from "@/components/Global/PapillonSpinner";
import { PressableScale } from "react-native-pressable-scale";
import { useTheme } from "@react-navigation/native";
import { BlurView } from "expo-blur";
import AnimatedNumber from "@/components/Global/AnimatedNumber";
import { LinearGradient } from "expo-linear-gradient";
import { TouchableOpacity } from "react-native-gesture-handler";
import { ArrowLeftToLine, ArrowUp, CalendarCheck, CalendarClock, CalendarPlus, CalendarSearch, History, ListRestart, Loader, Plus, Rewind } from "lucide-react-native";
import NetInfo from "@react-native-community/netinfo";
import { WifiOff } from "lucide-react-native";

interface ModernHeaderProps {
children: React.ReactNode,
Expand All @@ -33,9 +21,6 @@ interface ModernHeaderProps {
};

export const PapillonModernHeader: React.FC<ModernHeaderProps> = (props) => {
const theme = useTheme();
const insets = useSafeAreaInsets();

if (props.native) {
return (
<NativeModernHeader {...props} />
Expand Down Expand Up @@ -243,6 +228,13 @@ export const PapillonHeaderSelector: React.FC<{
loading = false,
}) => {
const theme = useTheme();
const [isOnline, setIsOnline] = useState(true);

useEffect(() => {
return NetInfo.addEventListener(state => {
setIsOnline(state.isConnected ?? false);
});
}, []);

return (
<Reanimated.View
Expand All @@ -268,7 +260,9 @@ export const PapillonHeaderSelector: React.FC<{
>
{children}

{loading &&
{!isOnline ? (
<WifiOff size={20} color="red" />
) : loading &&
<PapillonSpinner
size={18}
color={theme.colors.text}
Expand Down
135 changes: 60 additions & 75 deletions src/components/Home/AccountSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import React, { useEffect, useState } from "react";
import { Image, StyleSheet, View } from "react-native";
import { useTheme } from "@react-navigation/native";
import { ChevronDown } from "lucide-react-native";
import { ChevronDown, WifiOff } from "lucide-react-native";

import Reanimated, {
interpolateColor,
LinearTransition, useAnimatedStyle,
LinearTransition,
ZoomIn,
ZoomOut,
} from "react-native-reanimated";
Expand All @@ -16,68 +15,46 @@ import PapillonSpinner from "../Global/PapillonSpinner";
import { animPapillon } from "@/utils/ui/animations";
import Animated from "react-native-reanimated";
import { BlurView } from "expo-blur";
import NetInfo from "@react-native-community/netinfo";

const ReanimatedBlurView = Reanimated.createAnimatedComponent(BlurView);

const AccountSwitcher: React.FC<{
small?: boolean,
opened?: boolean,
modalOpen?: boolean,
translationY?: Reanimated.SharedValue<number>,
loading?: boolean,
small?: boolean;
opened?: boolean;
modalOpen?: boolean;
translationY?: Reanimated.SharedValue<number>;
loading?: boolean;
}> = ({ small, opened, modalOpen, translationY, loading }) => {
const theme = useTheme();
const { colors } = theme;

const account = useCurrentAccount(store => store.account!);
const account = useCurrentAccount((store) => store.account!);

const shouldHideName = account.personalization.hideNameOnHomeScreen || false;
const shouldHidePicture = account.personalization.hideProfilePicOnHomeScreen || false;
const shouldHidePicture =
account.personalization.hideProfilePicOnHomeScreen || false;

const borderAnimatedStyle = useAnimatedStyle(() => ({
borderWidth: 1,
borderRadius: 80,
borderColor: interpolateColor(
translationY.value,
[200, 251],
["#ffffff50", colors.border],
),
backgroundColor: interpolateColor(
translationY.value,
[200, 251],
["#ffffff30", "transparent"],
),
}));

const textAnimatedStyle = useAnimatedStyle(() => ({
color: interpolateColor(
translationY.value,
[200, 251],
["#FFF", colors.text],
),
fontSize: 16,
fontFamily: "semibold",
maxWidth: 140,
}));
const [isOnline, setIsOnline] = useState(true);

useEffect(() => {
return NetInfo.addEventListener((state) => {
setIsOnline(state.isConnected ?? false);
});
}, []);

const AnimatedChevronDown = Animated.createAnimatedComponent(ChevronDown);
const iconAnimatedStyle = useAnimatedStyle(() => ({
color: interpolateColor(
translationY.value,
[200, 251],
["#FFF", colors.text],
),
marginLeft: -6,
}));

return (
<Reanimated.View
style={{
backgroundColor:
opened ?
theme.dark && !modalOpen ? "#00000044" : "#FFFFFF22"
: modalOpen ? colors.text + "10" : "#FFFFFF12",
backgroundColor: opened
? theme.dark && !modalOpen
? "#00000044"
: "#FFFFFF22"
: modalOpen
? colors.text + "10"
: "#FFFFFF12",
borderRadius: 12,
borderCurve: "continuous",
overflow: "hidden",
Expand Down Expand Up @@ -109,7 +86,7 @@ const AccountSwitcher: React.FC<{
borderRadius: 0,
paddingVertical: 0,
backgroundColor: "transparent",
}
},
]}
>
<Reanimated.View
Expand All @@ -124,24 +101,31 @@ const AccountSwitcher: React.FC<{
>
{!shouldHidePicture ? (
<Image
source={(account.personalization.profilePictureB64 && account.personalization.profilePictureB64.trim() !== "") ? { uri: account.personalization.profilePictureB64 } : defaultProfilePicture(account.service)}
source={
account.personalization.profilePictureB64 &&
account.personalization.profilePictureB64.trim() !== ""
? { uri: account.personalization.profilePictureB64 }
: defaultProfilePicture(account.service)
}
style={[
styles.avatar,
{
backgroundColor: colors.text + "22",
height: small ? 30 : 28,
width: small ? 30 : 28,
borderColor: modalOpen ? colors.text + "20" : "#FFFFFF32",
}
},
]}
/>
) : (
<View style={[
{
marginLeft: -8,
height: small ? 30 : 28,
}
]} />
<View
style={[
{
marginLeft: -8,
height: small ? 30 : 28,
},
]}
/>
)}

<Reanimated.Text
Expand All @@ -154,25 +138,28 @@ const AccountSwitcher: React.FC<{
numberOfLines={1}
ellipsizeMode="tail"
>
{account.studentName ? (
account.studentName?.first + (shouldHideName ? "" : " " + account.studentName.last)
) : "Mon compte"}
{account.studentName
? account.studentName?.first +
(shouldHideName ? "" : " " + account.studentName.last)
: "Mon compte"}
</Reanimated.Text>

{loading && (
<PapillonSpinner
size={20}
strokeWidth={3}
color={modalOpen && !opened ? colors.text : "#FFF"}
animated
entering={animPapillon(ZoomIn)}
exiting={animPapillon(ZoomOut)}
/>
{!isOnline ? (
<WifiOff size={20} color="red" />
) : (
loading && (
<PapillonSpinner
size={20}
strokeWidth={3}
color={modalOpen && !opened ? colors.text : "#FFF"}
animated
entering={animPapillon(ZoomIn)}
exiting={animPapillon(ZoomOut)}
/>
)
)}

<Reanimated.View
layout={animPapillon(LinearTransition)}
>
<Reanimated.View layout={animPapillon(LinearTransition)}>
<AnimatedChevronDown
size={24}
strokeWidth={2.3}
Expand Down Expand Up @@ -212,9 +199,7 @@ const styles = StyleSheet.create({
borderWidth: 1,
},

accountSwitcherText: {

},
accountSwitcherText: {},
});

export default AccountSwitcher;
Loading
Loading