progress && remove video
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Image, Pressable, Text, View } from "react-native";
|
import { Image, Platform, Pressable, Text, View } from "react-native";
|
||||||
import { icons } from "../assets";
|
import { icons } from "../assets";
|
||||||
import { Palette, Style } from "../styles";
|
import { Palette, Style } from "../styles";
|
||||||
import { FONT_FAMILY } from "../styles/Fonts";
|
import { FONT_FAMILY } from "../styles/Fonts";
|
||||||
@@ -12,6 +12,30 @@ const MusicLandHeader = ({
|
|||||||
progress = 1,
|
progress = 1,
|
||||||
logo = null,
|
logo = null,
|
||||||
}) => {
|
}) => {
|
||||||
|
const isWeb = Platform.OS === "web";
|
||||||
|
const backButtonStyle = isWeb
|
||||||
|
? {
|
||||||
|
...Style.containerRow,
|
||||||
|
gap: 8,
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
paddingVertical: 8,
|
||||||
|
// backgroundColor: Palette.transparentWhite,
|
||||||
|
// borderRadius: mainBorderRadius,
|
||||||
|
}
|
||||||
|
: { width: 24, height: 24, ...Style.containerCenter };
|
||||||
|
const backIconSource = isWeb ? icons.arrowRight : icons.chevronDown;
|
||||||
|
const backIconStyle = isWeb
|
||||||
|
? {
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
transform: [{ rotate: "180deg" }],
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
width: 15,
|
||||||
|
height: 15,
|
||||||
|
transform: [{ rotate: "90deg" }],
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ alignItems: "center", gap: 16 }}>
|
<View style={{ alignItems: "center", gap: 16 }}>
|
||||||
<Image
|
<Image
|
||||||
@@ -19,15 +43,23 @@ const MusicLandHeader = ({
|
|||||||
style={{ alignSelf: "center", height: 150, resizeMode: "contain" }}
|
style={{ alignSelf: "center", height: 150, resizeMode: "contain" }}
|
||||||
/>
|
/>
|
||||||
<View style={{ width: "100%", ...Style.containerRow, gap: 16 }}>
|
<View style={{ width: "100%", ...Style.containerRow, gap: 16 }}>
|
||||||
<Pressable
|
<Pressable style={backButtonStyle} onPress={onPressBack}>
|
||||||
style={{ width: 24, height: 24, ...Style.containerCenter }}
|
|
||||||
onPress={onPressBack}
|
|
||||||
>
|
|
||||||
<Image
|
<Image
|
||||||
source={icons.chevronDown}
|
source={backIconSource}
|
||||||
style={{ width: 15, height: 15, transform: [{ rotate: "90deg" }] }}
|
style={backIconStyle}
|
||||||
resizeMode="contain"
|
resizeMode="contain"
|
||||||
/>
|
/>
|
||||||
|
{isWeb && (
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 14,
|
||||||
|
color: Palette.white,
|
||||||
|
fontFamily: FONT_FAMILY.InterSemiBold,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Retour
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ProgressBar progress={progress} />
|
<ProgressBar progress={progress} />
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ const GeneratingSong = () => {
|
|||||||
// Progress based on 8 minutes cap or until status becomes GENERATED
|
// Progress based on 8 minutes cap or until status becomes GENERATED
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const totalMs = 8 * 60 * 1000;
|
const totalMs = 8 * 60 * 1000;
|
||||||
|
const maxGeneratingProgress = 90;
|
||||||
const clearTimer = () => {
|
const clearTimer = () => {
|
||||||
if (progressTimerRef.current) {
|
if (progressTimerRef.current) {
|
||||||
global.clearInterval(progressTimerRef.current);
|
global.clearInterval(progressTimerRef.current);
|
||||||
@@ -44,6 +45,10 @@ const GeneratingSong = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const status = selectedProject?.musicStatus;
|
const status = selectedProject?.musicStatus;
|
||||||
|
const readyUrls = Array.isArray(selectedProject?.musicUrls)
|
||||||
|
? selectedProject.musicUrls.filter(Boolean)
|
||||||
|
: [];
|
||||||
|
const hasReadySong = readyUrls.length > 0 || !!selectedProject?.songUrl;
|
||||||
|
|
||||||
if (status !== "GENERATING") {
|
if (status !== "GENERATING") {
|
||||||
// Reset local start when leaving generating state
|
// Reset local start when leaving generating state
|
||||||
@@ -51,8 +56,14 @@ const GeneratingSong = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status === "GENERATED") {
|
if (status === "GENERATED") {
|
||||||
setProgress(100);
|
|
||||||
clearTimer();
|
clearTimer();
|
||||||
|
setProgress(hasReadySong ? 100 : maxGeneratingProgress);
|
||||||
|
return () => clearTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status !== "GENERATING") {
|
||||||
|
clearTimer();
|
||||||
|
setProgress(0);
|
||||||
return () => clearTimer();
|
return () => clearTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +86,8 @@ const GeneratingSong = () => {
|
|||||||
}
|
}
|
||||||
const elapsed = moment().diff(moment(startDate));
|
const elapsed = moment().diff(moment(startDate));
|
||||||
const raw = Math.floor((elapsed / totalMs) * 100);
|
const raw = Math.floor((elapsed / totalMs) * 100);
|
||||||
// While status is GENERATING, block visual progress at 99%
|
// While status is GENERATING, block visual progress at 90%
|
||||||
const pct = Math.max(0, Math.min(99, raw));
|
const pct = Math.max(0, Math.min(maxGeneratingProgress, raw));
|
||||||
setProgress(pct);
|
setProgress(pct);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,7 +95,12 @@ const GeneratingSong = () => {
|
|||||||
clearTimer();
|
clearTimer();
|
||||||
progressTimerRef.current = global.setInterval(update, 1000);
|
progressTimerRef.current = global.setInterval(update, 1000);
|
||||||
return () => clearTimer();
|
return () => clearTimer();
|
||||||
}, [selectedProject?.musicStatus, selectedProject?.generationStartAt]);
|
}, [
|
||||||
|
selectedProject?.musicStatus,
|
||||||
|
selectedProject?.generationStartAt,
|
||||||
|
selectedProject?.musicUrls,
|
||||||
|
selectedProject?.songUrl,
|
||||||
|
]);
|
||||||
|
|
||||||
// Auto navigate to SongReady when generation completed
|
// Auto navigate to SongReady when generation completed
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React from "react";
|
||||||
import { Image, StyleSheet, View } from "react-native";
|
import { Image, StyleSheet, View } from "react-native";
|
||||||
import useMinuit from "react-native-minuit/src/hooks/useMinuit.js";
|
import useMinuit from "react-native-minuit/src/hooks/useMinuit.js";
|
||||||
import { ai, background, icons } from "../../assets";
|
import { ai, background, icons } from "../../assets";
|
||||||
import BorderGradientButton from "../../components/BorderGradientButton";
|
import BorderGradientButton from "../../components/BorderGradientButton";
|
||||||
import FullscreenIntroVideo from "../../components/FullscreenIntroVideo";
|
|
||||||
import GradientButton from "../../components/GradientButton";
|
import GradientButton from "../../components/GradientButton";
|
||||||
import MusicLandHeader from "../../components/MusicLandHeader";
|
import MusicLandHeader from "../../components/MusicLandHeader";
|
||||||
import { isWeb } from "../../hooks/useLayoutType";
|
import { isWeb } from "../../hooks/useLayoutType";
|
||||||
@@ -18,14 +17,6 @@ const WritingLyrics = () => {
|
|||||||
useUserData();
|
useUserData();
|
||||||
const { setIsLoading } = useMinuit();
|
const { setIsLoading } = useMinuit();
|
||||||
|
|
||||||
const [showIntro, setShowIntro] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (selectedProject === null) {
|
|
||||||
setShowIntro(true);
|
|
||||||
}
|
|
||||||
}, [selectedProject]);
|
|
||||||
|
|
||||||
async function createAndNavigate({ hasLyrics = false }) {
|
async function createAndNavigate({ hasLyrics = false }) {
|
||||||
try {
|
try {
|
||||||
await setIsLoading(true);
|
await setIsLoading(true);
|
||||||
@@ -76,11 +67,6 @@ const WritingLyrics = () => {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<FullscreenIntroVideo
|
|
||||||
url={require("../../../src/assets/video/testVideo.mp4")}
|
|
||||||
visible={showIntro}
|
|
||||||
onClose={() => setShowIntro(false)}
|
|
||||||
/>
|
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user