feat: start video

This commit is contained in:
2025-12-03 16:11:44 +01:00
parent f6cb467929
commit 13f34d3ef1
4 changed files with 104 additions and 21 deletions
+81
View File
@@ -0,0 +1,81 @@
import React, { useContext, useEffect, useMemo, useState } from "react";
import { Platform, StyleSheet, View } from "react-native";
import { Portal } from "@gorhom/portal";
import FullscreenIntroVideo from "./FullscreenIntroVideo";
import { useUser } from "../providers/UserDataProvider";
import { SplashAnimationContext } from "../providers/SplashAnimationProvider";
const BLOCKING_TIMEOUT_MS = 5000;
// Affiche la vidéo d'intro mobile (videos.splash) juste après le splash screen.
const MobileSplashVideo = () => {
const { videos } = useUser();
const { isFullyLoaded } = useContext(SplashAnimationContext);
const [visible, setVisible] = useState(false);
const [hasShown, setHasShown] = useState(false);
const [gaveUp, setGaveUp] = useState(false);
const splashVideoUrl = useMemo(() => {
if (Platform.OS === "web") return null;
return videos?.splash ?? null;
}, [videos]);
const shouldAttempt =
Platform.OS !== "web" && isFullyLoaded && !hasShown && !gaveUp;
const showBlockingOverlay = shouldAttempt && !visible;
useEffect(() => {
if (!shouldAttempt) return;
if (!splashVideoUrl) return;
setVisible(true);
}, [shouldAttempt, splashVideoUrl]);
useEffect(() => {
if (!showBlockingOverlay) return;
if (splashVideoUrl) return;
const timeoutId = setTimeout(() => {
setHasShown(true);
setGaveUp(true);
}, BLOCKING_TIMEOUT_MS);
return () => clearTimeout(timeoutId);
}, [showBlockingOverlay, splashVideoUrl]);
const handleClose = () => {
setVisible(false);
setHasShown(true);
};
if (!showBlockingOverlay && !visible) {
return null;
}
return (
<>
{showBlockingOverlay ? (
<Portal>
<View pointerEvents="auto" style={styles.blocker} />
</Portal>
) : null}
{visible ? (
<FullscreenIntroVideo
url={splashVideoUrl}
visible={visible}
onClose={handleClose}
/>
) : null}
</>
);
};
const styles = StyleSheet.create({
blocker: {
...StyleSheet.absoluteFillObject,
backgroundColor: "black",
zIndex: 9998,
},
});
export default MobileSplashVideo;
+16 -16
View File
@@ -80,14 +80,14 @@ export default ({
const nestedSubscription =
currentUserData?.subscription &&
typeof currentUserData.subscription === "object"
typeof currentUserData.subscription === "object"
? currentUserData.subscription
: null;
const stripeMetadata =
currentUserData?.stripeSubscription &&
typeof currentUserData.stripeSubscription === "object" &&
typeof currentUserData.stripeSubscription.metadata === "object"
typeof currentUserData.stripeSubscription === "object" &&
typeof currentUserData.stripeSubscription.metadata === "object"
? currentUserData.stripeSubscription.metadata
: null;
@@ -100,18 +100,18 @@ export default ({
const nestedCandidates = nestedSubscription
? ["level", "plan", "pack", "type"].map((key) =>
pickLevel(nestedSubscription?.[key]),
)
pickLevel(nestedSubscription?.[key]),
)
: [];
const metadataCandidates = stripeMetadata
? [
"level",
"subscriptionLevel",
"subscription_level",
"pack",
"Pack",
].map((key) => pickLevel(stripeMetadata?.[key]))
"level",
"subscriptionLevel",
"subscription_level",
"pack",
"Pack",
].map((key) => pickLevel(stripeMetadata?.[key]))
: [];
const resolvedLevel = [
@@ -293,11 +293,11 @@ export default ({
style={{ flex: 1, ...resolvedContentContainerStyle }}
{...(scrollEnabled
? {
scrollEventThrottle: 80,
showsVerticalScrollIndicator: false,
contentContainerStyle: { paddingBottom: responsiveHeight(55) },
keyboardDismissMode: "on-drag",
}
scrollEventThrottle: 80,
showsVerticalScrollIndicator: false,
contentContainerStyle: { paddingBottom: responsiveHeight(55) },
keyboardDismissMode: "on-drag",
}
: {})}
>
{children}
+5 -5
View File
@@ -55,8 +55,8 @@ export default ({ children }) => {
useDataFromRef({
ref: currentUID
? projectsRef
.where("userId", "==", currentUID)
.orderBy("updatedAt", "desc")
.where("userId", "==", currentUID)
.orderBy("updatedAt", "desc")
: null,
simpleRef: false,
listener: true,
@@ -299,9 +299,9 @@ export default ({ children }) => {
const userDoc = await usersRef.doc(uid).get();
return userDoc.exists
? {
id: userDoc.id,
...userDoc.data(),
}
id: userDoc.id,
...userDoc.data(),
}
: null;
} catch (e) {
console.log(e);