playback cards
This commit is contained in:
@@ -22,6 +22,16 @@ const HitParade = () => {
|
||||
listener: 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 (
|
||||
<Page backgroundImg={background.hitParadeBG} headerType="NONE">
|
||||
@@ -114,8 +124,17 @@ const HitParade = () => {
|
||||
gap: 10,
|
||||
paddingBottom: responsiveHeight(20),
|
||||
}}
|
||||
data={Array.from({ length: 5 })}
|
||||
renderItem={() => <PlaybacksCard />}
|
||||
data={Array.isArray(topPlaybacks) ? topPlaybacks : []}
|
||||
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" && (
|
||||
|
||||
@@ -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 { BlurView } from "expo-blur";
|
||||
import { img } from "../../../assets";
|
||||
@@ -6,8 +6,15 @@ import { Palette, Style } from "../../../styles";
|
||||
import { FONT_FAMILY } from "../../../styles/Fonts";
|
||||
import CoinBadge from "./CoinBadge";
|
||||
|
||||
const PlaybacksCard = () => {
|
||||
const PlaybacksCard = ({
|
||||
rank = 1,
|
||||
title = "Sans titre",
|
||||
artist = "MusicLand",
|
||||
coverUrl = null,
|
||||
onPress = () => null,
|
||||
}) => {
|
||||
return (
|
||||
<Pressable onPress={onPress}>
|
||||
<BlurView
|
||||
intensity={20}
|
||||
tint="dark"
|
||||
@@ -36,10 +43,10 @@ const PlaybacksCard = () => {
|
||||
fontFamily: FONT_FAMILY.InterSemiBold,
|
||||
}}
|
||||
>
|
||||
1
|
||||
{rank}
|
||||
</Text>
|
||||
<Image
|
||||
source={img.placeholder3}
|
||||
source={coverUrl ? { uri: coverUrl } : img.placeholder3}
|
||||
style={{ width: 67, height: 108, borderRadius: 16 }}
|
||||
/>
|
||||
<View>
|
||||
@@ -49,8 +56,9 @@ const PlaybacksCard = () => {
|
||||
color: Palette.white,
|
||||
fontFamily: FONT_FAMILY.InterMedium,
|
||||
}}
|
||||
numberOfLines={1}
|
||||
>
|
||||
Alors on danse
|
||||
{title}
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
@@ -58,13 +66,15 @@ const PlaybacksCard = () => {
|
||||
color: Palette.white,
|
||||
fontFamily: FONT_FAMILY.InterRegular,
|
||||
}}
|
||||
numberOfLines={1}
|
||||
>
|
||||
Stromae
|
||||
{artist}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<CoinBadge />
|
||||
</BlurView>
|
||||
</Pressable>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user