Fixes and tickets
This commit is contained in:
+21
-37
@@ -1,13 +1,18 @@
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
||||
import {
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { background } from "../assets";
|
||||
import FullscreenIntroVideo from "../components/FullscreenIntroVideo";
|
||||
import GradientButton from "../components/GradientButton";
|
||||
import { usersRef, videosRef } from "../config/firebase";
|
||||
import { videosRef } from "../config/firebase";
|
||||
import useDataFromRef from "../hooks/useDataFromRef";
|
||||
import { isWeb } from "../hooks/useLayoutType";
|
||||
import Page from "../layouts/Page";
|
||||
import { Routes } from "../navigation/Routes";
|
||||
import { useUser } from "../providers/UserDataProvider";
|
||||
@@ -19,13 +24,9 @@ const LANGUAGE_STORAGE_KEY = "preferredLanguage";
|
||||
export default function LandingPage() {
|
||||
const navigation = useNavigation();
|
||||
const { currentUID } = useUser();
|
||||
const [isVideoVisible, setIsVideoVisible] = useState(false);
|
||||
const [videoUrl, setVideoUrl] = useState(null);
|
||||
const [selectedLanguage, setSelectedLanguage] = useState(null);
|
||||
|
||||
const handleStartVisit = useCallback(() => {
|
||||
setIsVideoVisible(true);
|
||||
}, []);
|
||||
|
||||
const handleSelectLanguage = useCallback((language) => {
|
||||
setSelectedLanguage(language);
|
||||
AsyncStorage.setItem(LANGUAGE_STORAGE_KEY, language).catch((error) => {
|
||||
@@ -33,33 +34,10 @@ export default function LandingPage() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleSashaHome = useCallback(() => {
|
||||
// Placeholder handler until the Sasha experience is available.
|
||||
}, []);
|
||||
|
||||
const handleLaunchAdventure = useCallback(() => {
|
||||
navigation.navigate(Routes.Register);
|
||||
}, [navigation]);
|
||||
|
||||
const persistAdventureStarted = useCallback(async () => {
|
||||
if (!currentUID) {
|
||||
return;
|
||||
}
|
||||
await usersRef
|
||||
.doc(currentUID)
|
||||
.set({ adventureStarted: true }, { merge: true });
|
||||
}, [currentUID]);
|
||||
|
||||
const handleVideoClose = useCallback(() => {
|
||||
setIsVideoVisible(false);
|
||||
persistAdventureStarted()
|
||||
.catch((error) => {
|
||||
console.warn("LandingPage: adventureStarted update failed", error);
|
||||
})
|
||||
.finally(() => {
|
||||
navigation.navigate(Routes.Login);
|
||||
});
|
||||
}, [navigation, persistAdventureStarted]);
|
||||
const { data: video } = useDataFromRef({
|
||||
ref: videosRef.doc("fr"),
|
||||
simpleRef: true,
|
||||
@@ -118,12 +96,18 @@ export default function LandingPage() {
|
||||
<View style={styles.actions}>
|
||||
<GradientButton
|
||||
title="Découvrir Musicland"
|
||||
onPress={handleStartVisit}
|
||||
onPress={() => setVideoUrl(video?.introWeb)}
|
||||
containerStyle={styles.actionButton}
|
||||
/>
|
||||
<GradientButton
|
||||
title="Accueil avec Sasha"
|
||||
onPress={handleSashaHome}
|
||||
title="Présentation de Musicland"
|
||||
onPress={() =>
|
||||
setVideoUrl(
|
||||
Platform.OS === "web"
|
||||
? video?.landingWeb
|
||||
: video?.landing,
|
||||
)
|
||||
}
|
||||
containerStyle={styles.actionButton}
|
||||
/>
|
||||
<GradientButton
|
||||
@@ -137,9 +121,9 @@ export default function LandingPage() {
|
||||
</View>
|
||||
</Page>
|
||||
<FullscreenIntroVideo
|
||||
url={isWeb ? video?.landingWeb : video?.landing}
|
||||
visible={isVideoVisible}
|
||||
onClose={handleVideoClose}
|
||||
url={videoUrl}
|
||||
visible={!!videoUrl}
|
||||
onClose={() => setVideoUrl(null)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user