From 2434d5f5df52a150673dd33d686a0bc1377431bc Mon Sep 17 00:00:00 2001 From: GitBluub Date: Tue, 30 May 2023 15:33:54 +0900 Subject: [PATCH] fix: image via props and remove songIllustration function for cover property --- front/API.ts | 8 -------- front/components/ArtistCard.tsx | 2 +- front/components/GenreCard.tsx | 6 +++--- front/components/SearchResult.tsx | 6 +++--- front/components/SongCard.tsx | 1 + front/views/ScoreView.tsx | 2 +- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/front/API.ts b/front/API.ts index 2a27364..26c2575 100644 --- a/front/API.ts +++ b/front/API.ts @@ -228,14 +228,6 @@ export default class API { return "11111"; } - /** - * Retrive a song's midi partition - * @param songId the id to find the song - */ - public static getSongIllustration(songId: number): string { - return `${baseAPIUrl}/song/${songId}/illustration`; - } - public static async getAllSongs(): Promise { let songs = await API.fetch({ route: "/song", diff --git a/front/components/ArtistCard.tsx b/front/components/ArtistCard.tsx index dfc3b44..46e188d 100644 --- a/front/components/ArtistCard.tsx +++ b/front/components/ArtistCard.tsx @@ -18,7 +18,7 @@ const ArtistCard = (props: ArtistCardProps) => { {name} diff --git a/front/components/GenreCard.tsx b/front/components/GenreCard.tsx index 2acc032..348ecf7 100644 --- a/front/components/GenreCard.tsx +++ b/front/components/GenreCard.tsx @@ -5,14 +5,14 @@ import { useTheme } from "native-base"; import { Ionicons } from "@expo/vector-icons"; import API from "../API"; type GenreCardProps = { - icon: string; + image: string; name: string; id: number; onPress: () => void; }; const GenreCard = (props: GenreCardProps) => { - const { icon, name, id } = props; + const { image, name, id } = props; const theme = useTheme(); return ( @@ -29,7 +29,7 @@ const GenreCard = (props: GenreCardProps) => { > diff --git a/front/components/SearchResult.tsx b/front/components/SearchResult.tsx index d5e3217..06acd85 100644 --- a/front/components/SearchResult.tsx +++ b/front/components/SearchResult.tsx @@ -82,7 +82,7 @@ const SongRow = ({ song, onPress }: SongRowProps) => { flexGrow={0} pl={10} style={{ zIndex: 0, aspectRatio: 1, borderRadius: 5 }} - source={{ uri: API.getSongIllustration(song.id) }} + source={{ uri: song.cover }} alt={song.name} /> { content={artistData .slice(0, props?.maxItems ?? artistData.length) .map((a) => ({ - image: a.picture ?? "https://picsum.photos/200", + image: API.getArtistIllustration(a.id), name: a.name, id: a.id, onPress: () => { @@ -257,7 +257,7 @@ const GenreSearchComponent = (props: any) => { content={genreData .slice(0, props?.maxItems ?? genreData.length) .map((g) => ({ - icon: "musical-note-sharp", + image: API.getGenreIllustration(g.id), name: g.name, id: g.id, onPress: () => { diff --git a/front/components/SongCard.tsx b/front/components/SongCard.tsx index 8935c2a..64ec328 100644 --- a/front/components/SongCard.tsx +++ b/front/components/SongCard.tsx @@ -7,6 +7,7 @@ type SongCardProps = { cover: string; name: string; artistName: string; + songId: number; }; const SongCard = (props: SongCardProps) => { diff --git a/front/views/ScoreView.tsx b/front/views/ScoreView.tsx index 0966d3c..88921ab 100644 --- a/front/views/ScoreView.tsx +++ b/front/views/ScoreView.tsx @@ -115,7 +115,7 @@ const ScoreView = ({ artistName: artistRecommendations.find(({ data }) => data?.id == i.artistId) ?.data?.name ?? "", - id: i.id, + songId: i.id, }))} cardComponent={SongCard} heading={