playback cards

This commit is contained in:
2025-09-05 15:01:45 +02:00
parent 8464f986c4
commit e5cd374382
2 changed files with 77 additions and 48 deletions
+21 -2
View File
@@ -22,6 +22,16 @@ const HitParade = () => {
listener: true, listener: true,
condition: true, condition: true,
}); });
const { data: topPlaybacks } = useDataFromRef({
// Firestore n'autorise pas 2 inégalités (>, <, >=, <=, !=) sur des champs différents.
// On ne garde qu'une inégalité côté requête (views > 0) et on filtre ensuite côté client.
// On surdimensionne le limit pour s'assurer d'obtenir 10 playbacks après filtrage.
ref: projectsRef.where("views", ">", 0).orderBy("views", "desc").limit(50),
format: (docs) => docs.filter((d) => d?.playbackUrl != null).slice(0, 10),
simpleRef: false,
listener: true,
condition: true,
});
return ( return (
<Page backgroundImg={background.hitParadeBG} headerType="NONE"> <Page backgroundImg={background.hitParadeBG} headerType="NONE">
@@ -114,8 +124,17 @@ const HitParade = () => {
gap: 10, gap: 10,
paddingBottom: responsiveHeight(20), paddingBottom: responsiveHeight(20),
}} }}
data={Array.from({ length: 5 })} data={Array.isArray(topPlaybacks) ? topPlaybacks : []}
renderItem={() => <PlaybacksCard />} keyExtractor={(item) => item.id}
renderItem={({ item, index }) => (
<PlaybacksCard
rank={index + 1}
title={item?.title || "Sans titre"}
artist={"MusicLand"}
coverUrl={item?.coverUrl || null}
onPress={() => navigate(Routes.Playbacks, { projectId: item.id })}
/>
)}
/> />
)} )}
{selected === "Clips" && ( {selected === "Clips" && (
@@ -1,4 +1,4 @@
import { View, Text, Image, Platform } from "react-native"; import { View, Text, Image, Platform, Pressable } from "react-native";
import React from "react"; import React from "react";
import { BlurView } from "expo-blur"; import { BlurView } from "expo-blur";
import { img } from "../../../assets"; import { img } from "../../../assets";
@@ -6,8 +6,15 @@ import { Palette, Style } from "../../../styles";
import { FONT_FAMILY } from "../../../styles/Fonts"; import { FONT_FAMILY } from "../../../styles/Fonts";
import CoinBadge from "./CoinBadge"; import CoinBadge from "./CoinBadge";
const PlaybacksCard = () => { const PlaybacksCard = ({
rank = 1,
title = "Sans titre",
artist = "MusicLand",
coverUrl = null,
onPress = () => null,
}) => {
return ( return (
<Pressable onPress={onPress}>
<BlurView <BlurView
intensity={20} intensity={20}
tint="dark" tint="dark"
@@ -36,10 +43,10 @@ const PlaybacksCard = () => {
fontFamily: FONT_FAMILY.InterSemiBold, fontFamily: FONT_FAMILY.InterSemiBold,
}} }}
> >
1 {rank}
</Text> </Text>
<Image <Image
source={img.placeholder3} source={coverUrl ? { uri: coverUrl } : img.placeholder3}
style={{ width: 67, height: 108, borderRadius: 16 }} style={{ width: 67, height: 108, borderRadius: 16 }}
/> />
<View> <View>
@@ -49,8 +56,9 @@ const PlaybacksCard = () => {
color: Palette.white, color: Palette.white,
fontFamily: FONT_FAMILY.InterMedium, fontFamily: FONT_FAMILY.InterMedium,
}} }}
numberOfLines={1}
> >
Alors on danse {title}
</Text> </Text>
<Text <Text
style={{ style={{
@@ -58,13 +66,15 @@ const PlaybacksCard = () => {
color: Palette.white, color: Palette.white,
fontFamily: FONT_FAMILY.InterRegular, fontFamily: FONT_FAMILY.InterRegular,
}} }}
numberOfLines={1}
> >
Stromae {artist}
</Text> </Text>
</View> </View>
</View> </View>
<CoinBadge /> <CoinBadge />
</BlurView> </BlurView>
</Pressable>
); );
}; };