From 587e95469a80a645919e7754e75e59c1d77a53c3 Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sat, 4 Jan 2025 23:31:00 +0100 Subject: [PATCH 1/8] fix(PronoteInstanceSelector): Update subtext condition based on previous route --- src/views/login/pronote/PronoteInstanceSelector.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/views/login/pronote/PronoteInstanceSelector.tsx b/src/views/login/pronote/PronoteInstanceSelector.tsx index 0ada3ff71..2d0684758 100644 --- a/src/views/login/pronote/PronoteInstanceSelector.tsx +++ b/src/views/login/pronote/PronoteInstanceSelector.tsx @@ -47,6 +47,9 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ const [keyboardHeight, setKeyboardHeight] = useState(0); const [sound, setSound] = useState(null); + const routes = navigation.getState()?.routes; + const prevRoute = routes[routes.length - 2]; + const keyboardDidShow = (event: KeyboardEvent) => { setKeyboardOpen(true); setKeyboardHeight(event.endCoordinates.height); @@ -84,6 +87,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ }; }, []); + console.log(navigation); useEffect(() => { if (params) { @@ -299,7 +303,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ ); }} text={instance.name} - subtext={`à ${instance.distance.toFixed(2)}km de toi`} + subtext={prevRoute.name === "PronoteManualLocation" ? "" : `à ${instance.distance.toFixed(2)}km de toi`} /> ))} From 6f4bda7823d1ec9d5203ded1b9bba83e26df6fa9 Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sun, 5 Jan 2025 00:35:12 +0100 Subject: [PATCH 2/8] fix: j'en profite pr fix des espaces en trop --- src/views/settings/Settings.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/settings/Settings.tsx b/src/views/settings/Settings.tsx index f3dfbf5e8..e77b4d49b 100644 --- a/src/views/settings/Settings.tsx +++ b/src/views/settings/Settings.tsx @@ -28,8 +28,8 @@ import { Route, Scroll, Settings as SettingsLucide, - Sparkles, - SunMoon, + Sparkles, + SunMoon, Smile, SwatchBook, WandSparkles, From 65dc5acbc92dc941abef15d9ec69202f86e41b39 Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sun, 5 Jan 2025 00:36:58 +0100 Subject: [PATCH 3/8] fix: remove debug log --- src/views/login/pronote/PronoteInstanceSelector.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/views/login/pronote/PronoteInstanceSelector.tsx b/src/views/login/pronote/PronoteInstanceSelector.tsx index 2d0684758..5d325aca6 100644 --- a/src/views/login/pronote/PronoteInstanceSelector.tsx +++ b/src/views/login/pronote/PronoteInstanceSelector.tsx @@ -87,8 +87,6 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ }; }, []); - console.log(navigation); - useEffect(() => { if (params) { void async function () { From 4e67614f0066c772ca0cc7e4bf9ccc1b73769a90 Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sun, 5 Jan 2025 00:38:31 +0100 Subject: [PATCH 4/8] fix: replace empty string with undefined --- src/views/login/pronote/PronoteInstanceSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/login/pronote/PronoteInstanceSelector.tsx b/src/views/login/pronote/PronoteInstanceSelector.tsx index 5d325aca6..73fd61e8e 100644 --- a/src/views/login/pronote/PronoteInstanceSelector.tsx +++ b/src/views/login/pronote/PronoteInstanceSelector.tsx @@ -301,7 +301,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ ); }} text={instance.name} - subtext={prevRoute.name === "PronoteManualLocation" ? "" : `à ${instance.distance.toFixed(2)}km de toi`} + subtext={prevRoute.name === "PronoteManualLocation" ? undefined : `à ${instance.distance.toFixed(2)}km de toi`} /> ))} From 2ef029e69ed91a0f4aba3167d353eac6ee65ab93 Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sun, 5 Jan 2025 00:40:48 +0100 Subject: [PATCH 5/8] fix: code formatting --- .../login/pronote/PronoteInstanceSelector.tsx | 127 +++++++++++------- 1 file changed, 81 insertions(+), 46 deletions(-) diff --git a/src/views/login/pronote/PronoteInstanceSelector.tsx b/src/views/login/pronote/PronoteInstanceSelector.tsx index 73fd61e8e..a436249ba 100644 --- a/src/views/login/pronote/PronoteInstanceSelector.tsx +++ b/src/views/login/pronote/PronoteInstanceSelector.tsx @@ -8,10 +8,19 @@ import { ActivityIndicator, Keyboard, KeyboardEvent, - Text + Text, } from "react-native"; import pronote from "pawnote"; -import Reanimated, { LinearTransition, FlipInXDown, FadeInUp, FadeOutUp, ZoomIn, ZoomOut, Easing, ZoomInEasyDown } from "react-native-reanimated"; +import Reanimated, { + LinearTransition, + FlipInXDown, + FadeInUp, + FadeOutUp, + ZoomIn, + ZoomOut, + Easing, + ZoomInEasyDown, +} from "react-native-reanimated"; import determinateAuthenticationView from "@/services/pronote/determinate-authentication-view"; import MaskStars from "@/components/FirstInstallation/MaskStars"; import PapillonShineBubble from "@/components/FirstInstallation/PapillonShineBubble"; @@ -20,7 +29,7 @@ import DuoListPressable from "@/components/FirstInstallation/DuoListPressable"; import { LinearGradient } from "expo-linear-gradient"; import { useTheme } from "@react-navigation/native"; -import { Search, X, GraduationCap, } from "lucide-react-native"; +import { Search, X, GraduationCap } from "lucide-react-native"; import { useAlert } from "@/providers/AlertProvider"; import { Audio } from "expo-av"; import getInstancesFromDataset from "@/services/pronote/dataset_geolocation"; @@ -30,10 +39,14 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ navigation, }) => { // `null` when loading, `[]` when no instances found. - const [instances, setInstances] = useState(null); - const [originalInstances, setOriginalInstances] = useState(null); - - const {colors} = useTheme(); + const [instances, setInstances] = useState< + pronote.GeolocatedInstance[] | null + >(null); + const [originalInstances, setOriginalInstances] = useState< + pronote.GeolocatedInstance[] | null + >(null); + + const { colors } = useTheme(); const insets = useSafeAreaInsets(); const { showAlert } = useAlert(); @@ -89,8 +102,11 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ useEffect(() => { if (params) { - void async function () { - const dataset_instances = await getInstancesFromDataset(params.longitude, params.latitude); + void (async function () { + const dataset_instances = await getInstancesFromDataset( + params.longitude, + params.latitude + ); const pronote_instances = await pronote.geolocation(params); // On calcule la distance entre les instances et l'utilisateur. @@ -106,9 +122,12 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ const dLat = lat2 - lat1; const dLon = lon2 - lon1; - const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(lat1) * Math.cos(lat2) * - Math.sin(dLon / 2) * Math.sin(dLon / 2); + const a = + Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(lat1) * + Math.cos(lat2) * + Math.sin(dLon / 2) * + Math.sin(dLon / 2); const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); const distance = R * c; @@ -130,7 +149,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ // On met à jour les instances. setInstances(instances); setOriginalInstances(instances); - }(); + })(); } }, [params]); @@ -151,14 +170,14 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ styles.container, { paddingTop: insets.top, - } + }, ]} > - + - {!keyboardOpen && + {!keyboardOpen && ( = ({ style={{ marginTop: 0, zIndex: 9999 }} /> - } + )} = ({ // @ts-expect-error color: colors.text, borderColor: colors.border, - } + }, ]} layout={LinearTransition.springify().mass(1).stiffness(100).damping(40)} > @@ -199,19 +218,24 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ styles.searchInput, { color: colors.text, - } + }, ]} /> {search.length > 0 && ( - { - setSearch(""); - }}> + { + setSearch(""); + }} + > @@ -225,15 +249,14 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ ) : ( - = ({ {instances.length === 0 && ( = ({ )} 0 ? 0 : 20), - } + paddingBottom: + keyboardHeight + + insets.bottom + + (keyboardHeight > 0 ? 0 : 20), + }, ]} - layout={LinearTransition.springify().mass(1).stiffness(100).damping(40)} + layout={LinearTransition.springify() + .mass(1) + .stiffness(100) + .damping(40)} > {instances.map((instance, index) => ( + } onPress={async () => { determinateAuthenticationView( @@ -301,14 +333,17 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ ); }} text={instance.name} - subtext={prevRoute.name === "PronoteManualLocation" ? undefined : `à ${instance.distance.toFixed(2)}km de toi`} + subtext={ + prevRoute.name === "PronoteManualLocation" + ? undefined + : `à ${instance.distance.toFixed(2)}km de toi` + } /> ))} - )} ); @@ -377,7 +412,7 @@ const styles = StyleSheet.create({ flex: 1, fontSize: 17, fontFamily: "medium", - } + }, }); export default PronoteInstanceSelector; From ba88f94c583dcfe00cd0a1a668e418edbab1bcde Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sun, 5 Jan 2025 01:13:08 +0100 Subject: [PATCH 6/8] fix: prettier me joue des tours --- src/views/login/pronote/PronoteInstanceSelector.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/views/login/pronote/PronoteInstanceSelector.tsx b/src/views/login/pronote/PronoteInstanceSelector.tsx index a436249ba..79f32e6b7 100644 --- a/src/views/login/pronote/PronoteInstanceSelector.tsx +++ b/src/views/login/pronote/PronoteInstanceSelector.tsx @@ -231,11 +231,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ entering={ZoomIn.springify()} exiting={ZoomOut.springify()} > - { - setSearch(""); - }} - > + {setSearch("");}}> @@ -316,7 +312,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ index < 10 && !hasSearched ? FlipInXDown.springify().delay(100 * index) // @ts-expect-error - : ZoomInEasyDown.duration(400).easing(Easing.bezier(0.25, 0.1, 0.25, 1)).delay(30 * index) + : ZoomInEasyDown.duration(400).easing(Easing.bezier(0.25, 0.1, 0.25, 1)).delay(30 * index) } exiting={index < 10 ? FadeOutUp : void 0} key={instance.url} From 48fa263d233854e3de752fcb64d53b5ca70de493 Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sun, 5 Jan 2025 01:18:53 +0100 Subject: [PATCH 7/8] fix: update distance text for clarity --- src/views/login/pronote/PronoteInstanceSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/login/pronote/PronoteInstanceSelector.tsx b/src/views/login/pronote/PronoteInstanceSelector.tsx index 79f32e6b7..bee3b4904 100644 --- a/src/views/login/pronote/PronoteInstanceSelector.tsx +++ b/src/views/login/pronote/PronoteInstanceSelector.tsx @@ -332,7 +332,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ subtext={ prevRoute.name === "PronoteManualLocation" ? undefined - : `à ${instance.distance.toFixed(2)}km de toi` + : `à ${instance.distance.toFixed(2)}km de ta position` } /> From f9cf7567c7ba5b9784eee9e6f52eb2c1a06a0ca1 Mon Sep 17 00:00:00 2001 From: SupRMinecraftien Date: Sun, 5 Jan 2025 02:15:59 +0100 Subject: [PATCH 8/8] fix: simplify TouchableOpacity onPress syntax --- src/views/login/pronote/PronoteInstanceSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/login/pronote/PronoteInstanceSelector.tsx b/src/views/login/pronote/PronoteInstanceSelector.tsx index bee3b4904..c2bfd27df 100644 --- a/src/views/login/pronote/PronoteInstanceSelector.tsx +++ b/src/views/login/pronote/PronoteInstanceSelector.tsx @@ -231,7 +231,7 @@ const PronoteInstanceSelector: Screen<"PronoteInstanceSelector"> = ({ entering={ZoomIn.springify()} exiting={ZoomOut.springify()} > - {setSearch("");}}> + setSearch("")}>