monthly money

This commit is contained in:
Thomas Demirdjian
2025-10-31 17:31:10 +01:00
parent 6f330c1df8
commit 0dd0fa5ab7
10 changed files with 299 additions and 1 deletions
+28
View File
@@ -3,6 +3,7 @@ import { Pressable, Text, View } from "react-native";
import { SheetManager } from "react-native-actions-sheet";
import { Palette } from "../../styles";
import { FONT_FAMILY } from "../../styles/Fonts";
import { openShareSheet } from "../../utils/shareSheet";
import AppActionSheet from "../AppActionSheet";
const OptionButton = ({ label, onPress, disabled = false }) => (
@@ -40,6 +41,9 @@ const MusicOptionsModal = ({ payload }) => {
projectId = null,
ownerId = null,
title = null,
onShare,
sharePayload = null,
shareDisabled = false,
} = payload || {};
const trigger = useCallback((action) => {
@@ -97,6 +101,23 @@ const MusicOptionsModal = ({ payload }) => {
trigger(run);
}, [downloadDisabled, onDownload, trigger]);
const handleShare = useCallback(() => {
if (shareDisabled) return;
const run = () => {
if (typeof onShare === "function") {
onShare();
return;
}
if (sharePayload) {
openShareSheet(sharePayload);
}
};
trigger(run);
}, [onShare, shareDisabled, sharePayload, trigger]);
const shouldShowShareOption =
typeof onShare === "function" || !!sharePayload;
return (
<AppActionSheet id="MusicOptions">
<View style={{ gap: 20 }}>
@@ -116,6 +137,13 @@ const MusicOptionsModal = ({ payload }) => {
label="Ajouter à une playlist"
onPress={handleAddToPlaylist}
/>
{shouldShowShareOption && (
<OptionButton
label="Partager la musique"
onPress={handleShare}
disabled={shareDisabled}
/>
)}
<OptionButton
label="Télécharger"
onPress={handleDownload}
+22
View File
@@ -38,6 +38,10 @@ import {
getSegmentMeta,
normalizeStructureType,
} from "../../utils/songStructure";
import {
createMusicSharePayload,
openShareSheet,
} from "../../utils/shareSheet";
// 20 secondes
const timeBeforeIncrement = 20000;
@@ -108,6 +112,19 @@ const MusicDetails = ({ route }) => {
};
}, [trackId, songUrl, title, artist, coverUrl, projectId]);
const sharePayload = useMemo(() => {
return createMusicSharePayload({
projectId,
title,
artist,
});
}, [artist, projectId, title]);
const handleShare = useCallback(() => {
if (!sharePayload) return;
openShareSheet(sharePayload);
}, [sharePayload]);
const handleReport = useCallback(() => {
if (!projectId) return;
SheetManager.show("Report", {
@@ -147,15 +164,20 @@ const MusicDetails = ({ route }) => {
onAddToPlaylist: handleAddToPlaylist,
onDownload: handleDownload,
downloadDisabled: !songUrl,
onShare: sharePayload ? handleShare : null,
sharePayload,
shareDisabled: !sharePayload,
},
});
}, [
handleAddToPlaylist,
handleDownload,
handleReport,
handleShare,
owner?.id,
project?.userId,
projectId,
sharePayload,
songUrl,
title,
]);
+5
View File
@@ -243,16 +243,21 @@ const MusicDetails = ({ route }) => {
onAddToPlaylist: handleAddToPlaylist,
onDownload: handleDownload,
downloadDisabled: isDownloading || !songUrl,
onShare: sharePayload ? handleShare : null,
sharePayload,
shareDisabled: !sharePayload,
},
});
}, [
handleAddToPlaylist,
handleDownload,
handleReport,
handleShare,
isDownloading,
owner?.id,
project?.userId,
projectId,
sharePayload,
songUrl,
title,
]);