alert after paroles

This commit is contained in:
2025-10-20 10:03:36 +02:00
parent a0de26b41f
commit f9b478fe22
7 changed files with 59 additions and 32 deletions
+20 -5
View File
@@ -1,3 +1,4 @@
import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio";
import React, { import React, {
createContext, createContext,
useCallback, useCallback,
@@ -7,7 +8,6 @@ import React, {
useState, useState,
} from "react"; } from "react";
import { Platform } from "react-native"; import { Platform } from "react-native";
import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio";
import { useGlobal } from "reactn"; import { useGlobal } from "reactn";
import GlobalAudioPlayer from "../components/player/GlobalAudioPlayer"; import GlobalAudioPlayer from "../components/player/GlobalAudioPlayer";
@@ -153,7 +153,12 @@ const normalizeTrack = (trackInput = {}, options = {}) => {
if (!id && typeof source === "number") { if (!id && typeof source === "number") {
id = String(source); id = String(source);
} }
if (!id && source && typeof source === "object" && typeof source.uri === "string") { if (
!id &&
source &&
typeof source === "object" &&
typeof source.uri === "string"
) {
id = source.uri; id = source.uri;
} }
if (!id) { if (!id) {
@@ -174,7 +179,12 @@ const normalizeTrack = (trackInput = {}, options = {}) => {
? options.artist ? options.artist
: ""; : "";
const artwork = track?.artwork ?? track?.coverUrl ?? options?.artwork ?? options?.coverUrl ?? null; const artwork =
track?.artwork ??
track?.coverUrl ??
options?.artwork ??
options?.coverUrl ??
null;
return { return {
id, id,
@@ -282,7 +292,9 @@ const PlayerProvider = ({ children }) => {
async (trackInput, options = {}) => { async (trackInput, options = {}) => {
const normalized = normalizeTrack(trackInput, options); const normalized = normalizeTrack(trackInput, options);
if (!normalized.source) { if (!normalized.source) {
console.warn("PlayerProvider: impossible de lancer la lecture, source audio manquante"); console.warn(
"PlayerProvider: impossible de lancer la lecture, source audio manquante"
);
return; return;
} }
@@ -370,7 +382,10 @@ const PlayerProvider = ({ children }) => {
options options
); );
if (trackInput && (!currentTrack || (targetId && targetId !== currentTrack.id))) { if (
trackInput &&
(!currentTrack || (targetId && targetId !== currentTrack.id))
) {
await play(trackInput, options); await play(trackInput, options);
return; return;
} }
+11 -1
View File
@@ -29,7 +29,7 @@ import {
getStageAction, getStageAction,
} from "../../utils/projectStages"; } from "../../utils/projectStages";
const Home = () => { const Home = ({ navigation, route }) => {
const { const {
userProjects = [], userProjects = [],
resetSelectedProject, resetSelectedProject,
@@ -216,6 +216,16 @@ const Home = () => {
]; ];
}, [handleDeleteProject, menuProject?.id]); }, [handleDeleteProject, menuProject?.id]);
useEffect(() => {
if (route?.params?.showLyricsCongrats) {
Alert(
"Nathalie",
"Bravo ! Vous venez de terminer de créer les paroles de votre musique ! Maintenant vous pouvez passer à la prochaine étape : le Studio avec Malik. Dans cette étape vous allez pouvoir donner vie à votre chanson !"
);
navigation?.setParams?.({ showLyricsCongrats: false });
}
}, [navigation, route?.params?.showLyricsCongrats]);
const activeStage = const activeStage =
stageStates[activeStageIndex] || stageStates[preferredStageIndex]; stageStates[activeStageIndex] || stageStates[preferredStageIndex];
const stageAction = useMemo(() => { const stageAction = useMemo(() => {
+5 -7
View File
@@ -198,9 +198,7 @@ const CreateLyricsWithAi = () => {
style: resolvedStyle, style: resolvedStyle,
audience: audience?.trim() ? audience.trim() : undefined, audience: audience?.trim() ? audience.trim() : undefined,
structure: structure:
(customStructure && (Array.isArray(customStructure) && customStructure.length > 0
parsedStructure &&
customStructure.length === parsedStructure.length
? customStructure ? customStructure
: parsedStructure) || undefined, : parsedStructure) || undefined,
rhymes: rhymes || undefined, rhymes: rhymes || undefined,
@@ -279,11 +277,11 @@ const CreateLyricsWithAi = () => {
// sauter Rhymes et CreatingLyrics et aller directement sur Lyrics // sauter Rhymes et CreatingLyrics et aller directement sur Lyrics
if (hasLyrics && selectedIndex === 6) { if (hasLyrics && selectedIndex === 6) {
const chosenStructure = const chosenStructure =
(customStructure && Array.isArray(customStructure) && customStructure.length > 0
parsedStructure &&
customStructure.length === parsedStructure.length
? customStructure ? customStructure
: parsedStructure) || []; : Array.isArray(parsedStructure)
? parsedStructure
: [];
await updateProjectData({ await updateProjectData({
config: { structure: chosenStructure }, config: { structure: chosenStructure },
selections: { selections: {
@@ -203,9 +203,7 @@ const CreateLyricsWithAi = () => {
style: resolvedStyle, style: resolvedStyle,
audience: audience?.trim() ? audience.trim() : undefined, audience: audience?.trim() ? audience.trim() : undefined,
structure: structure:
(customStructure && (Array.isArray(customStructure) && customStructure.length > 0
parsedStructure &&
customStructure.length === parsedStructure.length
? customStructure ? customStructure
: parsedStructure) || undefined, : parsedStructure) || undefined,
rhymes: rhymes || undefined, rhymes: rhymes || undefined,
@@ -284,11 +282,11 @@ const CreateLyricsWithAi = () => {
// sauter Rhymes et CreatingLyrics et aller directement sur Lyrics // sauter Rhymes et CreatingLyrics et aller directement sur Lyrics
if (hasLyrics && selectedIndex === 6) { if (hasLyrics && selectedIndex === 6) {
const chosenStructure = const chosenStructure =
(customStructure && Array.isArray(customStructure) && customStructure.length > 0
parsedStructure &&
customStructure.length === parsedStructure.length
? customStructure ? customStructure
: parsedStructure) || []; : Array.isArray(parsedStructure)
? parsedStructure
: [];
await updateProjectData({ await updateProjectData({
config: { structure: chosenStructure }, config: { structure: chosenStructure },
selections: { selections: {
@@ -1,12 +1,12 @@
import { View, StyleSheet, Image, Platform, Text } from "react-native";
import React, { useMemo, useState, useCallback, useEffect } from "react";
import Animated, { useAnimatedRef } from "react-native-reanimated";
import { BlurView } from "expo-blur"; import { BlurView } from "expo-blur";
import CreateLyricsHeader from "./components/CreateLyricsHeader"; import React, { useEffect, useMemo, useState } from "react";
import { Palette, Style } from "../../styles"; import { Image, Platform, StyleSheet, Text, View } from "react-native";
import { FONT_FAMILY } from "../../styles/Fonts"; import Animated, { useAnimatedRef } from "react-native-reanimated";
import Sortable from "react-native-sortables"; import Sortable from "react-native-sortables";
import { icons } from "../../assets"; import { icons } from "../../assets";
import { Palette, Style } from "../../styles";
import { FONT_FAMILY } from "../../styles/Fonts";
import CreateLyricsHeader from "./components/CreateLyricsHeader";
// baseStructure: array like ['couplet','refrain',...] // baseStructure: array like ['couplet','refrain',...]
// onChange: callback that receives array like ['couplet','refrain',...] // onChange: callback that receives array like ['couplet','refrain',...]
+5 -5
View File
@@ -1,13 +1,13 @@
import { View, Image, StyleSheet } from "react-native";
import React from "react"; import React from "react";
import Page from "../../layouts/Page"; import { Image, StyleSheet, View } from "react-native";
import { ai } from "../../assets"; import { ai } from "../../assets";
import MusicLandHeader from "../../components/MusicLandHeader";
import { goBack, navigate } from "../../navigation/NavigationService";
import { gutters } from "../../styles";
import BorderGradientButton from "../../components/BorderGradientButton"; import BorderGradientButton from "../../components/BorderGradientButton";
import GradientButton from "../../components/GradientButton"; import GradientButton from "../../components/GradientButton";
import MusicLandHeader from "../../components/MusicLandHeader";
import Page from "../../layouts/Page";
import { Routes } from "../../navigation"; import { Routes } from "../../navigation";
import { goBack, navigate } from "../../navigation/NavigationService";
import { gutters } from "../../styles";
const FinishedWriting = () => { const FinishedWriting = () => {
return ( return (
+7 -1
View File
@@ -237,7 +237,13 @@ const Lyrics = ({ navigation }) => {
.doc(selectedProjectId) .doc(selectedProjectId)
.set(updateData, { merge: true }); .set(updateData, { merge: true });
} }
navigate(Routes.Home); navigate(Routes.BottomTab, {
screen: Routes.HomeStack,
params: {
screen: Routes.Home,
params: { showLyricsCongrats: true },
},
});
} catch (e) { } catch (e) {
console.log(e); console.log(e);
alertMessage("Erreur", "Échec de l'enregistrement dans le projet."); alertMessage("Erreur", "Échec de l'enregistrement dans le projet.");