diff --git a/src/providers/PlayerProvider.js b/src/providers/PlayerProvider.js index 1bec3d3..e9d7687 100644 --- a/src/providers/PlayerProvider.js +++ b/src/providers/PlayerProvider.js @@ -1,3 +1,4 @@ +import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio"; import React, { createContext, useCallback, @@ -7,7 +8,6 @@ import React, { useState, } from "react"; import { Platform } from "react-native"; -import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio"; import { useGlobal } from "reactn"; import GlobalAudioPlayer from "../components/player/GlobalAudioPlayer"; @@ -153,7 +153,12 @@ const normalizeTrack = (trackInput = {}, options = {}) => { if (!id && typeof source === "number") { 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; } if (!id) { @@ -174,7 +179,12 @@ const normalizeTrack = (trackInput = {}, options = {}) => { ? 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 { id, @@ -282,7 +292,9 @@ const PlayerProvider = ({ children }) => { async (trackInput, options = {}) => { const normalized = normalizeTrack(trackInput, options); 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; } @@ -370,7 +382,10 @@ const PlayerProvider = ({ children }) => { options ); - if (trackInput && (!currentTrack || (targetId && targetId !== currentTrack.id))) { + if ( + trackInput && + (!currentTrack || (targetId && targetId !== currentTrack.id)) + ) { await play(trackInput, options); return; } diff --git a/src/screens/Home/Home.js b/src/screens/Home/Home.js index 08080d4..f0e7dee 100644 --- a/src/screens/Home/Home.js +++ b/src/screens/Home/Home.js @@ -29,7 +29,7 @@ import { getStageAction, } from "../../utils/projectStages"; -const Home = () => { +const Home = ({ navigation, route }) => { const { userProjects = [], resetSelectedProject, @@ -216,6 +216,16 @@ const Home = () => { ]; }, [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 = stageStates[activeStageIndex] || stageStates[preferredStageIndex]; const stageAction = useMemo(() => { diff --git a/src/screens/Writing/CreateLyricsWithAi.js b/src/screens/Writing/CreateLyricsWithAi.js index f7c3c52..4aa66f8 100644 --- a/src/screens/Writing/CreateLyricsWithAi.js +++ b/src/screens/Writing/CreateLyricsWithAi.js @@ -198,9 +198,7 @@ const CreateLyricsWithAi = () => { style: resolvedStyle, audience: audience?.trim() ? audience.trim() : undefined, structure: - (customStructure && - parsedStructure && - customStructure.length === parsedStructure.length + (Array.isArray(customStructure) && customStructure.length > 0 ? customStructure : parsedStructure) || undefined, rhymes: rhymes || undefined, @@ -279,11 +277,11 @@ const CreateLyricsWithAi = () => { // sauter Rhymes et CreatingLyrics et aller directement sur Lyrics if (hasLyrics && selectedIndex === 6) { const chosenStructure = - (customStructure && - parsedStructure && - customStructure.length === parsedStructure.length + Array.isArray(customStructure) && customStructure.length > 0 ? customStructure - : parsedStructure) || []; + : Array.isArray(parsedStructure) + ? parsedStructure + : []; await updateProjectData({ config: { structure: chosenStructure }, selections: { diff --git a/src/screens/Writing/CreateLyricsWithAi.web.js b/src/screens/Writing/CreateLyricsWithAi.web.js index 21e216e..45dffc3 100644 --- a/src/screens/Writing/CreateLyricsWithAi.web.js +++ b/src/screens/Writing/CreateLyricsWithAi.web.js @@ -203,9 +203,7 @@ const CreateLyricsWithAi = () => { style: resolvedStyle, audience: audience?.trim() ? audience.trim() : undefined, structure: - (customStructure && - parsedStructure && - customStructure.length === parsedStructure.length + (Array.isArray(customStructure) && customStructure.length > 0 ? customStructure : parsedStructure) || undefined, rhymes: rhymes || undefined, @@ -284,11 +282,11 @@ const CreateLyricsWithAi = () => { // sauter Rhymes et CreatingLyrics et aller directement sur Lyrics if (hasLyrics && selectedIndex === 6) { const chosenStructure = - (customStructure && - parsedStructure && - customStructure.length === parsedStructure.length + Array.isArray(customStructure) && customStructure.length > 0 ? customStructure - : parsedStructure) || []; + : Array.isArray(parsedStructure) + ? parsedStructure + : []; await updateProjectData({ config: { structure: chosenStructure }, selections: { diff --git a/src/screens/Writing/CustomizeSongStructure.js b/src/screens/Writing/CustomizeSongStructure.js index cbb42f9..9508dc6 100644 --- a/src/screens/Writing/CustomizeSongStructure.js +++ b/src/screens/Writing/CustomizeSongStructure.js @@ -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 CreateLyricsHeader from "./components/CreateLyricsHeader"; -import { Palette, Style } from "../../styles"; -import { FONT_FAMILY } from "../../styles/Fonts"; +import React, { useEffect, useMemo, useState } from "react"; +import { Image, Platform, StyleSheet, Text, View } from "react-native"; +import Animated, { useAnimatedRef } from "react-native-reanimated"; import Sortable from "react-native-sortables"; 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',...] // onChange: callback that receives array like ['couplet','refrain',...] diff --git a/src/screens/Writing/FinishedWriting.js b/src/screens/Writing/FinishedWriting.js index abf239d..b930f74 100644 --- a/src/screens/Writing/FinishedWriting.js +++ b/src/screens/Writing/FinishedWriting.js @@ -1,13 +1,13 @@ -import { View, Image, StyleSheet } from "react-native"; import React from "react"; -import Page from "../../layouts/Page"; +import { Image, StyleSheet, View } from "react-native"; 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 GradientButton from "../../components/GradientButton"; +import MusicLandHeader from "../../components/MusicLandHeader"; +import Page from "../../layouts/Page"; import { Routes } from "../../navigation"; +import { goBack, navigate } from "../../navigation/NavigationService"; +import { gutters } from "../../styles"; const FinishedWriting = () => { return ( diff --git a/src/screens/Writing/Lyrics.js b/src/screens/Writing/Lyrics.js index dc7fc4e..03bfc97 100644 --- a/src/screens/Writing/Lyrics.js +++ b/src/screens/Writing/Lyrics.js @@ -237,7 +237,13 @@ const Lyrics = ({ navigation }) => { .doc(selectedProjectId) .set(updateData, { merge: true }); } - navigate(Routes.Home); + navigate(Routes.BottomTab, { + screen: Routes.HomeStack, + params: { + screen: Routes.Home, + params: { showLyricsCongrats: true }, + }, + }); } catch (e) { console.log(e); alertMessage("Erreur", "Échec de l'enregistrement dans le projet.");