big refacto change all flows

This commit is contained in:
Thomas Demirdjian
2025-09-03 15:43:22 +02:00
parent 8f1c062b33
commit 60d1794c99
29 changed files with 841 additions and 344 deletions
+38 -7
View File
@@ -1,5 +1,5 @@
import { View, Image, StyleSheet } from "react-native";
import React from "react";
import React, { useEffect, useState } from "react";
import Page from "../../layouts/Page";
import { ai } from "../../assets";
import GradientButton from "../../components/GradientButton";
@@ -8,8 +8,39 @@ import BorderGradientButton from "../../components/BorderGradientButton";
import MusicLandHeader from "../../components/MusicLandHeader";
import { goBack, navigate } from "../../navigation/NavigationService";
import { Routes } from "../../navigation";
import { useUserData } from "../../providers/UserDataProvider";
import useMinuit from "react-native-minuit/src/hooks/useMinuit.js";
import FullscreenIntroVideo from "../../components/FullscreenIntroVideo";
const WritingLyrics = () => {
const { createNewProject, selectedProject, updateProjectData } =
useUserData();
const { setIsLoading } = useMinuit();
const [showIntro, setShowIntro] = useState(false);
useEffect(() => {
if (selectedProject === null) {
setShowIntro(true);
}
}, [selectedProject]);
async function createAndNavigate({ hasLyrics = false }) {
try {
await setIsLoading(true);
if (selectedProject) {
updateProjectData({ hasLyrics });
} else {
await createNewProject({ hasLyrics });
}
setTimeout(() => navigate(Routes.CreateLyricsWithAi), 500);
} catch (e) {
console.log(e);
} finally {
await setIsLoading(false);
}
}
return (
<Page headerType="NONE">
<Image source={ai.nathalie} style={styles.img} resizeMode="contain" />
@@ -25,18 +56,18 @@ const WritingLyrics = () => {
}}
>
<BorderGradientButton
onPress={() => {
navigate(Routes.CreateLyricsWithAi, {
hasLyrics: true,
});
}}
onPress={() => createAndNavigate({ hasLyrics: true })}
/>
<GradientButton
title="Écrire des paroles avec une IA"
onPress={() => navigate(Routes.CreateLyricsWithAi)}
onPress={() => createAndNavigate({ hasLyrics: false })}
/>
</View>
</View>
<FullscreenIntroVideo
visible={showIntro}
onClose={() => setShowIntro(false)}
/>
</Page>
);
};