feat: play from dropdown
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.2 MiB |
@@ -1,8 +1,10 @@
|
|||||||
import { BlurView } from "expo-blur";
|
import { BlurView } from "expo-blur";
|
||||||
import { Portal } from "@gorhom/portal";
|
import { Portal } from "@gorhom/portal";
|
||||||
import React, {
|
import React, {
|
||||||
|
forwardRef,
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
useImperativeHandle,
|
||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
@@ -78,7 +80,9 @@ const defaultFormatDate = (timestamp) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ProjectDropDown = ({
|
const ProjectDropDown = forwardRef(
|
||||||
|
(
|
||||||
|
{
|
||||||
style,
|
style,
|
||||||
projects = [],
|
projects = [],
|
||||||
selectedProject,
|
selectedProject,
|
||||||
@@ -87,7 +91,9 @@ const ProjectDropDown = ({
|
|||||||
onCreateProject,
|
onCreateProject,
|
||||||
formatDate = defaultFormatDate,
|
formatDate = defaultFormatDate,
|
||||||
allowEmptySelection = false,
|
allowEmptySelection = false,
|
||||||
}) => {
|
},
|
||||||
|
ref
|
||||||
|
) => {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [triggerLayout, setTriggerLayout] = useState(null);
|
const [triggerLayout, setTriggerLayout] = useState(null);
|
||||||
const [triggerWindowLayout, setTriggerWindowLayout] = useState(null);
|
const [triggerWindowLayout, setTriggerWindowLayout] = useState(null);
|
||||||
@@ -145,6 +151,14 @@ const ProjectDropDown = ({
|
|||||||
|
|
||||||
const closeDropdown = useCallback(() => setIsOpen(false), []);
|
const closeDropdown = useCallback(() => setIsOpen(false), []);
|
||||||
|
|
||||||
|
useImperativeHandle(
|
||||||
|
ref,
|
||||||
|
() => ({
|
||||||
|
close: closeDropdown,
|
||||||
|
}),
|
||||||
|
[closeDropdown]
|
||||||
|
);
|
||||||
|
|
||||||
const handleSelect = useCallback(
|
const handleSelect = useCallback(
|
||||||
(project) => {
|
(project) => {
|
||||||
if (!project?.id) return;
|
if (!project?.id) return;
|
||||||
@@ -353,7 +367,8 @@ const ProjectDropDown = ({
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export default ProjectDropDown;
|
export default ProjectDropDown;
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
getStageAction,
|
getStageAction,
|
||||||
} from "../../utils/projectStages";
|
} from "../../utils/projectStages";
|
||||||
import { openCoinPackModal } from "../../utils/coinPackModal";
|
import { openCoinPackModal } from "../../utils/coinPackModal";
|
||||||
|
import useNavigateToMusicDetails from "../../hooks/useNavigateToMusicDetails";
|
||||||
import StageCard from "./components/StageCard";
|
import StageCard from "./components/StageCard";
|
||||||
import ClubCard from "./components/ClubCard";
|
import ClubCard from "./components/ClubCard";
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ const STAGE_CARD_CONTENT = [
|
|||||||
key: "beatmaker",
|
key: "beatmaker",
|
||||||
step: "ÉTAPE 2",
|
step: "ÉTAPE 2",
|
||||||
description:
|
description:
|
||||||
"Bienvenue au studio MusicLand.\nNous mettons en musique tes paroles en fonction de tes inspirations, ça va être top !",
|
"Je suis Malik, responsable du studio de MusicLand.\nJe vais mettre en musique tes paroles en fonction de tes goûts musicaux, ça va être top !",
|
||||||
image: cardsImg.studio,
|
image: cardsImg.studio,
|
||||||
imagePosition: "right",
|
imagePosition: "right",
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
@@ -86,7 +87,7 @@ const STAGE_CARD_CONTENT = [
|
|||||||
key: "publisher",
|
key: "publisher",
|
||||||
step: "ÉTAPE 4",
|
step: "ÉTAPE 4",
|
||||||
description:
|
description:
|
||||||
"À la sortie du studio, l'équipe production te propose les prochaines étapes pour partager ta musique avec le monde.",
|
"Je suis Mr Benhaï, Producteur de MusicLand, et je vais te faire une proposition qui pourrait t’intéresser. On se retrouve à la sortie du studio !",
|
||||||
image: cardsImg.production,
|
image: cardsImg.production,
|
||||||
imagePosition: "right",
|
imagePosition: "right",
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
@@ -115,6 +116,7 @@ const Home = ({ navigation, route }) => {
|
|||||||
} = useUser();
|
} = useUser();
|
||||||
const { setTooltip } = useMinuit();
|
const { setTooltip } = useMinuit();
|
||||||
const [videoUrl, setVideoUrl] = useState(null);
|
const [videoUrl, setVideoUrl] = useState(null);
|
||||||
|
const navigateToMusicDetails = useNavigateToMusicDetails();
|
||||||
|
|
||||||
if (!currentUID) {
|
if (!currentUID) {
|
||||||
return <LandingPage />;
|
return <LandingPage />;
|
||||||
@@ -174,6 +176,7 @@ const Home = ({ navigation, route }) => {
|
|||||||
const [menuAnchor, setMenuAnchor] = useState(null);
|
const [menuAnchor, setMenuAnchor] = useState(null);
|
||||||
const [menuProject, setMenuProject] = useState(null);
|
const [menuProject, setMenuProject] = useState(null);
|
||||||
const menuAnchorRef = useRef(null);
|
const menuAnchorRef = useRef(null);
|
||||||
|
const projectDropdownRef = useRef(null);
|
||||||
const [hasLocalAdventureFlag, setHasLocalAdventureFlag] = useState(false);
|
const [hasLocalAdventureFlag, setHasLocalAdventureFlag] = useState(false);
|
||||||
|
|
||||||
const handleSelectProject = useCallback(
|
const handleSelectProject = useCallback(
|
||||||
@@ -232,8 +235,27 @@ const Home = ({ navigation, route }) => {
|
|||||||
|
|
||||||
const moreMenuItems = useMemo(() => {
|
const moreMenuItems = useMemo(() => {
|
||||||
if (!menuProject?.id) return [];
|
if (!menuProject?.id) return [];
|
||||||
return [
|
|
||||||
{
|
const items = [];
|
||||||
|
const hasSongUrl =
|
||||||
|
typeof menuProject?.songUrl === "string" &&
|
||||||
|
menuProject.songUrl.length > 0;
|
||||||
|
|
||||||
|
if (hasSongUrl) {
|
||||||
|
items.push({
|
||||||
|
label: "Jouer la musique",
|
||||||
|
onPress: () => {
|
||||||
|
projectDropdownRef.current?.close?.();
|
||||||
|
navigateToMusicDetails({
|
||||||
|
projectId: menuProject.id,
|
||||||
|
songUrl: menuProject.songUrl,
|
||||||
|
project: menuProject,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push({
|
||||||
label: "Supprimer",
|
label: "Supprimer",
|
||||||
onPress: () =>
|
onPress: () =>
|
||||||
Alert(
|
Alert(
|
||||||
@@ -251,9 +273,10 @@ const Home = ({ navigation, route }) => {
|
|||||||
],
|
],
|
||||||
{ cancelable: true },
|
{ cancelable: true },
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
|
||||||
}, [handleDeleteProject, menuProject?.id]);
|
return items;
|
||||||
|
}, [handleDeleteProject, menuProject, navigateToMusicDetails]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!route?.params?.showLyricsCongrats) {
|
if (!route?.params?.showLyricsCongrats) {
|
||||||
@@ -495,6 +518,7 @@ const Home = ({ navigation, route }) => {
|
|||||||
<View style={styles.topBar}>
|
<View style={styles.topBar}>
|
||||||
{mobileInfoRow}
|
{mobileInfoRow}
|
||||||
<ProjectDropDown
|
<ProjectDropDown
|
||||||
|
ref={projectDropdownRef}
|
||||||
style={styles.projectDropDown}
|
style={styles.projectDropDown}
|
||||||
projects={projects}
|
projects={projects}
|
||||||
selectedProject={currentProject}
|
selectedProject={currentProject}
|
||||||
|
|||||||
Reference in New Issue
Block a user