last tickets
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">MusicLand</string>
|
<string name="app_name">MusicLand</string>
|
||||||
<string name="expo_splash_screen_resize_mode" translatable="false">cover</string>
|
<string name="expo_splash_screen_resize_mode" translatable="false">contain</string>
|
||||||
<string name="expo_splash_screen_status_bar_translucent" translatable="false">false</string>
|
<string name="expo_splash_screen_status_bar_translucent" translatable="false">false</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
"expo-linking": "~7.0.5",
|
"expo-linking": "~7.0.5",
|
||||||
"expo-location": "~18.0.10",
|
"expo-location": "~18.0.10",
|
||||||
"expo-notifications": "~0.29.14",
|
"expo-notifications": "~0.29.14",
|
||||||
|
"expo-sharing": "~13.0.1",
|
||||||
"expo-speech": "~13.0.1",
|
"expo-speech": "~13.0.1",
|
||||||
"expo-splash-screen": "~0.29.24",
|
"expo-splash-screen": "~0.29.24",
|
||||||
"expo-status-bar": "~2.0.1",
|
"expo-status-bar": "~2.0.1",
|
||||||
@@ -1388,6 +1389,8 @@
|
|||||||
|
|
||||||
"expo-notifications": ["expo-notifications@0.29.14", "", { "dependencies": { "@expo/image-utils": "^0.6.5", "@ide/backoff": "^1.0.0", "abort-controller": "^3.0.0", "assert": "^2.0.0", "badgin": "^1.1.5", "expo-application": "~6.0.2", "expo-constants": "~17.0.8" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-AVduNx9mKOgcAqBfrXS1OHC9VAQZrDQLbVbcorMjPDGXW7m0Q5Q+BG6FYM/saVviF2eO8fhQRsTT40yYv5/bhQ=="],
|
"expo-notifications": ["expo-notifications@0.29.14", "", { "dependencies": { "@expo/image-utils": "^0.6.5", "@ide/backoff": "^1.0.0", "abort-controller": "^3.0.0", "assert": "^2.0.0", "badgin": "^1.1.5", "expo-application": "~6.0.2", "expo-constants": "~17.0.8" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-AVduNx9mKOgcAqBfrXS1OHC9VAQZrDQLbVbcorMjPDGXW7m0Q5Q+BG6FYM/saVviF2eO8fhQRsTT40yYv5/bhQ=="],
|
||||||
|
|
||||||
|
"expo-sharing": ["expo-sharing@13.0.1", "", { "peerDependencies": { "expo": "*" } }, "sha512-qych3Nw65wlFcnzE/gRrsdtvmdV0uF4U4qVMZBJYPG90vYyWh2QM9rp1gVu0KWOBc7N8CC2dSVYn4/BXqJy6Xw=="],
|
||||||
|
|
||||||
"expo-speech": ["expo-speech@13.0.1", "", { "peerDependencies": { "expo": "*" } }, "sha512-J7tvFzORsFpIKihMnayeY5lCPc15giDrlN+ws2uUNo0MvLv1HCYEu/5p3+aMmZXXsY5I1QlconD4CwRWw3JFig=="],
|
"expo-speech": ["expo-speech@13.0.1", "", { "peerDependencies": { "expo": "*" } }, "sha512-J7tvFzORsFpIKihMnayeY5lCPc15giDrlN+ws2uUNo0MvLv1HCYEu/5p3+aMmZXXsY5I1QlconD4CwRWw3JFig=="],
|
||||||
|
|
||||||
"expo-splash-screen": ["expo-splash-screen@0.29.24", "", { "dependencies": { "@expo/prebuild-config": "~8.2.0" }, "peerDependencies": { "expo": "*" } }, "sha512-k2rdjbb3Qeg4g104Sdz6+qXXYba8QgiuZRSxHX8IpsSYiiTU48BmCCGy12sN+O1B+sD1/+WPL4duCa1Fy6+Y4g=="],
|
"expo-splash-screen": ["expo-splash-screen@0.29.24", "", { "dependencies": { "@expo/prebuild-config": "~8.2.0" }, "peerDependencies": { "expo": "*" } }, "sha512-k2rdjbb3Qeg4g104Sdz6+qXXYba8QgiuZRSxHX8IpsSYiiTU48BmCCGy12sN+O1B+sD1/+WPL4duCa1Fy6+Y4g=="],
|
||||||
|
|||||||
@@ -125,9 +125,11 @@ async function markPlaybackCompatibility({ projectId, initiatorUid = null }) {
|
|||||||
const docRef = db.collection("projects").doc(projectId);
|
const docRef = db.collection("projects").doc(projectId);
|
||||||
await docRef.set(
|
await docRef.set(
|
||||||
{
|
{
|
||||||
"playbackCompatibility.codec": PLAYBACK_CODEC_TAG,
|
playbackCompatibility: {
|
||||||
"playbackCompatibility.migratedAt": FieldValue.serverTimestamp(),
|
codec: PLAYBACK_CODEC_TAG,
|
||||||
"playbackCompatibility.migratedBy": initiatorUid,
|
migratedAt: FieldValue.serverTimestamp(),
|
||||||
|
migratedBy: initiatorUid,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ merge: true }
|
{ merge: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
"expo-linking": "~7.0.5",
|
"expo-linking": "~7.0.5",
|
||||||
"expo-location": "~18.0.10",
|
"expo-location": "~18.0.10",
|
||||||
"expo-notifications": "~0.29.14",
|
"expo-notifications": "~0.29.14",
|
||||||
|
"expo-sharing": "~13.0.1",
|
||||||
"expo-speech": "~13.0.1",
|
"expo-speech": "~13.0.1",
|
||||||
"expo-splash-screen": "~0.29.24",
|
"expo-splash-screen": "~0.29.24",
|
||||||
"expo-status-bar": "~2.0.1",
|
"expo-status-bar": "~2.0.1",
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ const AppActionSheet = ({
|
|||||||
width: 50,
|
width: 50,
|
||||||
zIndex: 2,
|
zIndex: 2,
|
||||||
}}
|
}}
|
||||||
|
closeOnTouchBackdrop
|
||||||
|
closeOnPressBack
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
{...sheetProps}
|
{...sheetProps}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { StyleSheet, Text, View } from "react-native";
|
||||||
|
import { gutters, Palette } from "../styles";
|
||||||
|
import { FONT_FAMILY } from "../styles/Fonts";
|
||||||
|
import BorderGradientButton from "./BorderGradientButton";
|
||||||
|
import GradientButton from "./GradientButton";
|
||||||
|
import Overlay from "./Overlay";
|
||||||
|
|
||||||
|
const SubscriptionConfirmModal = ({
|
||||||
|
isVisible,
|
||||||
|
setIsVisible,
|
||||||
|
onJoinClub,
|
||||||
|
onContinue,
|
||||||
|
continueLabel = "Continuer vers la création de playback",
|
||||||
|
}) => {
|
||||||
|
const handleJoinClub = () => {
|
||||||
|
if (typeof setIsVisible === "function") {
|
||||||
|
setIsVisible(false);
|
||||||
|
}
|
||||||
|
if (typeof onJoinClub === "function") {
|
||||||
|
onJoinClub();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleContinue = () => {
|
||||||
|
if (typeof setIsVisible === "function") {
|
||||||
|
setIsVisible(false);
|
||||||
|
}
|
||||||
|
if (typeof onContinue === "function") {
|
||||||
|
onContinue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Overlay
|
||||||
|
isVisible={isVisible}
|
||||||
|
setIsVisible={setIsVisible}
|
||||||
|
blurIntensity={15}
|
||||||
|
>
|
||||||
|
<View style={styles.modalCard}>
|
||||||
|
<Text style={styles.modalTitle}>
|
||||||
|
Continuer sans générer de revenus ?
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.modalDescription}>
|
||||||
|
Rejoins le Club Musicland pour monétiser tes écoutes et accéder aux
|
||||||
|
concours.
|
||||||
|
</Text>
|
||||||
|
<View style={styles.modalActions}>
|
||||||
|
<GradientButton
|
||||||
|
title="Rejoindre le club"
|
||||||
|
onPress={handleJoinClub}
|
||||||
|
containerStyle={styles.modalAction}
|
||||||
|
/>
|
||||||
|
<BorderGradientButton
|
||||||
|
title={continueLabel}
|
||||||
|
onPress={handleContinue}
|
||||||
|
containerStyle={styles.modalAction}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Overlay>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SubscriptionConfirmModal;
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
modalCard: {
|
||||||
|
width: "90%",
|
||||||
|
maxWidth: 420,
|
||||||
|
alignSelf: "center",
|
||||||
|
padding: gutters * 1.4,
|
||||||
|
borderRadius: 20,
|
||||||
|
backgroundColor: "rgba(37, 36, 56, 0.96)",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "rgba(255, 255, 255, 0.12)",
|
||||||
|
gap: gutters * 0.8,
|
||||||
|
},
|
||||||
|
modalTitle: {
|
||||||
|
fontFamily: FONT_FAMILY.InterSemiBold,
|
||||||
|
fontSize: 18,
|
||||||
|
color: Palette.white,
|
||||||
|
textAlign: "center",
|
||||||
|
},
|
||||||
|
modalDescription: {
|
||||||
|
fontFamily: FONT_FAMILY.InterRegular,
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: 20,
|
||||||
|
color: Palette.grayMid,
|
||||||
|
textAlign: "center",
|
||||||
|
},
|
||||||
|
modalActions: {
|
||||||
|
gap: gutters * 0.6,
|
||||||
|
marginTop: gutters * 0.6,
|
||||||
|
},
|
||||||
|
modalAction: {
|
||||||
|
width: "100%",
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
import React, { useCallback, useMemo, useState } from "react";
|
import React, {
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import {
|
import {
|
||||||
Image,
|
Image,
|
||||||
Pressable,
|
Pressable,
|
||||||
@@ -6,6 +12,7 @@ import {
|
|||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
|
findNodeHandle,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { SheetManager } from "react-native-actions-sheet";
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
import AppActionSheet from "../AppActionSheet";
|
import AppActionSheet from "../AppActionSheet";
|
||||||
@@ -25,6 +32,7 @@ const PlaybackPickerModal = () => {
|
|||||||
const { userProjects = [], createNewProject } = useUserData();
|
const { userProjects = [], createNewProject } = useUserData();
|
||||||
const [isCreating, setIsCreating] = useState(false);
|
const [isCreating, setIsCreating] = useState(false);
|
||||||
const [webVisible, setWebVisible] = useState(true);
|
const [webVisible, setWebVisible] = useState(true);
|
||||||
|
const modalRef = useRef(null);
|
||||||
|
|
||||||
const sanitizedProjects = useMemo(() => {
|
const sanitizedProjects = useMemo(() => {
|
||||||
if (!Array.isArray(userProjects)) {
|
if (!Array.isArray(userProjects)) {
|
||||||
@@ -101,13 +109,45 @@ const PlaybackPickerModal = () => {
|
|||||||
|
|
||||||
const hasProjects = sanitizedProjects.length > 0;
|
const hasProjects = sanitizedProjects.length > 0;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isWeb || !webVisible || typeof document === "undefined") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePointerDown = (event) => {
|
||||||
|
const node = modalRef.current;
|
||||||
|
if (!node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const domNode = findNodeHandle(node);
|
||||||
|
if (domNode && typeof domNode.contains === "function") {
|
||||||
|
if (domNode.contains(event.target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (domNode === event.target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hideSheet();
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener("pointerdown", handlePointerDown);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("pointerdown", handlePointerDown);
|
||||||
|
};
|
||||||
|
}, [hideSheet, webVisible]);
|
||||||
|
|
||||||
if (isWeb && !webVisible) {
|
if (isWeb && !webVisible) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppActionSheet id={SHEET_ID} webModal onClose={hideSheet}>
|
<AppActionSheet id={SHEET_ID} webModal onClose={hideSheet}>
|
||||||
<View style={{ gap: 18 }}>
|
<View ref={modalRef} style={{ gap: 18 }} collapsable={false}>
|
||||||
<Text style={styles.title}>Ajouter un playback</Text>
|
<Text style={styles.title}>Ajouter un playback</Text>
|
||||||
<Text style={styles.description}>
|
<Text style={styles.description}>
|
||||||
Choisis une musique déjà créée pour y ajouter un playback ou lance un
|
Choisis une musique déjà créée pour y ajouter un playback ou lance un
|
||||||
|
|||||||
@@ -6,7 +6,16 @@ import { FONT_FAMILY } from "../../styles/Fonts";
|
|||||||
import BorderGradientButton from "../BorderGradientButton";
|
import BorderGradientButton from "../BorderGradientButton";
|
||||||
import GradientButton from "../GradientButton";
|
import GradientButton from "../GradientButton";
|
||||||
|
|
||||||
const ValidateModal = ({ visible, onClose, onPressValidate }) => {
|
const ValidateModal = ({
|
||||||
|
visible,
|
||||||
|
onClose,
|
||||||
|
onPressValidate,
|
||||||
|
onPressSecondary,
|
||||||
|
title = "Attention !",
|
||||||
|
description = "Lorsque tu clique sur valider, tu ne pourra plus changer ni le texte ni la mélodie.",
|
||||||
|
primaryLabel = "Valider",
|
||||||
|
secondaryLabel = "Retour",
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
animationType="slide"
|
animationType="slide"
|
||||||
@@ -36,7 +45,7 @@ const ValidateModal = ({ visible, onClose, onPressValidate }) => {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Attention !
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
@@ -46,17 +55,22 @@ const ValidateModal = ({ visible, onClose, onPressValidate }) => {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Lorsque tu clique sur valider, tu ne pourra plus changer ni le
|
{description}
|
||||||
texte ni la mélodie.
|
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ width: "85%", alignSelf: "center", gap: 15 }}>
|
<View style={{ width: "85%", alignSelf: "center", gap: 15 }}>
|
||||||
<BorderGradientButton title="Retour" onPress={onClose} />
|
<BorderGradientButton
|
||||||
<GradientButton
|
title={secondaryLabel}
|
||||||
title="Valider"
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
onClose();
|
onClose?.();
|
||||||
|
onPressSecondary?.();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<GradientButton
|
||||||
|
title={primaryLabel}
|
||||||
|
onPress={() => {
|
||||||
|
onClose?.();
|
||||||
onPressValidate?.();
|
onPressValidate?.();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Image, Pressable, StyleSheet, Text, View } from "react-native";
|
|||||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
|
|
||||||
import { icons, img } from "../../assets";
|
import { icons, img } from "../../assets";
|
||||||
import { arrayRemove, arrayUnion, projectsRef } from "../../config/firebase";
|
import { projectsRef } from "../../config/firebase";
|
||||||
import useDataFromRef from "../../hooks/useDataFromRef";
|
import useDataFromRef from "../../hooks/useDataFromRef";
|
||||||
import { isWeb } from "../../hooks/useLayoutType";
|
import { isWeb } from "../../hooks/useLayoutType";
|
||||||
import usePlayer from "../../hooks/usePlayer";
|
import usePlayer from "../../hooks/usePlayer";
|
||||||
@@ -13,6 +13,11 @@ import { useUser } from "../../providers/UserDataProvider";
|
|||||||
import { gutters, Palette } from "../../styles";
|
import { gutters, Palette } from "../../styles";
|
||||||
import { FONT_FAMILY } from "../../styles/Fonts";
|
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||||
import { ensureAuthenticated } from "../../utils/authRedirect";
|
import { ensureAuthenticated } from "../../utils/authRedirect";
|
||||||
|
import {
|
||||||
|
getProjectLikes,
|
||||||
|
LIKE_TARGET,
|
||||||
|
toggleProjectLike,
|
||||||
|
} from "../../utils/likes";
|
||||||
import { responsiveHeight } from "react-native-responsive-dimensions";
|
import { responsiveHeight } from "react-native-responsive-dimensions";
|
||||||
|
|
||||||
const formatDuration = (ms) => {
|
const formatDuration = (ms) => {
|
||||||
@@ -60,9 +65,9 @@ const GlobalAudioPlayer = () => {
|
|||||||
refreshArray: [projectId],
|
refreshArray: [projectId],
|
||||||
});
|
});
|
||||||
|
|
||||||
const likedByList = Array.isArray(projectData?.likedBy)
|
const likedByList = useMemo(() => {
|
||||||
? projectData.likedBy
|
return getProjectLikes(projectData, LIKE_TARGET.SONG);
|
||||||
: [];
|
}, [projectData]);
|
||||||
|
|
||||||
const likedFromDoc = useMemo(() => {
|
const likedFromDoc = useMemo(() => {
|
||||||
if (!projectId || !currentUID) return false;
|
if (!projectId || !currentUID) return false;
|
||||||
@@ -100,12 +105,12 @@ const GlobalAudioPlayer = () => {
|
|||||||
const next = !effectiveIsLiked;
|
const next = !effectiveIsLiked;
|
||||||
setPendingLike(next);
|
setPendingLike(next);
|
||||||
try {
|
try {
|
||||||
await projectsRef.doc(projectId).set(
|
await toggleProjectLike({
|
||||||
{
|
projectId,
|
||||||
likedBy: next ? arrayUnion(currentUID) : arrayRemove(currentUID),
|
target: LIKE_TARGET.SONG,
|
||||||
},
|
currentUID,
|
||||||
{ merge: true },
|
next,
|
||||||
);
|
});
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
setPendingLike(null);
|
setPendingLike(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useGlobal } from "reactn";
|
import { useGlobal } from "reactn";
|
||||||
|
import { useMemo } from "react";
|
||||||
import firebase from "../config/firebase";
|
import firebase from "../config/firebase";
|
||||||
import { getLikeFieldPath, LIKE_TARGET } from "../utils/likes";
|
import { getLikeFieldPath, LIKE_TARGET } from "../utils/likes";
|
||||||
import useDataFromRef from "./useDataFromRef";
|
import useDataFromRef from "./useDataFromRef";
|
||||||
@@ -6,14 +7,36 @@ import useDataFromRef from "./useDataFromRef";
|
|||||||
export default function useUserLikedProjects() {
|
export default function useUserLikedProjects() {
|
||||||
const [currentUID] = useGlobal("currentUID");
|
const [currentUID] = useGlobal("currentUID");
|
||||||
|
|
||||||
const { data, loading } = useDataFromRef({
|
const likeField = getLikeFieldPath(LIKE_TARGET.SONG);
|
||||||
|
|
||||||
|
const { data: songLikes = [], loading: songLikesLoading } = useDataFromRef({
|
||||||
ref:
|
ref:
|
||||||
currentUID
|
currentUID
|
||||||
? firebase
|
? firebase
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection("projects")
|
.collection("projects")
|
||||||
.where(
|
.where(
|
||||||
getLikeFieldPath(LIKE_TARGET.SONG),
|
likeField,
|
||||||
|
"array-contains",
|
||||||
|
currentUID
|
||||||
|
)
|
||||||
|
.orderBy("updatedAt", "desc")
|
||||||
|
: null,
|
||||||
|
simpleRef: false,
|
||||||
|
listener: true,
|
||||||
|
condition: !!currentUID,
|
||||||
|
refreshArray: [currentUID],
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data: legacyLikes = [], loading: legacyLikesLoading } =
|
||||||
|
useDataFromRef({
|
||||||
|
ref:
|
||||||
|
currentUID
|
||||||
|
? firebase
|
||||||
|
.firestore()
|
||||||
|
.collection("projects")
|
||||||
|
.where(
|
||||||
|
"likedBy",
|
||||||
"array-contains",
|
"array-contains",
|
||||||
currentUID
|
currentUID
|
||||||
)
|
)
|
||||||
@@ -24,5 +47,43 @@ export default function useUserLikedProjects() {
|
|||||||
refreshArray: [currentUID],
|
refreshArray: [currentUID],
|
||||||
});
|
});
|
||||||
|
|
||||||
return { projects: Array.isArray(data) ? data : [], loading };
|
const projects = useMemo(() => {
|
||||||
|
const byId = new Map();
|
||||||
|
|
||||||
|
const pushList = (list) => {
|
||||||
|
if (!Array.isArray(list)) return;
|
||||||
|
list.forEach((project) => {
|
||||||
|
if (project?.id && !byId.has(project.id)) {
|
||||||
|
byId.set(project.id, project);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
pushList(songLikes);
|
||||||
|
pushList(legacyLikes);
|
||||||
|
|
||||||
|
const withUpdatedAt = Array.from(byId.values());
|
||||||
|
const toTimestamp = (value) => {
|
||||||
|
if (!value) return 0;
|
||||||
|
if (typeof value.toDate === "function") {
|
||||||
|
return value.toDate().getTime();
|
||||||
|
}
|
||||||
|
if (typeof value.seconds === "number") {
|
||||||
|
return value.seconds * 1000;
|
||||||
|
}
|
||||||
|
if (typeof value === "number") {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
return withUpdatedAt.sort(
|
||||||
|
(a, b) => toTimestamp(b?.updatedAt) - toTimestamp(a?.updatedAt)
|
||||||
|
);
|
||||||
|
}, [legacyLikes, songLikes]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
projects,
|
||||||
|
loading: !!(songLikesLoading || legacyLikesLoading),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import PublishYoutube from "../screens/Publishing/PublishYoutube";
|
|||||||
import PrivacyPolicy from "../screens/PrivacyPolicy";
|
import PrivacyPolicy from "../screens/PrivacyPolicy";
|
||||||
import Payments from "../screens/Payments";
|
import Payments from "../screens/Payments";
|
||||||
import DownloadPrices from "../screens/Production/DownloadPrices";
|
import DownloadPrices from "../screens/Production/DownloadPrices";
|
||||||
import DownloadSongs from "../screens/Production/DownloadSongs";
|
import PlaybackDownload from "../screens/Production/PlaybackDownload";
|
||||||
import PlaybackExample from "../screens/Production/PlaybackExample";
|
import PlaybackExample from "../screens/Production/PlaybackExample";
|
||||||
import Production from "../screens/Production/Production";
|
import Production from "../screens/Production/Production";
|
||||||
import ProductionOnboarding from "../screens/Production/ProductionOnboarding";
|
import ProductionOnboarding from "../screens/Production/ProductionOnboarding";
|
||||||
@@ -62,6 +62,7 @@ import { ChooseCoverType } from "../screens/cover/ChooseCoverType";
|
|||||||
import PhotoCover from "../screens/cover/PhotoCover";
|
import PhotoCover from "../screens/cover/PhotoCover";
|
||||||
import PouchReady from "../screens/cover/PouchReady";
|
import PouchReady from "../screens/cover/PouchReady";
|
||||||
import ValidateCover from "../screens/cover/ValidateCover";
|
import ValidateCover from "../screens/cover/ValidateCover";
|
||||||
|
import SongDownload from "../screens/cover/SongDownload";
|
||||||
import { Palette } from "../styles";
|
import { Palette } from "../styles";
|
||||||
import { BottomTabScreen } from "./BottomTab";
|
import { BottomTabScreen } from "./BottomTab";
|
||||||
import { Routes } from "./Routes";
|
import { Routes } from "./Routes";
|
||||||
@@ -179,6 +180,10 @@ const baseScreens = [
|
|||||||
name: Routes.ValidateCover,
|
name: Routes.ValidateCover,
|
||||||
component: ValidateCover,
|
component: ValidateCover,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: Routes.SongDownload,
|
||||||
|
component: SongDownload,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: Routes.ProductionOnboarding,
|
name: Routes.ProductionOnboarding,
|
||||||
component: ProductionOnboarding,
|
component: ProductionOnboarding,
|
||||||
@@ -188,8 +193,8 @@ const baseScreens = [
|
|||||||
component: Production,
|
component: Production,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: Routes.DownloadSongs,
|
name: Routes.PlaybackDownload,
|
||||||
component: DownloadSongs,
|
component: PlaybackDownload,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: Routes.DownloadPrices,
|
name: Routes.DownloadPrices,
|
||||||
|
|||||||
@@ -41,11 +41,12 @@ export const Routes = {
|
|||||||
PouchReady: "PouchReady",
|
PouchReady: "PouchReady",
|
||||||
PhotoCover: "PhotoCover",
|
PhotoCover: "PhotoCover",
|
||||||
ValidateCover: "ValidateCover",
|
ValidateCover: "ValidateCover",
|
||||||
|
SongDownload: "SongDownload",
|
||||||
FinishCompose: "FinishCompose",
|
FinishCompose: "FinishCompose",
|
||||||
|
|
||||||
ProductionOnboarding: "ProductionOnboarding",
|
ProductionOnboarding: "ProductionOnboarding",
|
||||||
Production: "Production",
|
Production: "Production",
|
||||||
DownloadSongs: "DownloadSongs",
|
PlaybackDownload: "PlaybackDownload",
|
||||||
DownloadPrices: "DownloadPrices",
|
DownloadPrices: "DownloadPrices",
|
||||||
SongDownloaded: "SongDownloaded",
|
SongDownloaded: "SongDownloaded",
|
||||||
StreamSong: "StreamSong",
|
StreamSong: "StreamSong",
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ const HIDDEN_ROUTE_NAMES = new Set([
|
|||||||
Routes.PouchReady,
|
Routes.PouchReady,
|
||||||
Routes.PhotoCover,
|
Routes.PhotoCover,
|
||||||
Routes.ValidateCover,
|
Routes.ValidateCover,
|
||||||
|
Routes.SongDownload,
|
||||||
Routes.FinishCompose,
|
Routes.FinishCompose,
|
||||||
Routes.GeneratingSong,
|
Routes.GeneratingSong,
|
||||||
Routes.ProductionOnboarding,
|
Routes.ProductionOnboarding,
|
||||||
Routes.Production,
|
Routes.Production,
|
||||||
Routes.DownloadSongs,
|
Routes.PlaybackDownload,
|
||||||
Routes.DownloadPrices,
|
Routes.DownloadPrices,
|
||||||
Routes.SongDownloaded,
|
Routes.SongDownloaded,
|
||||||
Routes.StreamSong,
|
Routes.StreamSong,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useDataFromRef } from "react-native-minuit/src/hooks";
|
|||||||
import useMinuit from "react-native-minuit/src/hooks/useMinuit";
|
import useMinuit from "react-native-minuit/src/hooks/useMinuit";
|
||||||
import { createContext, useContext, useGlobal } from "reactn";
|
import { createContext, useContext, useGlobal } from "reactn";
|
||||||
|
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { checkIfEmailIsValid } from "../actions/signupActions";
|
import { checkIfEmailIsValid } from "../actions/signupActions";
|
||||||
import { showPremiumRequiredAlert } from "../components/Alert";
|
import { showPremiumRequiredAlert } from "../components/Alert";
|
||||||
import firebase, {
|
import firebase, {
|
||||||
@@ -18,9 +18,15 @@ import { getUserPreferredArtistName } from "../utils/artistName";
|
|||||||
import { getLikeFieldPath, LIKE_TARGET } from "../utils/likes";
|
import { getLikeFieldPath, LIKE_TARGET } from "../utils/likes";
|
||||||
import { ensureAuthenticated } from "../utils/authRedirect";
|
import { ensureAuthenticated } from "../utils/authRedirect";
|
||||||
import { isWeb } from "../hooks/useLayoutType";
|
import { isWeb } from "../hooks/useLayoutType";
|
||||||
|
import useUserLikedProjects from "../hooks/useUserLikedProjects";
|
||||||
|
|
||||||
const SONG_LIKES_FIELD = getLikeFieldPath(LIKE_TARGET.SONG);
|
|
||||||
const PLAYBACK_LIKES_FIELD = getLikeFieldPath(LIKE_TARGET.PLAYBACK);
|
const PLAYBACK_LIKES_FIELD = getLikeFieldPath(LIKE_TARGET.PLAYBACK);
|
||||||
|
const ACTIVE_SUBSCRIPTION_STATUSES = new Set([
|
||||||
|
"trialing",
|
||||||
|
"active",
|
||||||
|
"past_due",
|
||||||
|
"unpaid",
|
||||||
|
]);
|
||||||
|
|
||||||
export const UserDataContext = createContext();
|
export const UserDataContext = createContext();
|
||||||
|
|
||||||
@@ -61,21 +67,11 @@ export default ({ children }) => {
|
|||||||
const userPlaybacks = Array.isArray(userProjects)
|
const userPlaybacks = Array.isArray(userProjects)
|
||||||
? userProjects.filter((project) => project.playbackUrl)
|
? userProjects.filter((project) => project.playbackUrl)
|
||||||
: [];
|
: [];
|
||||||
// Subscribe to user's liked projects
|
// Subscribe to user's liked projects (both new and legacy storage)
|
||||||
const {
|
const {
|
||||||
data: userLikedProjects = [],
|
projects: userLikedProjects = [],
|
||||||
loading: userLikedProjectsLoading = true,
|
loading: userLikedProjectsLoading = true,
|
||||||
} = useDataFromRef({
|
} = useUserLikedProjects();
|
||||||
ref: currentUID
|
|
||||||
? projectsRef
|
|
||||||
.where(SONG_LIKES_FIELD, "array-contains", currentUID)
|
|
||||||
.orderBy("updatedAt", "desc")
|
|
||||||
: null,
|
|
||||||
simpleRef: false,
|
|
||||||
listener: true,
|
|
||||||
condition: !!currentUID,
|
|
||||||
refreshArray: [currentUID],
|
|
||||||
});
|
|
||||||
const {
|
const {
|
||||||
data: userLikedPlaybacks = [],
|
data: userLikedPlaybacks = [],
|
||||||
loading: userLikedPlaybacksLoading = true,
|
loading: userLikedPlaybacksLoading = true,
|
||||||
@@ -421,6 +417,49 @@ export default ({ children }) => {
|
|||||||
simpleRef: true,
|
simpleRef: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hasActiveSubscription = useMemo(() => {
|
||||||
|
const pickStatus = (value) => {
|
||||||
|
if (typeof value !== "string") return null;
|
||||||
|
const trimmed = value.trim();
|
||||||
|
return trimmed ? trimmed.toLowerCase() : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusCandidates = [
|
||||||
|
pickStatus(currentUserDoc?.stripeSubscriptionStatus),
|
||||||
|
pickStatus(currentUserDoc?.stripeSubscription?.status),
|
||||||
|
pickStatus(currentUserDoc?.stripeSubscription?.stripeSubscriptionStatus),
|
||||||
|
pickStatus(currentUserDoc?.stripeSubscription?.metadata?.status),
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
if (
|
||||||
|
statusCandidates.some((status) =>
|
||||||
|
ACTIVE_SUBSCRIPTION_STATUSES.has(status),
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const premiumUntil = currentUserDoc?.premiumUntil;
|
||||||
|
if (premiumUntil) {
|
||||||
|
const asDate =
|
||||||
|
premiumUntil?.toDate?.() ||
|
||||||
|
(premiumUntil?.seconds ? new Date(premiumUntil.seconds * 1000) : null);
|
||||||
|
if (asDate && asDate > new Date()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentUserDoc?.premium?.active) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasPremiumLevel =
|
||||||
|
typeof currentUserDoc?.premiumLevel === "string" &&
|
||||||
|
currentUserDoc.premiumLevel.trim().length > 0;
|
||||||
|
|
||||||
|
return hasPremiumLevel;
|
||||||
|
}, [currentUserDoc]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UserDataContext.Provider
|
<UserDataContext.Provider
|
||||||
value={{
|
value={{
|
||||||
@@ -459,6 +498,7 @@ export default ({ children }) => {
|
|||||||
createNewProject,
|
createNewProject,
|
||||||
|
|
||||||
videos,
|
videos,
|
||||||
|
hasActiveSubscription,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -111,45 +111,11 @@ const Home = ({ navigation, route }) => {
|
|||||||
currentUID,
|
currentUID,
|
||||||
createNewProject,
|
createNewProject,
|
||||||
videos,
|
videos,
|
||||||
|
hasActiveSubscription,
|
||||||
} = useUser();
|
} = useUser();
|
||||||
const { setTooltip } = useMinuit();
|
const { setTooltip } = useMinuit();
|
||||||
const [videoUrl, setVideoUrl] = useState(null);
|
const [videoUrl, setVideoUrl] = useState(null);
|
||||||
|
|
||||||
const hasActiveSubscription = useMemo(() => {
|
|
||||||
if (!currentUserData) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const pickStatus = (value) => {
|
|
||||||
if (typeof value !== "string") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const trimmed = value.trim();
|
|
||||||
return trimmed ? trimmed.toLowerCase() : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const statusCandidates = [
|
|
||||||
pickStatus(currentUserData?.stripeSubscriptionStatus),
|
|
||||||
pickStatus(currentUserData?.stripeSubscription?.status),
|
|
||||||
pickStatus(currentUserData?.stripeSubscription?.stripeSubscriptionStatus),
|
|
||||||
pickStatus(currentUserData?.stripeSubscription?.metadata?.status),
|
|
||||||
].filter(Boolean);
|
|
||||||
|
|
||||||
if (
|
|
||||||
statusCandidates.some((status) =>
|
|
||||||
ACTIVE_SUBSCRIPTION_STATUSES.has(status),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasPremiumLevel =
|
|
||||||
typeof currentUserData?.premiumLevel === "string" &&
|
|
||||||
currentUserData.premiumLevel.trim().length > 0;
|
|
||||||
|
|
||||||
return hasPremiumLevel;
|
|
||||||
}, [currentUserData]);
|
|
||||||
|
|
||||||
if (!currentUID) {
|
if (!currentUID) {
|
||||||
return <LandingPage />;
|
return <LandingPage />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { navigate } from "../../navigation/NavigationService";
|
|||||||
import { useUser } from "../../providers/UserDataProvider";
|
import { useUser } from "../../providers/UserDataProvider";
|
||||||
import { Palette, Style, gutters } from "../../styles";
|
import { Palette, Style, gutters } from "../../styles";
|
||||||
import { FONT_FAMILY } from "../../styles/Fonts";
|
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||||
|
import { getProjectLikes, LIKE_TARGET } from "../../utils/likes";
|
||||||
import MusicCard from "./components/MusicCard";
|
import MusicCard from "./components/MusicCard";
|
||||||
|
|
||||||
export default function AllMyList() {
|
export default function AllMyList() {
|
||||||
@@ -28,6 +29,7 @@ export default function AllMyList() {
|
|||||||
userLikedProjectsLoading,
|
userLikedProjectsLoading,
|
||||||
userPlaybacks,
|
userPlaybacks,
|
||||||
userLikedPlaybacks,
|
userLikedPlaybacks,
|
||||||
|
userLikedPlaybacksLoading,
|
||||||
} = useUser();
|
} = useUser();
|
||||||
const navigateToMusicDetails = useNavigateToMusicDetails();
|
const navigateToMusicDetails = useNavigateToMusicDetails();
|
||||||
|
|
||||||
@@ -55,9 +57,18 @@ export default function AllMyList() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const sanitizedItems = Array.isArray(items) ? items : [];
|
const sanitizedItems = Array.isArray(items) ? items : [];
|
||||||
const itemsLoading = liked
|
const itemsLoading = useMemo(() => {
|
||||||
? userLikedProjectsLoading
|
if (scope === "playback") {
|
||||||
: userProjectsLoading;
|
return liked ? userLikedPlaybacksLoading : userProjectsLoading;
|
||||||
|
}
|
||||||
|
return liked ? userLikedProjectsLoading : userProjectsLoading;
|
||||||
|
}, [
|
||||||
|
liked,
|
||||||
|
scope,
|
||||||
|
userLikedPlaybacksLoading,
|
||||||
|
userLikedProjectsLoading,
|
||||||
|
userProjectsLoading,
|
||||||
|
]);
|
||||||
|
|
||||||
const emptyStateContent = useMemo(() => {
|
const emptyStateContent = useMemo(() => {
|
||||||
const variant = liked ? "liked" : "default";
|
const variant = liked ? "liked" : "default";
|
||||||
@@ -172,14 +183,18 @@ export default function AllMyList() {
|
|||||||
<Text style={placeholderDescriptionStyle}>{loadingMessage}</Text>
|
<Text style={placeholderDescriptionStyle}>{loadingMessage}</Text>
|
||||||
</View>
|
</View>
|
||||||
) : sanitizedItems.length > 0 ? (
|
) : sanitizedItems.length > 0 ? (
|
||||||
sanitizedItems.map((item) => (
|
sanitizedItems.map((item) => {
|
||||||
|
const likeTarget =
|
||||||
|
scope === "playback" ? LIKE_TARGET.PLAYBACK : LIKE_TARGET.SONG;
|
||||||
|
return (
|
||||||
<MusicCard
|
<MusicCard
|
||||||
key={item.id}
|
key={item.id}
|
||||||
title={item?.title || "Sans titre"}
|
title={item?.title || "Sans titre"}
|
||||||
imageUri={item?.coverUrl || null}
|
imageUri={item?.coverUrl || null}
|
||||||
subtitle={item?.userName}
|
subtitle={item?.userName}
|
||||||
projectId={item?.id}
|
projectId={item?.id}
|
||||||
likedBy={item?.likedBy || []}
|
likedBy={getProjectLikes(item, likeTarget)}
|
||||||
|
likeTarget={likeTarget}
|
||||||
onPress={() => onPressItem(item)}
|
onPress={() => onPressItem(item)}
|
||||||
onPressMore={(posTop) => {
|
onPressMore={(posTop) => {
|
||||||
setSelectedProjectId(item.id);
|
setSelectedProjectId(item.id);
|
||||||
@@ -190,7 +205,8 @@ export default function AllMyList() {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))
|
);
|
||||||
|
})
|
||||||
) : (
|
) : (
|
||||||
<View style={[Style.containerCenter, placeholderBaseStyle]}>
|
<View style={[Style.containerCenter, placeholderBaseStyle]}>
|
||||||
<Text style={placeholderTitleStyle}>
|
<Text style={placeholderTitleStyle}>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { useUser } from "../../providers/UserDataProvider";
|
|||||||
import { gutters, Palette, Style } from "../../styles";
|
import { gutters, Palette, Style } from "../../styles";
|
||||||
import { FONT_FAMILY } from "../../styles/Fonts";
|
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||||
import { size } from "../../styles/Style";
|
import { size } from "../../styles/Style";
|
||||||
|
import { getProjectLikes, LIKE_TARGET } from "../../utils/likes";
|
||||||
import MusicCard from "./components/MusicCard";
|
import MusicCard from "./components/MusicCard";
|
||||||
|
|
||||||
const AllMyPlaylist = ({ route }) => {
|
const AllMyPlaylist = ({ route }) => {
|
||||||
@@ -277,7 +278,8 @@ const AllMyPlaylist = ({ route }) => {
|
|||||||
subtitle={p?.userName}
|
subtitle={p?.userName}
|
||||||
imageUri={p?.coverUrl || null}
|
imageUri={p?.coverUrl || null}
|
||||||
projectId={p?.id}
|
projectId={p?.id}
|
||||||
likedBy={p?.likedBy || []}
|
likedBy={getProjectLikes(p, LIKE_TARGET.SONG)}
|
||||||
|
likeTarget={LIKE_TARGET.SONG}
|
||||||
onPress={() => handlePlayFromPlaylist(p)}
|
onPress={() => handlePlayFromPlaylist(p)}
|
||||||
onPressMore={(posTop) => {
|
onPressMore={(posTop) => {
|
||||||
setSelectedProjectId(p.id);
|
setSelectedProjectId(p.id);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ const Library = () => {
|
|||||||
experimentalBlurMethod="dimezisBlurView"
|
experimentalBlurMethod="dimezisBlurView"
|
||||||
style={{ borderRadius: 12, padding: 12, overflow: "hidden" }}
|
style={{ borderRadius: 12, padding: 12, overflow: "hidden" }}
|
||||||
>
|
>
|
||||||
{hasMyMusic && <MyMusic />}
|
<MyMusic />
|
||||||
</BlurView>
|
</BlurView>
|
||||||
{hasBackTracks && <BackTracks />}
|
{hasBackTracks && <BackTracks />}
|
||||||
{hasLikedMusic && <LikedMusic />}
|
{hasLikedMusic && <LikedMusic />}
|
||||||
|
|||||||
@@ -25,13 +25,7 @@ import { useGlobal } from "reactn";
|
|||||||
import { background, icons } from "../../assets";
|
import { background, icons } from "../../assets";
|
||||||
import PressableScale from "../../components/PressableScale";
|
import PressableScale from "../../components/PressableScale";
|
||||||
import Slider from "../../components/Slider";
|
import Slider from "../../components/Slider";
|
||||||
import {
|
import { increment, projectsRef, usersRef } from "../../config/firebase";
|
||||||
arrayRemove,
|
|
||||||
arrayUnion,
|
|
||||||
increment,
|
|
||||||
projectsRef,
|
|
||||||
usersRef,
|
|
||||||
} from "../../config/firebase";
|
|
||||||
import useDataFromRef from "../../hooks/useDataFromRef";
|
import useDataFromRef from "../../hooks/useDataFromRef";
|
||||||
import usePlayer from "../../hooks/usePlayer";
|
import usePlayer from "../../hooks/usePlayer";
|
||||||
import useTrackController from "../../hooks/useTrackController";
|
import useTrackController from "../../hooks/useTrackController";
|
||||||
@@ -45,6 +39,11 @@ import {
|
|||||||
createMusicSharePayload,
|
createMusicSharePayload,
|
||||||
openShareSheet,
|
openShareSheet,
|
||||||
} from "../../utils/shareSheet";
|
} from "../../utils/shareSheet";
|
||||||
|
import {
|
||||||
|
getProjectLikes,
|
||||||
|
LIKE_TARGET,
|
||||||
|
toggleProjectLike,
|
||||||
|
} from "../../utils/likes";
|
||||||
import {
|
import {
|
||||||
formatStructureLabel,
|
formatStructureLabel,
|
||||||
getPromptLabelForStructure,
|
getPromptLabelForStructure,
|
||||||
@@ -86,13 +85,10 @@ const MusicDetails = ({ route }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (project && currentUID) {
|
const likes = getProjectLikes(project, LIKE_TARGET.SONG);
|
||||||
const liked = Array.isArray(project?.likedBy)
|
const liked = currentUID ? likes.includes(currentUID) : false;
|
||||||
? project.likedBy.includes(currentUID)
|
|
||||||
: false;
|
|
||||||
setFav(liked);
|
setFav(liked);
|
||||||
}
|
}, [currentUID, project]);
|
||||||
}, [project?.likedBy, currentUID]);
|
|
||||||
|
|
||||||
const title = project?.title || "Sans titre";
|
const title = project?.title || "Sans titre";
|
||||||
const artist = useMemo(() => {
|
const artist = useMemo(() => {
|
||||||
@@ -862,10 +858,11 @@ const MusicDetails = ({ route }) => {
|
|||||||
const next = !fav;
|
const next = !fav;
|
||||||
setFav(next);
|
setFav(next);
|
||||||
try {
|
try {
|
||||||
await projectsRef.doc(projectId).update({
|
await toggleProjectLike({
|
||||||
likedBy: next
|
projectId,
|
||||||
? arrayUnion(currentUID)
|
target: LIKE_TARGET.SONG,
|
||||||
: arrayRemove(currentUID),
|
currentUID,
|
||||||
|
next,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setFav(!next);
|
setFav(!next);
|
||||||
|
|||||||
@@ -27,13 +27,7 @@ import { useGlobal } from "reactn";
|
|||||||
import { background, icons } from "../../assets";
|
import { background, icons } from "../../assets";
|
||||||
import PressableScale from "../../components/PressableScale";
|
import PressableScale from "../../components/PressableScale";
|
||||||
import Slider from "../../components/Slider";
|
import Slider from "../../components/Slider";
|
||||||
import {
|
import { increment, projectsRef, usersRef } from "../../config/firebase";
|
||||||
arrayRemove,
|
|
||||||
arrayUnion,
|
|
||||||
increment,
|
|
||||||
projectsRef,
|
|
||||||
usersRef,
|
|
||||||
} from "../../config/firebase";
|
|
||||||
import { ensureAuthenticated } from "../../utils/authRedirect";
|
import { ensureAuthenticated } from "../../utils/authRedirect";
|
||||||
import useDataFromRef from "../../hooks/useDataFromRef";
|
import useDataFromRef from "../../hooks/useDataFromRef";
|
||||||
import useTrackController from "../../hooks/useTrackController";
|
import useTrackController from "../../hooks/useTrackController";
|
||||||
@@ -50,6 +44,11 @@ import {
|
|||||||
normalizeStructureType,
|
normalizeStructureType,
|
||||||
segmentRequiresLyrics,
|
segmentRequiresLyrics,
|
||||||
} from "../../utils/songStructure";
|
} from "../../utils/songStructure";
|
||||||
|
import {
|
||||||
|
getProjectLikes,
|
||||||
|
LIKE_TARGET,
|
||||||
|
toggleProjectLike,
|
||||||
|
} from "../../utils/likes";
|
||||||
import {
|
import {
|
||||||
createMusicSharePayload,
|
createMusicSharePayload,
|
||||||
openShareSheet,
|
openShareSheet,
|
||||||
@@ -117,13 +116,10 @@ const MusicDetails = ({ route }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (project && currentUID) {
|
const likes = getProjectLikes(project, LIKE_TARGET.SONG);
|
||||||
const liked = Array.isArray(project?.likedBy)
|
const liked = currentUID ? likes.includes(currentUID) : false;
|
||||||
? project.likedBy.includes(currentUID)
|
|
||||||
: false;
|
|
||||||
setFav(liked);
|
setFav(liked);
|
||||||
}
|
}, [currentUID, project]);
|
||||||
}, [project?.likedBy, currentUID]);
|
|
||||||
|
|
||||||
const title = project?.title || "Sans titre";
|
const title = project?.title || "Sans titre";
|
||||||
const artist = useMemo(() => {
|
const artist = useMemo(() => {
|
||||||
@@ -1074,10 +1070,11 @@ const MusicDetails = ({ route }) => {
|
|||||||
const next = !fav;
|
const next = !fav;
|
||||||
setFav(next);
|
setFav(next);
|
||||||
try {
|
try {
|
||||||
await projectsRef.doc(projectId).update({
|
await toggleProjectLike({
|
||||||
likedBy: next
|
projectId,
|
||||||
? arrayUnion(currentUID)
|
target: LIKE_TARGET.SONG,
|
||||||
: arrayRemove(currentUID),
|
currentUID,
|
||||||
|
next,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setFav(!next);
|
setFav(!next);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import usePlayer from "../../hooks/usePlayer";
|
|||||||
import Page from "../../layouts/Page";
|
import Page from "../../layouts/Page";
|
||||||
import { goBack } from "../../navigation/NavigationService";
|
import { goBack } from "../../navigation/NavigationService";
|
||||||
import { gutters } from "../../styles";
|
import { gutters } from "../../styles";
|
||||||
|
import { getProjectLikes, LIKE_TARGET } from "../../utils/likes";
|
||||||
import MusicCard from "./components/MusicCard";
|
import MusicCard from "./components/MusicCard";
|
||||||
|
|
||||||
const PlaylistDetails = () => {
|
const PlaylistDetails = () => {
|
||||||
@@ -156,7 +157,8 @@ const PlaylistDetails = () => {
|
|||||||
subtitle={p?.userName}
|
subtitle={p?.userName}
|
||||||
imageUri={p?.coverUrl || null}
|
imageUri={p?.coverUrl || null}
|
||||||
projectId={p?.id}
|
projectId={p?.id}
|
||||||
likedBy={p?.likedBy || []}
|
likedBy={getProjectLikes(p, LIKE_TARGET.SONG)}
|
||||||
|
likeTarget={LIKE_TARGET.SONG}
|
||||||
onPress={() => handlePlayFromPlaylist(p)}
|
onPress={() => handlePlayFromPlaylist(p)}
|
||||||
onPressMore={(posTop) => {
|
onPressMore={(posTop) => {
|
||||||
setSelectedProjectId(p.id);
|
setSelectedProjectId(p.id);
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { View } from "react-native";
|
import { Text, View } from "react-native";
|
||||||
import { SheetManager } from "react-native-actions-sheet";
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
import { useGlobal } from "reactn";
|
import { useGlobal } from "reactn";
|
||||||
|
import GradientButton from "../../../components/GradientButton";
|
||||||
import MoreMenu from "../../../components/MoreMenu";
|
import MoreMenu from "../../../components/MoreMenu";
|
||||||
import { projectsRef } from "../../../config/firebase";
|
import { projectsRef } from "../../../config/firebase";
|
||||||
import useNavigateToMusicDetails from "../../../hooks/useNavigateToMusicDetails";
|
import useNavigateToMusicDetails from "../../../hooks/useNavigateToMusicDetails";
|
||||||
import { Routes } from "../../../navigation";
|
import { Routes } from "../../../navigation";
|
||||||
import { navigate } from "../../../navigation/NavigationService";
|
import { navigate } from "../../../navigation/NavigationService";
|
||||||
import { useUser } from "../../../providers/UserDataProvider";
|
import { useUser } from "../../../providers/UserDataProvider";
|
||||||
|
import { Palette } from "../../../styles";
|
||||||
|
import { FONT_FAMILY } from "../../../styles/Fonts";
|
||||||
|
import { getProjectLikes, LIKE_TARGET } from "../../../utils/likes";
|
||||||
import CardContainer from "./CardContainer";
|
import CardContainer from "./CardContainer";
|
||||||
import MusicCard from "./MusicCard";
|
import MusicCard from "./MusicCard";
|
||||||
const MyMusic = () => {
|
const MyMusic = () => {
|
||||||
@@ -16,6 +20,7 @@ const MyMusic = () => {
|
|||||||
const [showMenu, setShowMenu] = useState(false);
|
const [showMenu, setShowMenu] = useState(false);
|
||||||
const [selectedProjectId, setSelectedProjectId] = useState(null);
|
const [selectedProjectId, setSelectedProjectId] = useState(null);
|
||||||
const projects = Array.isArray(userProjects) ? userProjects.slice(0, 3) : [];
|
const projects = Array.isArray(userProjects) ? userProjects.slice(0, 3) : [];
|
||||||
|
const hasProjects = projects.length > 0;
|
||||||
|
|
||||||
const [, setTooltip] = useGlobal("_tooltip");
|
const [, setTooltip] = useGlobal("_tooltip");
|
||||||
const navigateToMusicDetails = useNavigateToMusicDetails();
|
const navigateToMusicDetails = useNavigateToMusicDetails();
|
||||||
@@ -32,6 +37,7 @@ const MyMusic = () => {
|
|||||||
}
|
}
|
||||||
onPressPlus={() => navigate(Routes.WritingLyrics)}
|
onPressPlus={() => navigate(Routes.WritingLyrics)}
|
||||||
>
|
>
|
||||||
|
{hasProjects ? (
|
||||||
<View style={{ gap: 10 }}>
|
<View style={{ gap: 10 }}>
|
||||||
{Array.isArray(projects) &&
|
{Array.isArray(projects) &&
|
||||||
projects.map((p) => (
|
projects.map((p) => (
|
||||||
@@ -41,7 +47,8 @@ const MyMusic = () => {
|
|||||||
subtitle={p?.userName}
|
subtitle={p?.userName}
|
||||||
imageUri={p?.coverUrl || null}
|
imageUri={p?.coverUrl || null}
|
||||||
projectId={p?.id}
|
projectId={p?.id}
|
||||||
likedBy={p?.likedBy || []}
|
likedBy={getProjectLikes(p, LIKE_TARGET.SONG)}
|
||||||
|
likeTarget={LIKE_TARGET.SONG}
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
navigateToMusicDetails({
|
navigateToMusicDetails({
|
||||||
projectId: p.id,
|
projectId: p.id,
|
||||||
@@ -53,7 +60,8 @@ const MyMusic = () => {
|
|||||||
setSelectedProjectId(p.id);
|
setSelectedProjectId(p.id);
|
||||||
setMenuPosition(posTop);
|
setMenuPosition(posTop);
|
||||||
setShowMenu(
|
setShowMenu(
|
||||||
(prev) => !prev || posTop?.top !== (menuPosition?.top ?? null)
|
(prev) =>
|
||||||
|
!prev || posTop?.top !== (menuPosition?.top ?? null)
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -95,6 +103,25 @@ const MyMusic = () => {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
) : (
|
||||||
|
<View style={{ flexDirection: "column", gap: 10 }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
textAlign: "center",
|
||||||
|
fontFamily: FONT_FAMILY.InterRegular,
|
||||||
|
color: Palette.white,
|
||||||
|
fontSize: 16,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Aucune musique pour l'instant
|
||||||
|
</Text>
|
||||||
|
<GradientButton
|
||||||
|
containerStyle={{ padding: 2 }}
|
||||||
|
onPress={() => navigate(Routes.WritingLyrics)}
|
||||||
|
title=" Créer une musique"
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</CardContainer>
|
</CardContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import React from "react";
|
|||||||
import { Image, Platform, Pressable, Text, View } from "react-native";
|
import { Image, Platform, Pressable, Text, View } from "react-native";
|
||||||
import { SheetManager } from "react-native-actions-sheet";
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
import { icons } from "../../../assets";
|
import { icons } from "../../../assets";
|
||||||
|
import GradientButton from "../../../components/GradientButton";
|
||||||
import useLayoutType from "../../../hooks/useLayoutType";
|
import useLayoutType from "../../../hooks/useLayoutType";
|
||||||
import { Routes } from "../../../navigation";
|
import { Routes } from "../../../navigation";
|
||||||
import { navigate } from "../../../navigation/NavigationService";
|
import { navigate } from "../../../navigation/NavigationService";
|
||||||
@@ -17,6 +18,7 @@ const MyPlaylist = () => {
|
|||||||
? userPlaylists.slice(0, 2)
|
? userPlaylists.slice(0, 2)
|
||||||
: [];
|
: [];
|
||||||
const { isWeb } = useLayoutType();
|
const { isWeb } = useLayoutType();
|
||||||
|
const hasPlaylists = playlists.length > 0;
|
||||||
return (
|
return (
|
||||||
<CardContainer
|
<CardContainer
|
||||||
label="Mes Playlists"
|
label="Mes Playlists"
|
||||||
@@ -28,7 +30,8 @@ const MyPlaylist = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<View style={{ gap: 8 }}>
|
<View style={{ gap: 8 }}>
|
||||||
{playlists.map((item) => (
|
{hasPlaylists ? (
|
||||||
|
playlists.map((item) => (
|
||||||
<Pressable
|
<Pressable
|
||||||
key={item.id}
|
key={item.id}
|
||||||
style={{ borderRadius: 12, overflow: "hidden" }}
|
style={{ borderRadius: 12, overflow: "hidden" }}
|
||||||
@@ -75,7 +78,30 @@ const MyPlaylist = () => {
|
|||||||
/>
|
/>
|
||||||
</BlurView>
|
</BlurView>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
))}
|
))
|
||||||
|
) : (
|
||||||
|
<View style={{ flexDirection: "column", gap: 10 }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
textAlign: "center",
|
||||||
|
fontFamily: FONT_FAMILY.InterRegular,
|
||||||
|
color: Palette.white,
|
||||||
|
fontSize: 16,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Aucune playlist pour l'instant
|
||||||
|
</Text>
|
||||||
|
<GradientButton
|
||||||
|
containerStyle={{ padding: 2 }}
|
||||||
|
onPress={() =>
|
||||||
|
SheetManager.show("Playlist", {
|
||||||
|
payload: { startAtCreate: true },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
title=" Créer une playlist"
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</CardContainer>
|
</CardContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { navigate } from "../../../navigation/NavigationService";
|
|||||||
import { Palette, Style } from "../../../styles";
|
import { Palette, Style } from "../../../styles";
|
||||||
import { FONT_FAMILY } from "../../../styles/Fonts";
|
import { FONT_FAMILY } from "../../../styles/Fonts";
|
||||||
import { getArtistDisplayName } from "../../../utils/artistName";
|
import { getArtistDisplayName } from "../../../utils/artistName";
|
||||||
|
import { getProjectLikes, LIKE_TARGET } from "../../../utils/likes";
|
||||||
import CreateLyricsHeader from "../../Writing/components/CreateLyricsHeader";
|
import CreateLyricsHeader from "../../Writing/components/CreateLyricsHeader";
|
||||||
import MusicCard from "./MusicCard";
|
import MusicCard from "./MusicCard";
|
||||||
import { defaultAvatar } from "../../../data/data";
|
import { defaultAvatar } from "../../../data/data";
|
||||||
@@ -157,7 +158,8 @@ const SearchResultsList = ({
|
|||||||
subtitle={project?.userName}
|
subtitle={project?.userName}
|
||||||
imageUri={resolveCoverUri(project)}
|
imageUri={resolveCoverUri(project)}
|
||||||
projectId={project?.id}
|
projectId={project?.id}
|
||||||
likedBy={project?.likedBy || []}
|
likedBy={getProjectLikes(project, LIKE_TARGET.SONG)}
|
||||||
|
likeTarget={LIKE_TARGET.SONG}
|
||||||
onPress={() => handleMusicPress(project)}
|
onPress={() => handleMusicPress(project)}
|
||||||
onPressMore={(positionTop) => {
|
onPressMore={(positionTop) => {
|
||||||
setSelectedProjectId(project.id);
|
setSelectedProjectId(project.id);
|
||||||
@@ -203,7 +205,8 @@ const SearchResultsList = ({
|
|||||||
preferThumbnail: true,
|
preferThumbnail: true,
|
||||||
})}
|
})}
|
||||||
projectId={project?.id}
|
projectId={project?.id}
|
||||||
likedBy={project?.likedBy || []}
|
likedBy={getProjectLikes(project, LIKE_TARGET.PLAYBACK)}
|
||||||
|
likeTarget={LIKE_TARGET.PLAYBACK}
|
||||||
onPress={() => handlePlaybackPress(project)}
|
onPress={() => handlePlaybackPress(project)}
|
||||||
onPressMore={(positionTop) => {
|
onPressMore={(positionTop) => {
|
||||||
setSelectedProjectId(project.id);
|
setSelectedProjectId(project.id);
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ const RecordedPlayback = ({ route }) => {
|
|||||||
<GradientButton
|
<GradientButton
|
||||||
title="Je valide"
|
title="Je valide"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigate(Routes.DownloadSongs, {
|
navigate(Routes.PlaybackDownload, {
|
||||||
action: "playback",
|
action: "playback",
|
||||||
uri: videoUri,
|
uri: videoUri,
|
||||||
project,
|
project,
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ const RecordedPlayback = ({ route }) => {
|
|||||||
title="Je valide"
|
title="Je valide"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
shouldPreserveBlobRef.current = true;
|
shouldPreserveBlobRef.current = true;
|
||||||
navigate(Routes.DownloadSongs, {
|
navigate(Routes.PlaybackDownload, {
|
||||||
action: "playback",
|
action: "playback",
|
||||||
uri: videoUri || null, // peut être null sur web
|
uri: videoUri || null, // peut être null sur web
|
||||||
project,
|
project,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const VideoFinalize = () => {
|
|||||||
<GradientButton
|
<GradientButton
|
||||||
title="Valider"
|
title="Valider"
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
navigate(Routes.DownloadSongs, {
|
navigate(Routes.PlaybackDownload, {
|
||||||
action: "playback",
|
action: "playback",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+111
-128
@@ -1,17 +1,18 @@
|
|||||||
import { BlurView } from "expo-blur";
|
|
||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Image,
|
Image,
|
||||||
Platform,
|
Platform,
|
||||||
Pressable,
|
Pressable,
|
||||||
|
ScrollView,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import useMinuit from "react-native-minuit/src/hooks/useMinuit.js";
|
import useMinuit from "react-native-minuit/src/hooks/useMinuit.js";
|
||||||
import { responsiveHeight } from "react-native-responsive-dimensions";
|
|
||||||
import { background } from "../../assets";
|
import { background } from "../../assets";
|
||||||
import FullscreenIntroVideo from "../../components/FullscreenIntroVideo";
|
import FullscreenIntroVideo from "../../components/FullscreenIntroVideo";
|
||||||
|
import BorderGradientButton from "../../components/BorderGradientButton";
|
||||||
import MusicLandHeader from "../../components/MusicLandHeader";
|
import MusicLandHeader from "../../components/MusicLandHeader";
|
||||||
import firebase, {
|
import firebase, {
|
||||||
projectsRef,
|
projectsRef,
|
||||||
@@ -23,12 +24,16 @@ import useDataFromRef from "../../hooks/useDataFromRef";
|
|||||||
import Page from "../../layouts/Page";
|
import Page from "../../layouts/Page";
|
||||||
import { Routes } from "../../navigation";
|
import { Routes } from "../../navigation";
|
||||||
import { goBack, navigate } from "../../navigation/NavigationService";
|
import { goBack, navigate } from "../../navigation/NavigationService";
|
||||||
import { useUserData } from "../../providers/UserDataProvider";
|
import { useUserData, useUser } from "../../providers/UserDataProvider";
|
||||||
import { Palette } from "../../styles";
|
import { Palette } from "../../styles";
|
||||||
import { FONT_FAMILY } from "../../styles/Fonts";
|
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||||
import { size } from "../../styles/Style";
|
import { size } from "../../styles/Style";
|
||||||
import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader";
|
|
||||||
import { getBlobForUrl, releaseBlobUrl } from "../../utils/blobUrlCache";
|
import { getBlobForUrl, releaseBlobUrl } from "../../utils/blobUrlCache";
|
||||||
|
import ClubAdvantagesCard from "../Profile/components/ClubAdvantagesCard";
|
||||||
|
import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader";
|
||||||
|
import { Image as ExpoImage } from "expo-image";
|
||||||
|
import SubscriptionConfirmModal from "../../components/SubscriptionConfirmModal";
|
||||||
|
import { isWeb } from "../../hooks/useLayoutType";
|
||||||
|
|
||||||
const triggerWebDownload = (url, title) => {
|
const triggerWebDownload = (url, title) => {
|
||||||
if (Platform.OS !== "web") return;
|
if (Platform.OS !== "web") return;
|
||||||
@@ -46,7 +51,7 @@ const triggerWebDownload = (url, title) => {
|
|||||||
anchor.click();
|
anchor.click();
|
||||||
document.body.removeChild(anchor);
|
document.body.removeChild(anchor);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[DownloadSongs] web download fallback", {
|
console.log("[PlaybackDownload] web download fallback", {
|
||||||
message: error?.message,
|
message: error?.message,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
@@ -64,7 +69,7 @@ const guessExtension = (inputUri = "") => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const uploadSourceRecording = async ({ uri, uid, projectId }) => {
|
const uploadSourceRecording = async ({ uri, uid, projectId }) => {
|
||||||
console.log("[DownloadSongs] uploadSourceRecording params", {
|
console.log("[PlaybackDownload] uploadSourceRecording params", {
|
||||||
hasUri: Boolean(uri),
|
hasUri: Boolean(uri),
|
||||||
uid,
|
uid,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -76,13 +81,13 @@ const uploadSourceRecording = async ({ uri, uid, projectId }) => {
|
|||||||
const extension = guessExtension(uri);
|
const extension = guessExtension(uri);
|
||||||
const sourcePath = `users/${uid}/projects/${projectId}/recordings/source-${Date.now()}.${extension}`;
|
const sourcePath = `users/${uid}/projects/${projectId}/recordings/source-${Date.now()}.${extension}`;
|
||||||
console.log("source path : ", sourcePath);
|
console.log("source path : ", sourcePath);
|
||||||
console.log("[DownloadSongs] uploadSourceRecording source path", {
|
console.log("[PlaybackDownload] uploadSourceRecording source path", {
|
||||||
extension,
|
extension,
|
||||||
sourcePath,
|
sourcePath,
|
||||||
});
|
});
|
||||||
|
|
||||||
const cachedBlob = getBlobForUrl(uri);
|
const cachedBlob = getBlobForUrl(uri);
|
||||||
console.log("[DownloadSongs] uploadSourceRecording blob cache", {
|
console.log("[PlaybackDownload] uploadSourceRecording blob cache", {
|
||||||
hasBlob: Boolean(cachedBlob),
|
hasBlob: Boolean(cachedBlob),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -97,10 +102,11 @@ const uploadSourceRecording = async ({ uri, uid, projectId }) => {
|
|||||||
return { sourcePath, videoUrl };
|
return { sourcePath, videoUrl };
|
||||||
};
|
};
|
||||||
|
|
||||||
const DownloadSongs = ({ route }) => {
|
const PlaybackDownload = ({ route }) => {
|
||||||
const { currentUID } = useUserData();
|
const { currentUID } = useUserData();
|
||||||
|
const { hasActiveSubscription } = useUser() || {};
|
||||||
const { action, uri, project } = route.params || {};
|
const { action, uri, project } = route.params || {};
|
||||||
console.log("[DownloadSongs] route params", {
|
console.log("[PlaybackDownload] route params", {
|
||||||
action,
|
action,
|
||||||
projectId: project?.id,
|
projectId: project?.id,
|
||||||
hasUri: Boolean(uri),
|
hasUri: Boolean(uri),
|
||||||
@@ -109,6 +115,7 @@ const DownloadSongs = ({ route }) => {
|
|||||||
const { setIsLoading, setTooltip } = useMinuit();
|
const { setIsLoading, setTooltip } = useMinuit();
|
||||||
const [isAfterPlaybackVideoVisible, setIsAfterPlaybackVideoVisible] =
|
const [isAfterPlaybackVideoVisible, setIsAfterPlaybackVideoVisible] =
|
||||||
useState(false);
|
useState(false);
|
||||||
|
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
||||||
const hasShownAfterPlaybackRef = useRef(false);
|
const hasShownAfterPlaybackRef = useRef(false);
|
||||||
|
|
||||||
const { data: video } = useDataFromRef({
|
const { data: video } = useDataFromRef({
|
||||||
@@ -138,7 +145,7 @@ const DownloadSongs = ({ route }) => {
|
|||||||
const handleDownloadUri = async () => {
|
const handleDownloadUri = async () => {
|
||||||
if (action === "playback" && project?.id) {
|
if (action === "playback" && project?.id) {
|
||||||
// Publication du playback
|
// Publication du playback
|
||||||
console.log("[DownloadSongs] handleDownloadUri playback", {
|
console.log("[PlaybackDownload] handleDownloadUri playback", {
|
||||||
projectId: project.id,
|
projectId: project.id,
|
||||||
uri,
|
uri,
|
||||||
currentUID,
|
currentUID,
|
||||||
@@ -173,13 +180,16 @@ const DownloadSongs = ({ route }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
"[DownloadSongs] calling upload-mergeVideoAndAudio",
|
"[PlaybackDownload] calling upload-mergeVideoAndAudio",
|
||||||
payload
|
payload,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: result } = await callable(payload);
|
const { data: result } = await callable(payload);
|
||||||
|
|
||||||
console.log("[DownloadSongs] upload-mergeVideoAndAudio result", result);
|
console.log(
|
||||||
|
"[PlaybackDownload] upload-mergeVideoAndAudio result",
|
||||||
|
result,
|
||||||
|
);
|
||||||
|
|
||||||
const resultURI = result?.url || null;
|
const resultURI = result?.url || null;
|
||||||
|
|
||||||
@@ -189,7 +199,7 @@ const DownloadSongs = ({ route }) => {
|
|||||||
playbackUrl: resultURI,
|
playbackUrl: resultURI,
|
||||||
updatedAt: serverTimestamp(),
|
updatedAt: serverTimestamp(),
|
||||||
},
|
},
|
||||||
{ merge: true }
|
{ merge: true },
|
||||||
);
|
);
|
||||||
setTooltip({
|
setTooltip({
|
||||||
type: "success",
|
type: "success",
|
||||||
@@ -200,7 +210,7 @@ const DownloadSongs = ({ route }) => {
|
|||||||
try {
|
try {
|
||||||
await firebase.storage().ref(tempSourcePath).delete();
|
await firebase.storage().ref(tempSourcePath).delete();
|
||||||
} catch (cleanupError) {
|
} catch (cleanupError) {
|
||||||
console.log("[DownloadSongs] unable to delete temp source", {
|
console.log("[PlaybackDownload] unable to delete temp source", {
|
||||||
message: cleanupError?.message,
|
message: cleanupError?.message,
|
||||||
code: cleanupError?.code,
|
code: cleanupError?.code,
|
||||||
});
|
});
|
||||||
@@ -213,7 +223,7 @@ const DownloadSongs = ({ route }) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[DownloadSongs] error upload playback", {
|
console.log("[PlaybackDownload] error upload playback", {
|
||||||
message: error?.message,
|
message: error?.message,
|
||||||
code: error?.code,
|
code: error?.code,
|
||||||
name: error?.name,
|
name: error?.name,
|
||||||
@@ -227,7 +237,7 @@ const DownloadSongs = ({ route }) => {
|
|||||||
setTooltip({
|
setTooltip({
|
||||||
type: "error",
|
type: "error",
|
||||||
text: String(
|
text: String(
|
||||||
error?.message || "Erreur lors de la publication du playback"
|
error?.message || "Erreur lors de la publication du playback",
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
@@ -239,6 +249,9 @@ const DownloadSongs = ({ route }) => {
|
|||||||
// Handle song download
|
// Handle song download
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const continueLabel = hasActiveSubscription
|
||||||
|
? "Publier"
|
||||||
|
: "Publier sans générer de revenus";
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Page
|
<Page
|
||||||
@@ -250,130 +263,100 @@ const DownloadSongs = ({ route }) => {
|
|||||||
headerType="NONE"
|
headerType="NONE"
|
||||||
>
|
>
|
||||||
<MusicLandHeader onPressBack={goBack} progress={50} />
|
<MusicLandHeader onPressBack={goBack} progress={50} />
|
||||||
<View style={{ flex: 1, paddingTop: responsiveHeight(15) }}>
|
<ScrollView
|
||||||
<CreateLyricsHeader
|
contentContainerStyle={styles.container}
|
||||||
gradientProps={{
|
showsVerticalScrollIndicator={false}
|
||||||
start: { x: 0, y: 0 },
|
|
||||||
end: { x: 0, y: 1 },
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Image
|
<CreateLyricsHeader title={"Publier ton playback"} />
|
||||||
|
|
||||||
|
<View style={styles.coverRow}>
|
||||||
|
{project?.coverUrl ? (
|
||||||
|
<ExpoImage
|
||||||
source={{ uri: project?.coverUrl }}
|
source={{ uri: project?.coverUrl }}
|
||||||
style={{
|
style={styles.coverImage}
|
||||||
...size({ size: 158 }),
|
contentFit="cover"
|
||||||
borderRadius: 13,
|
|
||||||
alignSelf: "center",
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<View style={{ gap: 12, paddingVertical: 12 }}>
|
) : (
|
||||||
<Text style={styles.title}>
|
<View style={[styles.coverImage, styles.coverPlaceholder]}>
|
||||||
Prêt à télécharger
|
<Text style={styles.placeholderText}>Aucune pochette</Text>
|
||||||
{action === "playback" ? " ton Playback" : " ta chanson"} ?
|
|
||||||
</Text>
|
|
||||||
<View style={{ gap: 10 }}>
|
|
||||||
<Pressable
|
|
||||||
style={styles.itemContainer}
|
|
||||||
onPress={handleDownloadUri}
|
|
||||||
// navigate(Routes.DownloadPrices, {
|
|
||||||
// action,
|
|
||||||
// uri,
|
|
||||||
// })
|
|
||||||
>
|
|
||||||
<BlurView
|
|
||||||
style={styles.blurView}
|
|
||||||
intensity={Platform.OS !== "ios" ? 10 : 40}
|
|
||||||
tint="dark"
|
|
||||||
// experimentalBlurMethod={
|
|
||||||
// Platform.OS !== "ios" ? "dimezisBlurView" : "none"
|
|
||||||
// }
|
|
||||||
>
|
|
||||||
<Text style={styles.label}>
|
|
||||||
Télécharger{" "}
|
|
||||||
{action === "playback" ? "mon Playback" : "ma chanson"}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.description}>Pour moi uniquement</Text>
|
|
||||||
</BlurView>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable
|
|
||||||
style={styles.itemContainer}
|
|
||||||
onPress={() =>
|
|
||||||
navigate(Routes.StreamSong, {
|
|
||||||
action,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<BlurView
|
|
||||||
style={styles.blurView}
|
|
||||||
intensity={Platform.OS !== "ios" ? 10 : 40}
|
|
||||||
tint="dark"
|
|
||||||
// experimentalBlurMethod={
|
|
||||||
// Platform.OS !== "ios" ? "dimezisBlurView" : "none"
|
|
||||||
// }
|
|
||||||
>
|
|
||||||
<Text style={styles.label}>
|
|
||||||
Diffuser{" "}
|
|
||||||
{action === "playback" ? "mon Playback" : "ma chanson"}{" "}
|
|
||||||
sur la plateforme de MusicLand (+ réseaux sociaux) et
|
|
||||||
participer au concours
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.description}>
|
|
||||||
Top 3: 1er 15% du CA ML - 2ème 10% du CA ML - 3ème 5% du
|
|
||||||
CA ML (catégorie{" "}
|
|
||||||
{action === "playback" ? "Playback" : "chanson"})
|
|
||||||
</Text>
|
|
||||||
</BlurView>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
|
||||||
</CreateLyricsHeader>
|
|
||||||
</View>
|
|
||||||
</Page>
|
|
||||||
{action === "playback" && (
|
|
||||||
<FullscreenIntroVideo
|
|
||||||
url={afterPlaybackUrl || null}
|
|
||||||
visible={Boolean(afterPlaybackUrl) && isAfterPlaybackVideoVisible}
|
|
||||||
onClose={() => setIsAfterPlaybackVideoVisible(false)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Pressable style={styles.downloadTile} onPress={handleDownloadUri}>
|
||||||
|
<MaterialCommunityIcons
|
||||||
|
name="download"
|
||||||
|
size={22}
|
||||||
|
color={Palette.white}
|
||||||
|
/>
|
||||||
|
<Text style={styles.downloadText}>Télécharger le playback</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ClubAdvantagesCard style={styles.clubCardSpacing} />
|
||||||
|
|
||||||
|
<BorderGradientButton
|
||||||
|
title={continueLabel}
|
||||||
|
onPress={() => {
|
||||||
|
if (hasActiveSubscription) {
|
||||||
|
navigate(Routes.SongRelease, { action });
|
||||||
|
} else {
|
||||||
|
setShowConfirmModal(true);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
containerStyle={styles.continueButton}
|
||||||
|
/>
|
||||||
|
</ScrollView>
|
||||||
|
</Page>
|
||||||
|
<SubscriptionConfirmModal
|
||||||
|
continueLabel={"Continuer vers la publication de playback"}
|
||||||
|
isVisible={showConfirmModal}
|
||||||
|
setIsVisible={setShowConfirmModal}
|
||||||
|
onJoinClub={() => navigate(Routes.Payments)}
|
||||||
|
onContinue={() => navigate(Routes.SongRelease, { action })}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DownloadSongs;
|
export default PlaybackDownload;
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
title: {
|
container: {
|
||||||
fontSize: 22,
|
flexGrow: 1,
|
||||||
color: Palette.white,
|
paddingHorizontal: 16,
|
||||||
|
paddingVertical: 12,
|
||||||
|
gap: 14,
|
||||||
|
},
|
||||||
|
coverRow: {
|
||||||
|
flexDirection: isWeb ? "row" : "column",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: isWeb ? "center" : "center",
|
||||||
|
gap: 12,
|
||||||
|
},
|
||||||
|
coverImage: {
|
||||||
|
...size({ size: 140 }),
|
||||||
|
borderRadius: 14,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "rgba(255, 255, 255, 0.18)",
|
||||||
|
},
|
||||||
|
downloadTile: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 10,
|
||||||
|
paddingVertical: 10,
|
||||||
|
paddingHorizontal: 14,
|
||||||
|
borderRadius: 14,
|
||||||
|
backgroundColor: "#8C4BFF",
|
||||||
|
},
|
||||||
|
downloadText: {
|
||||||
fontFamily: FONT_FAMILY.InterSemiBold,
|
fontFamily: FONT_FAMILY.InterSemiBold,
|
||||||
},
|
fontSize: 15,
|
||||||
label: {
|
|
||||||
fontSize: 16,
|
|
||||||
color: Palette.white,
|
color: Palette.white,
|
||||||
fontFamily: FONT_FAMILY.HelveticaNeueBold,
|
|
||||||
},
|
},
|
||||||
description: {
|
clubCardSpacing: {
|
||||||
fontSize: 12,
|
marginTop: 10,
|
||||||
color: Palette.white,
|
|
||||||
fontFamily: FONT_FAMILY.InterRegular,
|
|
||||||
},
|
},
|
||||||
blurView: {
|
continueButton: {
|
||||||
paddingHorizontal: 10,
|
marginTop: 10,
|
||||||
paddingBottom: 8,
|
|
||||||
paddingTop: 10,
|
|
||||||
},
|
|
||||||
itemContainer: {
|
|
||||||
borderRadius: 12,
|
|
||||||
overflow: "hidden",
|
|
||||||
backgroundColor: "#FFFFFF03",
|
|
||||||
shadowColor: "#0000001A",
|
|
||||||
shadowOffset: {
|
|
||||||
width: 0,
|
|
||||||
height: 2,
|
|
||||||
},
|
|
||||||
shadowOpacity: 0.25,
|
|
||||||
shadowRadius: 3.84,
|
|
||||||
|
|
||||||
elevation: 5,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -23,7 +23,7 @@ const Production = () => {
|
|||||||
>
|
>
|
||||||
<BorderGradientButton
|
<BorderGradientButton
|
||||||
title="Je télécharge ma chanson"
|
title="Je télécharge ma chanson"
|
||||||
onPress={() => navigate(Routes.DownloadSongs)}
|
onPress={() => navigate(Routes.PlaybackDownload)}
|
||||||
/>
|
/>
|
||||||
<View style={{ gap: 12 }}>
|
<View style={{ gap: 12 }}>
|
||||||
<GradientButton title="Je veux devenir Playbacker" />
|
<GradientButton title="Je veux devenir Playbacker" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { View, Text, Image } from "react-native";
|
import { View, Text, Image } from "react-native";
|
||||||
import React, { useCallback, useMemo } from "react";
|
import React, { useCallback, useEffect } from "react";
|
||||||
import Page from "../../layouts/Page";
|
import Page from "../../layouts/Page";
|
||||||
import MusicLandHeader from "../../components/MusicLandHeader";
|
import MusicLandHeader from "../../components/MusicLandHeader";
|
||||||
import GradientButton from "../../components/GradientButton";
|
import GradientButton from "../../components/GradientButton";
|
||||||
@@ -14,80 +14,25 @@ import { Routes } from "../../navigation";
|
|||||||
import { useRoute } from "@react-navigation/native";
|
import { useRoute } from "@react-navigation/native";
|
||||||
import { useUser } from "../../providers/UserDataProvider";
|
import { useUser } from "../../providers/UserDataProvider";
|
||||||
|
|
||||||
const ACTIVE_SUBSCRIPTION_STATUSES = new Set([
|
|
||||||
"trialing",
|
|
||||||
"active",
|
|
||||||
"past_due",
|
|
||||||
"unpaid",
|
|
||||||
]);
|
|
||||||
|
|
||||||
const pickStatus = (value) => {
|
|
||||||
if (typeof value !== "string") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const trimmed = value.trim();
|
|
||||||
return trimmed ? trimmed.toLowerCase() : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const hasActiveSubscription = (userData) => {
|
|
||||||
if (!userData) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const statusCandidates = [
|
|
||||||
pickStatus(userData?.stripeSubscriptionStatus),
|
|
||||||
pickStatus(userData?.stripeSubscription?.status),
|
|
||||||
pickStatus(userData?.stripeSubscription?.stripeSubscriptionStatus),
|
|
||||||
pickStatus(userData?.stripeSubscription?.metadata?.status),
|
|
||||||
].filter(Boolean);
|
|
||||||
|
|
||||||
if (
|
|
||||||
statusCandidates.some((status) =>
|
|
||||||
ACTIVE_SUBSCRIPTION_STATUSES.has(status),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const premiumUntil = userData?.premiumUntil;
|
|
||||||
if (premiumUntil) {
|
|
||||||
const asDate =
|
|
||||||
premiumUntil?.toDate?.() ||
|
|
||||||
(premiumUntil?.seconds ? new Date(premiumUntil.seconds * 1000) : null);
|
|
||||||
|
|
||||||
if (asDate && asDate > new Date()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userData?.premium?.active) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const StreamSong = () => {
|
const StreamSong = () => {
|
||||||
const params = useRoute().params;
|
const params = useRoute().params;
|
||||||
const action = params?.action;
|
const action = params?.action;
|
||||||
const { currentUserData = null } = useUser() || {};
|
const project = params?.project || null;
|
||||||
const isPlaybackFlow = action === "playback";
|
const { hasActiveSubscription } = useUser() || {};
|
||||||
const userHasActiveSubscription = useMemo(
|
const userHasActiveSubscription = hasActiveSubscription;
|
||||||
() => hasActiveSubscription(currentUserData),
|
|
||||||
[currentUserData],
|
useEffect(() => {
|
||||||
);
|
if (action && action !== "playback") {
|
||||||
const headingText = isPlaybackFlow
|
navigate(Routes.SongDownload, { project });
|
||||||
? "Publier ton playback"
|
}
|
||||||
: "Publier ta chanson";
|
}, [action, project]);
|
||||||
|
|
||||||
|
const headingText = "Publier ton playback";
|
||||||
const descriptionText = userHasActiveSubscription
|
const descriptionText = userHasActiveSubscription
|
||||||
? `Ton abonnement est actif, tu peux publier ${
|
? "Ton abonnement est actif, publie ton playback et participe au concours."
|
||||||
isPlaybackFlow ? "ce playback" : "cette chanson"
|
: "Pour publier ton playback sur la plateforme, rejoins le Club MusicLand.";
|
||||||
} sur MusicLand et participer au concours.`
|
|
||||||
: `Pour publier ${isPlaybackFlow ? "ton playback" : "ta chanson"} sur la plateforme, tu dois rejoindre le Club MusicLand.`;
|
|
||||||
const ctaLabel = userHasActiveSubscription
|
const ctaLabel = userHasActiveSubscription
|
||||||
? isPlaybackFlow
|
|
||||||
? "Publier mon playback"
|
? "Publier mon playback"
|
||||||
: "Publier ma chanson"
|
|
||||||
: "Rejoindre le Club MusicLand";
|
: "Rejoindre le Club MusicLand";
|
||||||
const handlePrimaryAction = useCallback(() => {
|
const handlePrimaryAction = useCallback(() => {
|
||||||
if (userHasActiveSubscription) {
|
if (userHasActiveSubscription) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useFocusEffect } from "@react-navigation/native";
|
import { useFocusEffect } from "@react-navigation/native";
|
||||||
import React, { useCallback, useMemo, useState } from "react";
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
import { Alert, Platform, StyleSheet, Text, View } from "react-native";
|
import { Alert, Platform, StyleSheet, Text, View } from "react-native";
|
||||||
|
|
||||||
import BorderGradientButton from "../../components/BorderGradientButton";
|
import BorderGradientButton from "../../components/BorderGradientButton";
|
||||||
import CreditAmount from "../../components/CreditAmount";
|
import CreditAmount from "../../components/CreditAmount";
|
||||||
import { background } from "../../assets";
|
import { background } from "../../assets";
|
||||||
@@ -14,6 +13,7 @@ import { FONT_FAMILY } from "../../styles/Fonts";
|
|||||||
import { formatDate, toDate } from "../../utils/dateFormatting";
|
import { formatDate, toDate } from "../../utils/dateFormatting";
|
||||||
import { Image as ExpoImage } from "expo-image";
|
import { Image as ExpoImage } from "expo-image";
|
||||||
import { isWeb } from "../../hooks/useLayoutType";
|
import { isWeb } from "../../hooks/useLayoutType";
|
||||||
|
import ClubAdvantagesCard from "./components/ClubAdvantagesCard";
|
||||||
|
|
||||||
const FUNCTIONS_REGION = "europe-west1";
|
const FUNCTIONS_REGION = "europe-west1";
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ const PERIOD_LABELS = {
|
|||||||
annual: "Annuel",
|
annual: "Annuel",
|
||||||
};
|
};
|
||||||
|
|
||||||
const PAGE_BACKGROUND_COLOR = "#303438";
|
const PAGE_BACKGROUND_COLOR = "#252438";
|
||||||
|
|
||||||
const getStatusColors = (status) => {
|
const getStatusColors = (status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
@@ -263,7 +263,9 @@ const ManageSubscription = ({ navigation }) => {
|
|||||||
const statusSource =
|
const statusSource =
|
||||||
pickString(currentUserData?.stripeSubscriptionStatus) ||
|
pickString(currentUserData?.stripeSubscriptionStatus) ||
|
||||||
pickString(pickFromSources((source) => source?.status)) ||
|
pickString(pickFromSources((source) => source?.status)) ||
|
||||||
pickString(pickFromSources((source) => source?.stripeSubscriptionStatus)) ||
|
pickString(
|
||||||
|
pickFromSources((source) => source?.stripeSubscriptionStatus),
|
||||||
|
) ||
|
||||||
pickString(pickFromSources((source) => source?.metadata?.status)) ||
|
pickString(pickFromSources((source) => source?.metadata?.status)) ||
|
||||||
null;
|
null;
|
||||||
|
|
||||||
@@ -291,7 +293,9 @@ const ManageSubscription = ({ navigation }) => {
|
|||||||
const candidates = [
|
const candidates = [
|
||||||
pickString(pickFromSources((source) => source?.billingPeriod)),
|
pickString(pickFromSources((source) => source?.billingPeriod)),
|
||||||
pickString(currentUserData?.premiumBillingPeriod),
|
pickString(currentUserData?.premiumBillingPeriod),
|
||||||
pickString(pickFromSources((source) => source?.metadata?.billingPeriod)),
|
pickString(
|
||||||
|
pickFromSources((source) => source?.metadata?.billingPeriod),
|
||||||
|
),
|
||||||
pickString(
|
pickString(
|
||||||
pickFromSources(
|
pickFromSources(
|
||||||
(source) => source?.metadata?.subscriptionBillingPeriod,
|
(source) => source?.metadata?.subscriptionBillingPeriod,
|
||||||
@@ -716,6 +720,7 @@ const ManageSubscription = ({ navigation }) => {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
<ClubAdvantagesCard isDev style={styles.clubCardSpacing} />
|
||||||
</View>
|
</View>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
@@ -808,6 +813,9 @@ const styles = StyleSheet.create({
|
|||||||
emptyButton: {
|
emptyButton: {
|
||||||
marginTop: gutters * 1.5,
|
marginTop: gutters * 1.5,
|
||||||
},
|
},
|
||||||
|
clubCardSpacing: {
|
||||||
|
marginTop: gutters,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ManageSubscription;
|
export default ManageSubscription;
|
||||||
|
|||||||
@@ -0,0 +1,344 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { StyleSheet, Switch, Text, View } from "react-native";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
|
import { Image as ExpoImage } from "expo-image";
|
||||||
|
import { useNavigation } from "@react-navigation/native";
|
||||||
|
|
||||||
|
import ClubCard from "../../Home/components/ClubCard";
|
||||||
|
import { gutters, Palette } from "../../../styles";
|
||||||
|
import { FONT_FAMILY } from "../../../styles/Fonts";
|
||||||
|
import { Routes } from "../../../navigation/Routes";
|
||||||
|
import { useUserData } from "../../../providers/UserDataProvider";
|
||||||
|
import { icons } from "../../../assets";
|
||||||
|
import { isWeb } from "../../../hooks/useLayoutType";
|
||||||
|
|
||||||
|
const ICON_BASE_ACCENT = "#A96BFF";
|
||||||
|
|
||||||
|
const CLUB_ADVANTAGES = [
|
||||||
|
{
|
||||||
|
title: "Revenus partagés",
|
||||||
|
description: "Gagne sur tes écoutes et ta popularité.",
|
||||||
|
iconType: "vector",
|
||||||
|
iconName: "currency-usd",
|
||||||
|
accent: "#F8C24D",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Concours hit du mois",
|
||||||
|
description: "Vise le podium du mois et empoche la récompense.",
|
||||||
|
iconType: "vector",
|
||||||
|
iconName: "chart-line",
|
||||||
|
accent: "#7AE0FF",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Crédits mensuels",
|
||||||
|
description: "Des crédits premium tous les mois pour créer plus.",
|
||||||
|
iconType: "image",
|
||||||
|
icon: icons.coin,
|
||||||
|
accent: ICON_BASE_ACCENT,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const ClubAdvantagesCard = ({ style, isDev = false }) => {
|
||||||
|
const navigation = useNavigation();
|
||||||
|
const { hasActiveSubscription } = useUserData() || {};
|
||||||
|
const [useWebLayout, setUseWebLayout] = React.useState(isWeb);
|
||||||
|
const advantages = CLUB_ADVANTAGES;
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!isDev) {
|
||||||
|
setUseWebLayout(isWeb);
|
||||||
|
}
|
||||||
|
}, [isDev, isWeb]);
|
||||||
|
|
||||||
|
const title = hasActiveSubscription
|
||||||
|
? "Tu profites déjà du Club Musicland"
|
||||||
|
: "Rejoins le Club Musicland";
|
||||||
|
const subtitle = hasActiveSubscription
|
||||||
|
? "Grâce à ton abonnement, tu bénéficies de tous ces avantages."
|
||||||
|
: "Découvre ce que tu gagnes en passant au club premium.";
|
||||||
|
|
||||||
|
const handleOpenPlans = () => {
|
||||||
|
navigation.navigate(Routes.Payments);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.card,
|
||||||
|
hasActiveSubscription ? styles.cardActive : styles.cardInactive,
|
||||||
|
style,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{isDev ? (
|
||||||
|
<View style={styles.testSwitches}>
|
||||||
|
<View style={styles.switchRow}>
|
||||||
|
<Text style={styles.switchLabel}>Test layout web</Text>
|
||||||
|
<Switch
|
||||||
|
value={useWebLayout}
|
||||||
|
onValueChange={setUseWebLayout}
|
||||||
|
trackColor={{
|
||||||
|
false: "rgba(255, 255, 255, 0.2)",
|
||||||
|
true: "rgba(52, 199, 89, 0.7)",
|
||||||
|
}}
|
||||||
|
thumbColor={useWebLayout ? Palette.white : Palette.grayMid}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<View style={styles.header}>
|
||||||
|
<View style={styles.titleBlock}>
|
||||||
|
<Text style={styles.title}>{title}</Text>
|
||||||
|
<Text style={styles.subtitle}>{subtitle}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.advantagesList,
|
||||||
|
useWebLayout ? styles.advantagesListWeb : styles.advantagesListMobile,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{advantages.map((advantage) => {
|
||||||
|
const accent = advantage.accent || Palette.white;
|
||||||
|
const iconType = advantage.iconType || "image";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
key={advantage.title}
|
||||||
|
style={[
|
||||||
|
styles.advantageCard,
|
||||||
|
useWebLayout
|
||||||
|
? styles.advantageCardWeb
|
||||||
|
: styles.advantageCardMobile,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{hasActiveSubscription ? (
|
||||||
|
<MaterialCommunityIcons
|
||||||
|
name="check"
|
||||||
|
size={useWebLayout ? 22 : 20}
|
||||||
|
color={Palette.green}
|
||||||
|
style={[
|
||||||
|
styles.advantageCheck,
|
||||||
|
useWebLayout
|
||||||
|
? styles.advantageCheckWeb
|
||||||
|
: styles.advantageCheckMobile,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.advantageIcon,
|
||||||
|
useWebLayout && styles.advantageIconWeb,
|
||||||
|
{
|
||||||
|
backgroundColor: `${ICON_BASE_ACCENT}1F`,
|
||||||
|
borderColor: `${ICON_BASE_ACCENT}55`,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{iconType === "vector" ? (
|
||||||
|
<MaterialCommunityIcons
|
||||||
|
name={advantage.iconName}
|
||||||
|
size={24}
|
||||||
|
color={accent}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ExpoImage
|
||||||
|
source={advantage.icon}
|
||||||
|
contentFit="contain"
|
||||||
|
style={[styles.advantageIconImage, { tintColor: accent }]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.advantageContent,
|
||||||
|
useWebLayout && styles.advantageContentWeb,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.advantageTitle,
|
||||||
|
useWebLayout && styles.advantageTextCenter,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{advantage.title}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.advantageText,
|
||||||
|
useWebLayout && styles.advantageTextCenter,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{advantage.description}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ClubCard
|
||||||
|
image={icons.clubIcon}
|
||||||
|
onPress={handleOpenPlans}
|
||||||
|
hasActiveSubscription={hasActiveSubscription}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
card: {
|
||||||
|
paddingHorizontal: gutters * 1.25,
|
||||||
|
paddingVertical: gutters,
|
||||||
|
borderRadius: 24,
|
||||||
|
backgroundColor: "#252438",
|
||||||
|
borderWidth: 1,
|
||||||
|
gap: gutters,
|
||||||
|
borderColor: "white",
|
||||||
|
},
|
||||||
|
cardInactive: {
|
||||||
|
borderColor: "rgba(255, 255, 255, 0.08)",
|
||||||
|
},
|
||||||
|
cardActive: {
|
||||||
|
borderColor: Palette.green,
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
gap: gutters,
|
||||||
|
},
|
||||||
|
testSwitches: {
|
||||||
|
gap: gutters * 0.75,
|
||||||
|
backgroundColor: "rgba(255, 255, 255, 0.08)",
|
||||||
|
padding: gutters * 0.9,
|
||||||
|
borderRadius: 14,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "rgba(255, 255, 255, 0.12)",
|
||||||
|
},
|
||||||
|
switchRow: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: gutters * 0.5,
|
||||||
|
justifyContent: "space-between",
|
||||||
|
},
|
||||||
|
switchLabel: {
|
||||||
|
fontFamily: FONT_FAMILY.InterMedium,
|
||||||
|
fontSize: 11,
|
||||||
|
color: Palette.grayMid,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: 0.6,
|
||||||
|
},
|
||||||
|
titleBlock: {
|
||||||
|
flex: 1,
|
||||||
|
gap: gutters * 0.3,
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontFamily: FONT_FAMILY.InterSemiBold,
|
||||||
|
fontSize: 18,
|
||||||
|
color: Palette.white,
|
||||||
|
textAlign: "center",
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
fontFamily: FONT_FAMILY.InterRegular,
|
||||||
|
fontSize: 13,
|
||||||
|
color: "rgba(255, 255, 255, 0.82)",
|
||||||
|
lineHeight: 18,
|
||||||
|
textAlign: "center",
|
||||||
|
},
|
||||||
|
advantagesList: {
|
||||||
|
gap: gutters * 0.75,
|
||||||
|
},
|
||||||
|
advantagesListWeb: {
|
||||||
|
flexDirection: "row",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
},
|
||||||
|
advantagesListMobile: {
|
||||||
|
flexDirection: "column",
|
||||||
|
},
|
||||||
|
advantageCard: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
gap: gutters * 0.65,
|
||||||
|
backgroundColor: "rgba(255, 255, 255, 0.08)",
|
||||||
|
borderRadius: 16,
|
||||||
|
borderWidth: 0,
|
||||||
|
padding: gutters,
|
||||||
|
shadowColor: "#000",
|
||||||
|
shadowOffset: { width: 0, height: 6 },
|
||||||
|
shadowOpacity: 0.2,
|
||||||
|
shadowRadius: 10,
|
||||||
|
elevation: 2,
|
||||||
|
},
|
||||||
|
advantageCardWeb: {
|
||||||
|
flexBasis: "31%",
|
||||||
|
maxWidth: "32%",
|
||||||
|
minWidth: 200,
|
||||||
|
flexGrow: 1,
|
||||||
|
flexShrink: 1,
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
gap: gutters * 0.5,
|
||||||
|
position: "relative",
|
||||||
|
},
|
||||||
|
advantageCardMobile: {
|
||||||
|
width: "100%",
|
||||||
|
position: "relative",
|
||||||
|
},
|
||||||
|
advantageIcon: {
|
||||||
|
width: 42,
|
||||||
|
height: 42,
|
||||||
|
borderRadius: 12,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
borderWidth: 1,
|
||||||
|
},
|
||||||
|
advantageIconWeb: {
|
||||||
|
alignSelf: "center",
|
||||||
|
marginBottom: gutters * 0.15,
|
||||||
|
},
|
||||||
|
advantageIconImage: {
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
},
|
||||||
|
advantageContent: {
|
||||||
|
flex: 1,
|
||||||
|
gap: gutters * 0.2,
|
||||||
|
},
|
||||||
|
advantageContentWeb: {
|
||||||
|
alignItems: "center",
|
||||||
|
gap: gutters * 0.4,
|
||||||
|
},
|
||||||
|
advantageTitle: {
|
||||||
|
fontFamily: FONT_FAMILY.InterSemiBold,
|
||||||
|
fontSize: 15,
|
||||||
|
color: Palette.white,
|
||||||
|
},
|
||||||
|
advantageText: {
|
||||||
|
fontFamily: FONT_FAMILY.InterRegular,
|
||||||
|
fontSize: 13,
|
||||||
|
lineHeight: 18,
|
||||||
|
color: "rgba(255, 255, 255, 0.85)",
|
||||||
|
},
|
||||||
|
advantageTextCenter: {
|
||||||
|
textAlign: "center",
|
||||||
|
},
|
||||||
|
advantageCheck: {
|
||||||
|
position: "absolute",
|
||||||
|
},
|
||||||
|
advantageCheckWeb: {
|
||||||
|
top: 10,
|
||||||
|
right: 10,
|
||||||
|
},
|
||||||
|
advantageCheckMobile: {
|
||||||
|
top: "50%",
|
||||||
|
right: 12,
|
||||||
|
transform: [{ translateY: -10 }],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ClubAdvantagesCard;
|
||||||
@@ -126,6 +126,15 @@ const Register = () => {
|
|||||||
d’utilisation et notre politique de confidentialité.
|
d’utilisation et notre politique de confidentialité.
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
<Text style={styles.bottomFooterText}>
|
||||||
|
Tu as déjà un compte ?{" "}
|
||||||
|
<Text
|
||||||
|
style={styles.bottomFooterLink}
|
||||||
|
onPress={() => navigate(Routes.Login)}
|
||||||
|
>
|
||||||
|
Se connecter
|
||||||
|
</Text>
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,13 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useRoute } from "@react-navigation/native";
|
import { useRoute } from "@react-navigation/native";
|
||||||
import { Dimensions, FlatList, Modal, Text, View } from "react-native";
|
import {
|
||||||
|
FlatList,
|
||||||
|
Modal,
|
||||||
|
Text,
|
||||||
|
View,
|
||||||
|
useWindowDimensions,
|
||||||
|
} from "react-native";
|
||||||
import { background } from "../../assets";
|
import { background } from "../../assets";
|
||||||
import BorderGradientButton from "../../components/BorderGradientButton";
|
import BorderGradientButton from "../../components/BorderGradientButton";
|
||||||
import GradientButton from "../../components/GradientButton";
|
import GradientButton from "../../components/GradientButton";
|
||||||
@@ -28,20 +34,35 @@ import ChooseRhythm from "./ChooseRhythm";
|
|||||||
import CustomizeVoice from "./CustomizeVoice";
|
import CustomizeVoice from "./CustomizeVoice";
|
||||||
import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader";
|
import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader";
|
||||||
|
|
||||||
const { width: windowWidth } = Dimensions.get("window");
|
|
||||||
const MUSIC_GENERATION_COIN_COST = 8;
|
const MUSIC_GENERATION_COIN_COST = 8;
|
||||||
const CONFIRM_MODAL_MAX_WIDTH = 540;
|
const CONFIRM_MODAL_MAX_WIDTH = 540;
|
||||||
const FUNCTIONS_REGION = "europe-west1";
|
const FUNCTIONS_REGION = "europe-west1";
|
||||||
const VOICE_SECTION_TITLES = ["BASE", "SENSIBILITÉ", "TECHNIQUE"];
|
const VOICE_SECTION_TITLES = ["BASE", "SENSIBILITÉ", "TECHNIQUE"];
|
||||||
const FIRST_VOICE_STEP_INDEX = 1;
|
const FIRST_VOICE_STEP_INDEX = 1;
|
||||||
const OPTIONAL_VOICE_CATEGORIES = new Set(["SENSIBILITÉ", "TECHNIQUE"]);
|
const OPTIONAL_VOICE_CATEGORIES = new Set(["SENSIBILITÉ", "TECHNIQUE"]);
|
||||||
|
const PAGE_WIDTH_RATIO_WEB = 0.6; // keep in sync with Page default width on web
|
||||||
|
const PAGE_MAX_WIDTH = 1200;
|
||||||
|
const PAGE_HORIZONTAL_PADDING = gutters * 2;
|
||||||
|
|
||||||
const ComposeSong = () => {
|
const ComposeSong = () => {
|
||||||
const scrollRef = useRef(null);
|
const scrollRef = useRef(null);
|
||||||
|
const { width: windowWidth } = useWindowDimensions();
|
||||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||||
const [progress, setProgress] = useState(18);
|
const [progress, setProgress] = useState(18);
|
||||||
const [parentLayout, setParentLayout] = useState(null);
|
const [parentLayout, setParentLayout] = useState(null);
|
||||||
const containerWidth = parentLayout?.width || windowWidth || 1;
|
const estimatedContainerWidth = useMemo(() => {
|
||||||
|
const safeWindowWidth =
|
||||||
|
typeof windowWidth === "number" && Number.isFinite(windowWidth)
|
||||||
|
? windowWidth
|
||||||
|
: 0;
|
||||||
|
const estimatedPageWidth = Math.min(
|
||||||
|
safeWindowWidth * PAGE_WIDTH_RATIO_WEB,
|
||||||
|
PAGE_MAX_WIDTH
|
||||||
|
);
|
||||||
|
const paddedWidth = estimatedPageWidth - PAGE_HORIZONTAL_PADDING;
|
||||||
|
return Math.max(1, paddedWidth);
|
||||||
|
}, [windowWidth]);
|
||||||
|
const containerWidth = parentLayout?.width || estimatedContainerWidth;
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const {
|
const {
|
||||||
selectedProjectId,
|
selectedProjectId,
|
||||||
|
|||||||
@@ -919,10 +919,7 @@ const CustomizeSongStructure = ({ baseStructure = [], onChange }) => {
|
|||||||
title="Personnalise la structure de ta chanson"
|
title="Personnalise la structure de ta chanson"
|
||||||
subTitle="Réorganise par glisser-déposer"
|
subTitle="Réorganise par glisser-déposer"
|
||||||
/>
|
/>
|
||||||
<ScrollView
|
<View style={styles.content}>
|
||||||
contentContainerStyle={styles.scrollContent}
|
|
||||||
showsVerticalScrollIndicator={false}
|
|
||||||
>
|
|
||||||
<View style={styles.columns}>
|
<View style={styles.columns}>
|
||||||
<View style={styles.column}>
|
<View style={styles.column}>
|
||||||
<View style={styles.sectionTag}>
|
<View style={styles.sectionTag}>
|
||||||
@@ -931,7 +928,12 @@ const CustomizeSongStructure = ({ baseStructure = [], onChange }) => {
|
|||||||
<ItemContainer
|
<ItemContainer
|
||||||
height="auto"
|
height="auto"
|
||||||
disableKeyboardHeight
|
disableKeyboardHeight
|
||||||
style={styles.blurSection}
|
style={[styles.blurSection, styles.scrollSection]}
|
||||||
|
>
|
||||||
|
<ScrollView
|
||||||
|
style={styles.listScroll}
|
||||||
|
contentContainerStyle={styles.listContent}
|
||||||
|
showsVerticalScrollIndicator
|
||||||
>
|
>
|
||||||
<View style={styles.listContainer} ref={containerRef}>
|
<View style={styles.listContainer} ref={containerRef}>
|
||||||
{labeledItems.map((item, index) => (
|
{labeledItems.map((item, index) => (
|
||||||
@@ -947,6 +949,7 @@ const CustomizeSongStructure = ({ baseStructure = [], onChange }) => {
|
|||||||
<View style={styles.dropPreview} />
|
<View style={styles.dropPreview} />
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
</ScrollView>
|
||||||
</ItemContainer>
|
</ItemContainer>
|
||||||
</View>
|
</View>
|
||||||
<View style={[styles.column, styles.paletteColumn]}>
|
<View style={[styles.column, styles.paletteColumn]}>
|
||||||
@@ -956,7 +959,12 @@ const CustomizeSongStructure = ({ baseStructure = [], onChange }) => {
|
|||||||
<ItemContainer
|
<ItemContainer
|
||||||
height="auto"
|
height="auto"
|
||||||
disableKeyboardHeight
|
disableKeyboardHeight
|
||||||
style={styles.blurSection}
|
style={[styles.blurSection, styles.scrollSection]}
|
||||||
|
>
|
||||||
|
<ScrollView
|
||||||
|
style={styles.listScroll}
|
||||||
|
contentContainerStyle={styles.listContent}
|
||||||
|
showsVerticalScrollIndicator
|
||||||
>
|
>
|
||||||
<View style={styles.paletteList}>
|
<View style={styles.paletteList}>
|
||||||
{paletteSegments.map((segment) => {
|
{paletteSegments.map((segment) => {
|
||||||
@@ -1002,7 +1010,8 @@ const CustomizeSongStructure = ({ baseStructure = [], onChange }) => {
|
|||||||
onPressIn={(ev) => ev?.stopPropagation?.()}
|
onPressIn={(ev) => ev?.stopPropagation?.()}
|
||||||
onPress={(ev) => {
|
onPress={(ev) => {
|
||||||
ev?.stopPropagation?.();
|
ev?.stopPropagation?.();
|
||||||
const result = addOptionalSegment(segment.type);
|
const result =
|
||||||
|
addOptionalSegment(segment.type);
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
setInsertPreviewIndex(null);
|
setInsertPreviewIndex(null);
|
||||||
setActiveItemId(null);
|
setActiveItemId(null);
|
||||||
@@ -1022,7 +1031,9 @@ const CustomizeSongStructure = ({ baseStructure = [], onChange }) => {
|
|||||||
/>
|
/>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<View style={badgeStyle}>
|
<View style={badgeStyle}>
|
||||||
<Text style={styles.countBadgeText}>{count}</Text>
|
<Text style={styles.countBadgeText}>
|
||||||
|
{count}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -1031,10 +1042,11 @@ const CustomizeSongStructure = ({ baseStructure = [], onChange }) => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</View>
|
</View>
|
||||||
|
</ScrollView>
|
||||||
</ItemContainer>
|
</ItemContainer>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</View>
|
||||||
{dragOverlay ? (
|
{dragOverlay ? (
|
||||||
<View
|
<View
|
||||||
pointerEvents="none"
|
pointerEvents="none"
|
||||||
@@ -1093,25 +1105,29 @@ const styles = StyleSheet.create({
|
|||||||
gap: 10,
|
gap: 10,
|
||||||
marginTop: 16,
|
marginTop: 16,
|
||||||
},
|
},
|
||||||
scrollContent: {
|
content: {
|
||||||
|
flex: 1,
|
||||||
paddingBottom: 24,
|
paddingBottom: 24,
|
||||||
gap: 24,
|
|
||||||
},
|
},
|
||||||
columns: {
|
columns: {
|
||||||
|
flex: 1,
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
gap: 24,
|
gap: 24,
|
||||||
alignItems: "flex-start",
|
alignItems: "stretch",
|
||||||
|
minHeight: 0,
|
||||||
},
|
},
|
||||||
column: {
|
column: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
flexBasis: 0,
|
flexBasis: 0,
|
||||||
minWidth: 320,
|
minWidth: 320,
|
||||||
gap: 16,
|
gap: 16,
|
||||||
|
minHeight: 0,
|
||||||
},
|
},
|
||||||
paletteColumn: {
|
paletteColumn: {
|
||||||
flexBasis: 360,
|
flexBasis: 360,
|
||||||
maxWidth: 420,
|
maxWidth: 420,
|
||||||
|
minHeight: 0,
|
||||||
},
|
},
|
||||||
sectionTag: {
|
sectionTag: {
|
||||||
alignSelf: "flex-start",
|
alignSelf: "flex-start",
|
||||||
@@ -1133,6 +1149,17 @@ const styles = StyleSheet.create({
|
|||||||
blurSection: {
|
blurSection: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
},
|
},
|
||||||
|
scrollSection: {
|
||||||
|
flex: 1,
|
||||||
|
minHeight: 0,
|
||||||
|
},
|
||||||
|
listScroll: {
|
||||||
|
maxHeight: "68vh",
|
||||||
|
width: "100%",
|
||||||
|
},
|
||||||
|
listContent: {
|
||||||
|
paddingVertical: 6,
|
||||||
|
},
|
||||||
listContainer: {
|
listContainer: {
|
||||||
gap: 12,
|
gap: 12,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
Platform,
|
Platform,
|
||||||
Pressable,
|
Pressable,
|
||||||
ScrollView,
|
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
@@ -100,6 +99,7 @@ const Goals = ({
|
|||||||
const [draftOtherObjective, setDraftOtherObjective] = useState(
|
const [draftOtherObjective, setDraftOtherObjective] = useState(
|
||||||
normalizedOtherObjective
|
normalizedOtherObjective
|
||||||
);
|
);
|
||||||
|
const [listContainerLayout, setListContainerLayout] = useState(null);
|
||||||
|
|
||||||
const selected = selectedProp ?? internalSelected;
|
const selected = selectedProp ?? internalSelected;
|
||||||
const setSelectedBase = setSelectedProp ?? setInternalSelected;
|
const setSelectedBase = setSelectedProp ?? setInternalSelected;
|
||||||
@@ -173,15 +173,14 @@ const Goals = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ScrollView contentContainerStyle={{ flex: 1, gap: 16, marginTop: 16 }}>
|
<View style={{ flex: 1, gap: 16, marginTop: 16 }}>
|
||||||
<View style={{ gap: 10, height: "100%" }}>
|
<View style={{ flex: 1, gap: 10 }}>
|
||||||
<CreateLyricsHeader title={strings.writing.steps.contextTitle} />
|
<CreateLyricsHeader title={strings.writing.steps.contextTitle} />
|
||||||
{/* <View style={styles.examplesContainer}>
|
<View
|
||||||
<Text style={styles.examplesText}>
|
style={{ flex: 1 }}
|
||||||
{strings.writing.steps.contextExamples}
|
onLayout={(event) => setListContainerLayout(event.nativeEvent.layout)}
|
||||||
</Text>
|
>
|
||||||
</View> */}
|
<ItemContainer height={listContainerLayout?.height}>
|
||||||
<ItemContainer height={"80%"}>
|
|
||||||
<ListSelection
|
<ListSelection
|
||||||
options={goalsOptions}
|
options={goalsOptions}
|
||||||
variant="simple"
|
variant="simple"
|
||||||
@@ -193,6 +192,7 @@ const Goals = ({
|
|||||||
/>
|
/>
|
||||||
</ItemContainer>
|
</ItemContainer>
|
||||||
</View>
|
</View>
|
||||||
|
</View>
|
||||||
{selected === OTHER_OBJECTIVE_OPTION ? (
|
{selected === OTHER_OBJECTIVE_OPTION ? (
|
||||||
<View style={styles.otherObjectiveSummary}>
|
<View style={styles.otherObjectiveSummary}>
|
||||||
<View style={{ flex: 1, gap: 4 }}>
|
<View style={{ flex: 1, gap: 4 }}>
|
||||||
@@ -221,7 +221,7 @@ const Goals = ({
|
|||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
</ScrollView>
|
</View>
|
||||||
<OtherObjectiveModal
|
<OtherObjectiveModal
|
||||||
visible={otherObjectiveModalVisible}
|
visible={otherObjectiveModalVisible}
|
||||||
value={draftOtherObjective}
|
value={draftOtherObjective}
|
||||||
|
|||||||
@@ -223,54 +223,16 @@ const PouchReady = () => {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onValidatePicture = useCallback(async () => {
|
const onValidatePicture = useCallback(() => {
|
||||||
if (!selectedOption) {
|
if (!selectedOption) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
navigate(Routes.SongDownload, {
|
||||||
await setLoading(true, {
|
project: selectedProject,
|
||||||
message: "Validation de la pochette en cours...",
|
|
||||||
});
|
|
||||||
const existingCover = selectedProject?.cover || {};
|
|
||||||
const finalUrl =
|
|
||||||
selectedOption.finalUrl || selectedOption.generatedUrl || null;
|
|
||||||
const nextCoverData = {
|
|
||||||
...existingCover,
|
|
||||||
options: coverOptions,
|
|
||||||
selectedOptionId: selectedOption.id,
|
|
||||||
result: finalUrl,
|
|
||||||
generatedBackground:
|
|
||||||
selectedOption.generatedUrl || selectedOption.finalUrl || null,
|
|
||||||
};
|
|
||||||
await updateProjectData({
|
|
||||||
cover: nextCoverData,
|
|
||||||
coverUrl: finalUrl,
|
|
||||||
});
|
|
||||||
const projectForStage = {
|
|
||||||
...selectedProject,
|
|
||||||
cover: nextCoverData,
|
|
||||||
coverUrl: finalUrl,
|
|
||||||
};
|
|
||||||
const playbackStage = getStageAction("director", projectForStage);
|
|
||||||
await setLoading(false);
|
|
||||||
const targetRoute = playbackStage?.route || Routes.Playback;
|
|
||||||
const params = playbackStage?.params || {
|
|
||||||
project: projectForStage,
|
|
||||||
};
|
|
||||||
navigate(targetRoute, params);
|
|
||||||
} catch (e) {
|
|
||||||
console.log("PouchReady: unable to validate cover", e?.message);
|
|
||||||
} finally {
|
|
||||||
await setLoading(false);
|
|
||||||
}
|
|
||||||
}, [
|
|
||||||
coverOptions,
|
|
||||||
navigate,
|
|
||||||
selectedOption,
|
selectedOption,
|
||||||
selectedProject,
|
coverOptions,
|
||||||
setLoading,
|
});
|
||||||
updateProjectData,
|
}, [coverOptions, navigate, selectedOption, selectedProject]);
|
||||||
]);
|
|
||||||
|
|
||||||
const primaryActionTitle = hasGeneratedOptions
|
const primaryActionTitle = hasGeneratedOptions
|
||||||
? "Valider la pochette"
|
? "Valider la pochette"
|
||||||
|
|||||||
@@ -0,0 +1,485 @@
|
|||||||
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
|
import { Image as ExpoImage } from "expo-image";
|
||||||
|
import {
|
||||||
|
Linking,
|
||||||
|
Platform,
|
||||||
|
Pressable,
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
View,
|
||||||
|
} from "react-native";
|
||||||
|
import * as FileSystem from "expo-file-system";
|
||||||
|
import * as Sharing from "expo-sharing";
|
||||||
|
import BorderGradientButton from "../../components/BorderGradientButton";
|
||||||
|
import MusicLandHeader from "../../components/MusicLandHeader";
|
||||||
|
import Page from "../../layouts/Page";
|
||||||
|
import { Routes } from "../../navigation/Routes";
|
||||||
|
import { goBack, navigate } from "../../navigation/NavigationService";
|
||||||
|
import { useUser } from "../../providers/UserDataProvider";
|
||||||
|
import { gutters, Palette, Style } from "../../styles";
|
||||||
|
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||||
|
import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader";
|
||||||
|
import { background } from "../../assets";
|
||||||
|
import { getStageAction } from "../../utils/projectStages";
|
||||||
|
import ClubAdvantagesCard from "../Profile/components/ClubAdvantagesCard";
|
||||||
|
import useGlobalLoading from "../../hooks/useGlobalLoading";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
|
import { isWeb } from "../../hooks/useLayoutType";
|
||||||
|
import { getArtistDisplayName } from "../../utils/artistName";
|
||||||
|
import { toDate } from "../../utils/dateFormatting";
|
||||||
|
import SubscriptionConfirmModal from "../../components/SubscriptionConfirmModal";
|
||||||
|
|
||||||
|
const SongDownload = ({ route }) => {
|
||||||
|
const {
|
||||||
|
project: routeProject,
|
||||||
|
selectedOption: routeSelectedOption,
|
||||||
|
coverOptions: routeCoverOptions,
|
||||||
|
} = route?.params || {};
|
||||||
|
const { selectedProject, updateProjectData, hasActiveSubscription } =
|
||||||
|
useUser();
|
||||||
|
const { setLoading } = useGlobalLoading();
|
||||||
|
const [isDownloading, setIsDownloading] = useState(false);
|
||||||
|
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
||||||
|
|
||||||
|
const projectForStage = useMemo(
|
||||||
|
() => routeProject || selectedProject || null,
|
||||||
|
[routeProject, selectedProject],
|
||||||
|
);
|
||||||
|
|
||||||
|
const coverOptions = useMemo(() => {
|
||||||
|
if (Array.isArray(routeCoverOptions) && routeCoverOptions.length) {
|
||||||
|
return routeCoverOptions.filter(Boolean);
|
||||||
|
}
|
||||||
|
if (Array.isArray(projectForStage?.cover?.options)) {
|
||||||
|
return projectForStage.cover.options.filter(Boolean);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}, [projectForStage?.cover?.options, routeCoverOptions]);
|
||||||
|
|
||||||
|
const selectedOption = useMemo(() => {
|
||||||
|
if (routeSelectedOption) {
|
||||||
|
return routeSelectedOption;
|
||||||
|
}
|
||||||
|
const selectedId =
|
||||||
|
projectForStage?.cover?.selectedOptionId ||
|
||||||
|
projectForStage?.cover?.selectedOption?.id ||
|
||||||
|
null;
|
||||||
|
if (selectedId && coverOptions.length) {
|
||||||
|
const match = coverOptions.find((option) => option?.id === selectedId);
|
||||||
|
if (match) return match;
|
||||||
|
}
|
||||||
|
return coverOptions[0] || null;
|
||||||
|
}, [coverOptions, projectForStage?.cover, routeSelectedOption]);
|
||||||
|
|
||||||
|
const coverUrl =
|
||||||
|
selectedOption?.finalUrl ||
|
||||||
|
selectedOption?.generatedUrl ||
|
||||||
|
projectForStage?.coverUrl ||
|
||||||
|
projectForStage?.cover?.result ||
|
||||||
|
projectForStage?.cover?.generatedBackground ||
|
||||||
|
null;
|
||||||
|
const trackTitle =
|
||||||
|
typeof projectForStage?.title === "string" && projectForStage.title.trim()
|
||||||
|
? projectForStage.title.trim()
|
||||||
|
: "Musicland Track";
|
||||||
|
|
||||||
|
const continueFlow = useCallback(async () => {
|
||||||
|
if (!selectedOption) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await setLoading(true, { message: "Sauvegarde de ta pochette..." });
|
||||||
|
const existingCover = projectForStage?.cover || {};
|
||||||
|
const finalUrl =
|
||||||
|
selectedOption.finalUrl || selectedOption.generatedUrl || coverUrl;
|
||||||
|
const nextCoverData = {
|
||||||
|
...existingCover,
|
||||||
|
options: coverOptions,
|
||||||
|
selectedOptionId: selectedOption.id,
|
||||||
|
result: finalUrl,
|
||||||
|
generatedBackground:
|
||||||
|
selectedOption.generatedUrl || selectedOption.finalUrl || null,
|
||||||
|
};
|
||||||
|
await updateProjectData({
|
||||||
|
cover: nextCoverData,
|
||||||
|
coverUrl: finalUrl,
|
||||||
|
});
|
||||||
|
const nextProject = {
|
||||||
|
...projectForStage,
|
||||||
|
cover: nextCoverData,
|
||||||
|
coverUrl: finalUrl,
|
||||||
|
};
|
||||||
|
const nextPlaybackStage = getStageAction("director", nextProject);
|
||||||
|
const targetRoute = nextPlaybackStage?.route || Routes.Playback;
|
||||||
|
const params = nextPlaybackStage?.params || { project: nextProject };
|
||||||
|
navigate(targetRoute, params);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[SongDownload] continue error", error?.message);
|
||||||
|
} finally {
|
||||||
|
await setLoading(false);
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
coverOptions,
|
||||||
|
coverUrl,
|
||||||
|
navigate,
|
||||||
|
projectForStage,
|
||||||
|
selectedOption,
|
||||||
|
setLoading,
|
||||||
|
updateProjectData,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const handleContinue = useCallback(() => {
|
||||||
|
if (hasActiveSubscription) {
|
||||||
|
continueFlow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setShowConfirmModal(true);
|
||||||
|
}, [continueFlow, hasActiveSubscription]);
|
||||||
|
|
||||||
|
const handleDownload = useCallback(async () => {
|
||||||
|
const downloadUrl =
|
||||||
|
projectForStage?.songUrl ||
|
||||||
|
projectForStage?.playbackUrl ||
|
||||||
|
selectedOption?.finalUrl ||
|
||||||
|
selectedOption?.generatedUrl ||
|
||||||
|
null;
|
||||||
|
if (!downloadUrl || isDownloading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await setLoading(true, { message: "Préparation du téléchargement..." });
|
||||||
|
const artist = getArtistDisplayName(projectForStage, "MusicLand");
|
||||||
|
const createdDate = toDate(projectForStage?.createdAt) || new Date();
|
||||||
|
const createdLabel = createdDate
|
||||||
|
? createdDate.toISOString().split("T")[0]
|
||||||
|
: "";
|
||||||
|
|
||||||
|
const triggerWebDownload = async (url, title) => {
|
||||||
|
setIsDownloading(true);
|
||||||
|
await setLoading(true, { message: "Préparation du téléchargement..." });
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`download_failed_${response.status}`);
|
||||||
|
}
|
||||||
|
const contentType =
|
||||||
|
response.headers.get("content-type") || "audio/mpeg";
|
||||||
|
const baseName =
|
||||||
|
String(trackTitle || "musicland-track")
|
||||||
|
.replace(/[\\/:*?"<>|]+/g, "-")
|
||||||
|
.trim() || "musicland-track";
|
||||||
|
const filename = `${baseName}.mp3`;
|
||||||
|
const buffer = await response.arrayBuffer();
|
||||||
|
|
||||||
|
if (contentType.includes("audio")) {
|
||||||
|
const toSynchSafe = (size) => {
|
||||||
|
const out = new Uint8Array(4);
|
||||||
|
out[0] = (size >> 21) & 0x7f;
|
||||||
|
out[1] = (size >> 14) & 0x7f;
|
||||||
|
out[2] = (size >> 7) & 0x7f;
|
||||||
|
out[3] = size & 0x7f;
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
const concatBytes = (...arrays) => {
|
||||||
|
const totalLength = arrays.reduce(
|
||||||
|
(sum, arr) => sum + arr.length,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const result = new Uint8Array(totalLength);
|
||||||
|
let offset = 0;
|
||||||
|
arrays.forEach((arr) => {
|
||||||
|
result.set(arr, offset);
|
||||||
|
offset += arr.length;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildTextFrame = (id, value) => {
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
const textBytes = encoder.encode(value || "");
|
||||||
|
const data = concatBytes(new Uint8Array([0x03]), textBytes);
|
||||||
|
const header = concatBytes(
|
||||||
|
new TextEncoder().encode(id),
|
||||||
|
toSynchSafe(data.length),
|
||||||
|
new Uint8Array([0x00, 0x00]),
|
||||||
|
);
|
||||||
|
return concatBytes(header, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildApicFrame = (imageBytes, mime) => {
|
||||||
|
if (!imageBytes) return null;
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
const mimeBytes = encoder.encode(mime || "image/jpeg");
|
||||||
|
const data = concatBytes(
|
||||||
|
new Uint8Array([0x03]),
|
||||||
|
mimeBytes,
|
||||||
|
new Uint8Array([0x00]), // mime terminator
|
||||||
|
new Uint8Array([0x03]), // front cover
|
||||||
|
new Uint8Array([0x00]), // empty description
|
||||||
|
new Uint8Array(imageBytes),
|
||||||
|
);
|
||||||
|
const header = concatBytes(
|
||||||
|
new TextEncoder().encode("APIC"),
|
||||||
|
toSynchSafe(data.length),
|
||||||
|
new Uint8Array([0x00, 0x00]),
|
||||||
|
);
|
||||||
|
return concatBytes(header, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildId3Tag = (audioBytes, coverBytes, coverMime) => {
|
||||||
|
const frames = [];
|
||||||
|
frames.push(buildTextFrame("TIT2", trackTitle));
|
||||||
|
frames.push(buildTextFrame("TPE1", artist));
|
||||||
|
frames.push(buildTextFrame("TDRC", createdLabel));
|
||||||
|
const apic = buildApicFrame(coverBytes, coverMime);
|
||||||
|
if (apic) frames.push(apic);
|
||||||
|
|
||||||
|
const framesData = concatBytes(...frames);
|
||||||
|
const header = concatBytes(
|
||||||
|
new TextEncoder().encode("ID3"),
|
||||||
|
new Uint8Array([0x04, 0x00]), // version 2.4.0
|
||||||
|
new Uint8Array([0x00]), // flags
|
||||||
|
toSynchSafe(framesData.length),
|
||||||
|
);
|
||||||
|
return concatBytes(header, framesData, audioBytes);
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchCoverBytes = async () => {
|
||||||
|
if (!coverUrl) return { bytes: null, mime: null };
|
||||||
|
try {
|
||||||
|
const res = await fetch(coverUrl);
|
||||||
|
const mime = res.headers?.get("content-type") || "image/jpeg";
|
||||||
|
const bufferImage = await res.arrayBuffer();
|
||||||
|
return { bytes: new Uint8Array(bufferImage), mime };
|
||||||
|
} catch {
|
||||||
|
return { bytes: null, mime: null };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const { bytes: coverBytes, mime: coverMime } =
|
||||||
|
await fetchCoverBytes();
|
||||||
|
const merged = buildId3Tag(
|
||||||
|
new Uint8Array(buffer),
|
||||||
|
coverBytes,
|
||||||
|
coverMime,
|
||||||
|
);
|
||||||
|
const blob = new Blob([merged], { type: contentType });
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
const downloadLink = document.createElement("a");
|
||||||
|
downloadLink.href = blobUrl;
|
||||||
|
downloadLink.download = filename;
|
||||||
|
document.body.appendChild(downloadLink);
|
||||||
|
downloadLink.click();
|
||||||
|
document.body.removeChild(downloadLink);
|
||||||
|
URL.revokeObjectURL(blobUrl);
|
||||||
|
} else {
|
||||||
|
const blob = await response.blob();
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
const downloadLink = document.createElement("a");
|
||||||
|
downloadLink.href = blobUrl;
|
||||||
|
downloadLink.download = filename;
|
||||||
|
document.body.appendChild(downloadLink);
|
||||||
|
downloadLink.click();
|
||||||
|
document.body.removeChild(downloadLink);
|
||||||
|
URL.revokeObjectURL(blobUrl);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setIsDownloading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isWeb) {
|
||||||
|
await triggerWebDownload(downloadUrl, projectForStage?.title);
|
||||||
|
await setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsDownloading(true);
|
||||||
|
try {
|
||||||
|
const baseName =
|
||||||
|
String(trackTitle || "musicland-track")
|
||||||
|
.replace(/[\\/:*?"<>|]+/g, "-")
|
||||||
|
.trim() || "musicland-track";
|
||||||
|
const fileName = `${baseName}.mp3`;
|
||||||
|
const targetUri = `${FileSystem.cacheDirectory || ""}${fileName}`;
|
||||||
|
|
||||||
|
const downloadResult = await FileSystem.downloadAsync(
|
||||||
|
downloadUrl,
|
||||||
|
targetUri,
|
||||||
|
);
|
||||||
|
if (!downloadResult?.uri) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Platform.OS === "android") {
|
||||||
|
const permissions =
|
||||||
|
await FileSystem.StorageAccessFramework.requestDirectoryPermissionsAsync();
|
||||||
|
if (!permissions.granted || !permissions.directoryUri) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const base64 = await FileSystem.readAsStringAsync(downloadResult.uri, {
|
||||||
|
encoding: FileSystem.EncodingType.Base64,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const destUri =
|
||||||
|
await FileSystem.StorageAccessFramework.createFileAsync(
|
||||||
|
permissions.directoryUri,
|
||||||
|
fileName,
|
||||||
|
"audio/mpeg",
|
||||||
|
);
|
||||||
|
await FileSystem.writeAsStringAsync(destUri, base64, {
|
||||||
|
encoding: FileSystem.EncodingType.Base64,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[SongDownload] SAF write error", error?.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (await Sharing.isAvailableAsync()) {
|
||||||
|
try {
|
||||||
|
await Sharing.shareAsync(downloadResult.uri, {
|
||||||
|
mimeType: "audio/mpeg",
|
||||||
|
dialogTitle: "Enregistrer la musique",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[SongDownload] share error", error?.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await Linking.openURL(downloadResult.uri);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(
|
||||||
|
"[SongDownload] open local file error",
|
||||||
|
error?.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[SongDownload] native download open error", error?.message);
|
||||||
|
} finally {
|
||||||
|
setIsDownloading(false);
|
||||||
|
await setLoading(false);
|
||||||
|
}
|
||||||
|
}, [coverUrl, isDownloading, projectForStage, selectedOption, trackTitle]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Page backgroundImg={background.studioBG2} headerType="NONE">
|
||||||
|
<MusicLandHeader onPressBack={goBack} progress={84} />
|
||||||
|
<ScrollView
|
||||||
|
contentContainerStyle={[
|
||||||
|
styles.container,
|
||||||
|
!isWeb && styles.containerMobile,
|
||||||
|
styles.scrollContent,
|
||||||
|
]}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
<CreateLyricsHeader title="Ta pochette est validée" />
|
||||||
|
<View style={styles.coverRow}>
|
||||||
|
{coverUrl ? (
|
||||||
|
<ExpoImage
|
||||||
|
source={{ uri: coverUrl }}
|
||||||
|
style={styles.coverImage}
|
||||||
|
contentFit="cover"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<View style={[styles.coverImage, styles.coverPlaceholder]}>
|
||||||
|
<Text style={styles.placeholderText}>Aucune pochette</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Pressable style={styles.downloadTile} onPress={handleDownload}>
|
||||||
|
<MaterialCommunityIcons
|
||||||
|
name="download"
|
||||||
|
size={22}
|
||||||
|
color={Palette.white}
|
||||||
|
/>
|
||||||
|
<Text style={styles.downloadText}>Télécharger la musique</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ClubAdvantagesCard style={styles.clubCardSpacing} />
|
||||||
|
|
||||||
|
<BorderGradientButton
|
||||||
|
title={
|
||||||
|
hasActiveSubscription
|
||||||
|
? "Continuer"
|
||||||
|
: "Continuer sans générer de revenus"
|
||||||
|
}
|
||||||
|
onPress={handleContinue}
|
||||||
|
containerStyle={styles.continueButton}
|
||||||
|
/>
|
||||||
|
</ScrollView>
|
||||||
|
<SubscriptionConfirmModal
|
||||||
|
isVisible={showConfirmModal}
|
||||||
|
setIsVisible={setShowConfirmModal}
|
||||||
|
onJoinClub={() => navigate(Routes.Payments)}
|
||||||
|
onContinue={continueFlow}
|
||||||
|
/>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flexGrow: 1,
|
||||||
|
width: "100%",
|
||||||
|
paddingHorizontal: gutters * 1.2,
|
||||||
|
paddingBottom: gutters * 1.8,
|
||||||
|
paddingTop: gutters,
|
||||||
|
gap: gutters * 1.2,
|
||||||
|
},
|
||||||
|
containerMobile: {
|
||||||
|
paddingHorizontal: 0,
|
||||||
|
paddingBottom: gutters * 1.2,
|
||||||
|
paddingTop: gutters * 0.8,
|
||||||
|
},
|
||||||
|
scrollContent: {
|
||||||
|
paddingBottom: gutters * 2.6,
|
||||||
|
},
|
||||||
|
coverRow: {
|
||||||
|
flexDirection: isWeb ? "row" : "column",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
gap: gutters * 0.8,
|
||||||
|
},
|
||||||
|
coverImage: {
|
||||||
|
width: 150,
|
||||||
|
height: 150,
|
||||||
|
borderRadius: 16,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "rgba(255, 255, 255, 0.18)",
|
||||||
|
},
|
||||||
|
coverPlaceholder: {
|
||||||
|
...Style.centered,
|
||||||
|
backgroundColor: "rgba(255, 255, 255, 0.06)",
|
||||||
|
},
|
||||||
|
placeholderText: {
|
||||||
|
fontFamily: FONT_FAMILY.InterMedium,
|
||||||
|
color: Palette.grayMid,
|
||||||
|
},
|
||||||
|
downloadTile: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 10,
|
||||||
|
paddingVertical: gutters * 0.9,
|
||||||
|
paddingHorizontal: gutters * 1.2,
|
||||||
|
borderRadius: 14,
|
||||||
|
backgroundColor: "#8C4BFF",
|
||||||
|
borderWidth: 0,
|
||||||
|
},
|
||||||
|
downloadText: {
|
||||||
|
fontFamily: FONT_FAMILY.InterSemiBold,
|
||||||
|
fontSize: 15,
|
||||||
|
color: Palette.white,
|
||||||
|
},
|
||||||
|
clubCardSpacing: {
|
||||||
|
marginTop: gutters * 0.5,
|
||||||
|
},
|
||||||
|
continueButton: {
|
||||||
|
marginTop: gutters * 0.5,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default SongDownload;
|
||||||
@@ -11,7 +11,6 @@ import { Routes } from "../../navigation";
|
|||||||
import { goBack, navigate } from "../../navigation/NavigationService";
|
import { goBack, navigate } from "../../navigation/NavigationService";
|
||||||
import { useUserData } from "../../providers/UserDataProvider";
|
import { useUserData } from "../../providers/UserDataProvider";
|
||||||
import { gutters, Palette, Style } from "../../styles";
|
import { gutters, Palette, Style } from "../../styles";
|
||||||
import { getStageAction } from "../../utils/projectStages";
|
|
||||||
import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader";
|
import CreateLyricsHeader from "../Writing/components/CreateLyricsHeader";
|
||||||
|
|
||||||
const ValidateCover = () => {
|
const ValidateCover = () => {
|
||||||
@@ -91,39 +90,11 @@ const ValidateCover = () => {
|
|||||||
if (!selectedOption) {
|
if (!selectedOption) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
navigate(Routes.SongDownload, {
|
||||||
await setIsLoading(true);
|
project: selectedProject,
|
||||||
const existingCover = selectedProject?.cover || {};
|
selectedOption,
|
||||||
const finalUrl =
|
coverOptions,
|
||||||
selectedOption.finalUrl || selectedOption.generatedUrl || null;
|
|
||||||
const nextCoverData = {
|
|
||||||
...existingCover,
|
|
||||||
options: coverOptions,
|
|
||||||
selectedOptionId: selectedOption.id,
|
|
||||||
result: finalUrl,
|
|
||||||
generatedBackground:
|
|
||||||
selectedOption.generatedUrl || selectedOption.finalUrl || null,
|
|
||||||
};
|
|
||||||
await updateProjectData({
|
|
||||||
cover: nextCoverData,
|
|
||||||
coverUrl: finalUrl,
|
|
||||||
});
|
});
|
||||||
const projectForStage = {
|
|
||||||
...selectedProject,
|
|
||||||
cover: nextCoverData,
|
|
||||||
coverUrl: finalUrl,
|
|
||||||
};
|
|
||||||
const playbackStage = getStageAction("director", projectForStage);
|
|
||||||
await setIsLoading(false);
|
|
||||||
const targetRoute = playbackStage?.route || Routes.Playback;
|
|
||||||
const params = playbackStage?.params || { project: projectForStage };
|
|
||||||
navigate(targetRoute, params);
|
|
||||||
return;
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
} finally {
|
|
||||||
await setIsLoading(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+21
-4
@@ -14,7 +14,19 @@ export const getProjectLikes = (project, target = LIKE_TARGET.SONG) => {
|
|||||||
const path = target === LIKE_TARGET.PLAYBACK ? "playback" : "song";
|
const path = target === LIKE_TARGET.PLAYBACK ? "playback" : "song";
|
||||||
const likes = project?.likes;
|
const likes = project?.likes;
|
||||||
const list = likes ? likes[path] : null;
|
const list = likes ? likes[path] : null;
|
||||||
return Array.isArray(list) ? list : [];
|
const normalized = Array.isArray(list) ? list : [];
|
||||||
|
const legacy = Array.isArray(project?.likedBy) ? project.likedBy : [];
|
||||||
|
|
||||||
|
if (target !== LIKE_TARGET.SONG || legacy.length === 0) {
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
const merged = new Set(normalized);
|
||||||
|
legacy.forEach((uid) => {
|
||||||
|
if (uid) merged.add(uid);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Array.from(merged);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isProjectLikedByUser = (
|
export const isProjectLikedByUser = (
|
||||||
@@ -35,11 +47,16 @@ export const toggleProjectLike = async ({
|
|||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
if (!ensureAuthenticated(currentUID)) return;
|
if (!ensureAuthenticated(currentUID)) return;
|
||||||
const fieldPath = getLikeFieldPath(target);
|
const fieldPath = getLikeFieldPath(target);
|
||||||
|
const likeOperation = next ? arrayUnion(currentUID) : arrayRemove(currentUID);
|
||||||
await projectsRef.doc(projectId).set(
|
await projectsRef.doc(projectId).set(
|
||||||
{
|
{
|
||||||
[fieldPath]: next
|
[fieldPath]: likeOperation,
|
||||||
? arrayUnion(currentUID)
|
...(target === LIKE_TARGET.SONG
|
||||||
: arrayRemove(currentUID),
|
? {
|
||||||
|
// Keep legacy likedBy in sync for clients still reading this field
|
||||||
|
likedBy: next ? arrayUnion(currentUID) : arrayRemove(currentUID),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
},
|
},
|
||||||
{ merge: true }
|
{ merge: true }
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user