From 4b64e2d96188de038c0e997a30c35956b7850aba Mon Sep 17 00:00:00 2001 From: Leon Date: Wed, 4 Mar 2026 15:30:18 +0100 Subject: [PATCH] feat: center generation text --- src/screens/Playback/Playback.js | 20 +++++++++++++------ src/screens/Studio/GeneratingSong.js | 24 ++++++++++++++++++----- src/screens/Writing/CreateLyricsWithAi.js | 14 +++++++++++-- src/screens/cover/SongDownload.js | 23 +++++++++++++++++++--- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/src/screens/Playback/Playback.js b/src/screens/Playback/Playback.js index 96dbfd4..da1c9be 100644 --- a/src/screens/Playback/Playback.js +++ b/src/screens/Playback/Playback.js @@ -8,12 +8,12 @@ import MusicLandHeader from '../../components/MusicLandHeader' import Page from '../../layouts/Page' import { isWeb } from '../../hooks/useLayoutType' import { Routes } from '../../navigation' -import { navigate } from '../../navigation/NavigationService' +import { goBack, navigate } from '../../navigation/NavigationService' import { useUser } from '../../providers/UserDataProvider' import { gutters } from '../../styles' const Playback = ({ route, navigation }) => { - const { project } = route.params || {} + const { project, returnToAdventureModal = false } = route.params || {} const { videos } = useUser() // const benhaiUrl = isWeb ? videos?.benhaiWeb || null : videos?.benhai; const theoUrl = isWeb ? videos?.theoWeb : videos?.theo @@ -23,9 +23,17 @@ const Playback = ({ route, navigation }) => { setShowIntro(null) } + const handleBackPress = useCallback(() => { + if (returnToAdventureModal) { + goBack() + return + } + navigation.navigate(Routes.Home) + }, [navigation, returnToAdventureModal]) + const onPressRecord = useCallback(() => { - navigate(Routes.RecordPlayback, { project }) - }, [project]) + navigate(Routes.RecordPlayback, { project, returnToAdventureModal }) + }, [project, returnToAdventureModal]) return ( { backgroundImg={isWeb ? background.playbackWeb : background.playbackMobile} > {/* */} - navigation.navigate(Routes.Home)} progress={25} /> + { navigate(Routes.PlaybackGuide)} + onPress={() => navigate(Routes.PlaybackGuide, { returnToAdventureModal })} /> {/* */} diff --git a/src/screens/Studio/GeneratingSong.js b/src/screens/Studio/GeneratingSong.js index c7a4fc8..f91c568 100644 --- a/src/screens/Studio/GeneratingSong.js +++ b/src/screens/Studio/GeneratingSong.js @@ -273,6 +273,7 @@ const GeneratingSong = () => { const progressStatus = isFailed ? 'error' : 'default' const displayProgress = Math.max(0, Math.min(100, Math.round(progress || 0))) const progressLabel = isFailed ? 'Erreur' : `${displayProgress}%` + const useSquareGeneratingCard = Platform.OS !== 'web' && !isFailed return ( @@ -289,16 +290,19 @@ const GeneratingSong = () => { /> { - + { const [selectedIndex, setSelectedIndex] = useState(0) const [progress, setProgress] = useState(16) const [parentLayout, setparentLayout] = useState(null) + const [headerHeight, setHeaderHeight] = useState(0) const containerWidth = windowWidth const handleLyricsError = React.useCallback(() => { setSelectedIndex(7) @@ -352,14 +353,23 @@ const CreateLyricsWithAi = () => { return ( - + { + const nextHeight = event?.nativeEvent?.layout?.height + if (typeof nextHeight === 'number' && nextHeight !== headerHeight) { + setHeaderHeight(nextHeight) + } + }} + > + + { skipAdventureGate ? 'stop' : 'pending' ) const adventureGateTriggeredRef = useRef(false) + const reopenAdventureModalOnFocusRef = useRef(false) const projectForStage = useMemo(() => { if (routeProject?.id && selectedProject?.id && routeProject.id === selectedProject.id) { @@ -134,6 +135,17 @@ const SongDownload = ({ route }) => { }, [backRoute, handleBackPress]) ) + useFocusEffect( + useCallback(() => { + if (!reopenAdventureModalOnFocusRef.current) { + return undefined + } + setShowIntro(null) + setShowAdventureModal(true) + return undefined + }, []) + ) + useEffect(() => { if (adventureGateTriggeredRef.current) { return @@ -194,7 +206,10 @@ const SongDownload = ({ route }) => { const nextPlaybackStage = getStageAction('director', nextProject) const targetRoute = nextPlaybackStage?.route || Routes.Playback const params = nextPlaybackStage?.params || { project: nextProject } - navigate(targetRoute, params) + push(targetRoute, { + ...params, + returnToAdventureModal: true, + }) } catch (error) { console.log('[SongDownload] continue error', error?.message) } finally { @@ -203,8 +218,8 @@ const SongDownload = ({ route }) => { }, [ coverOptions, coverUrl, - navigate, projectForStage, + push, selectedOption, setLoading, updateProjectData, @@ -216,6 +231,7 @@ const SongDownload = ({ route }) => { }, []) const handleContinueAdventure = useCallback(() => { + reopenAdventureModalOnFocusRef.current = true setShowAdventureModal(false) setAdventureChoice('continue') continueFlow() @@ -526,6 +542,7 @@ const SongDownload = ({ route }) => { }, [downloadPaymentPending, handleDownload, hasPaidDownload, isDownloading]) const handleStopAdventure = useCallback(() => { + reopenAdventureModalOnFocusRef.current = false setShowAdventureModal(false) setAdventureChoice('stop') }, [])