From e3784651265477b8535f22ccf5eac07a78822c1a Mon Sep 17 00:00:00 2001 From: danis Date: Wed, 21 Jun 2023 08:21:34 +0200 Subject: [PATCH] components RowCustom & SongRow + artist banner --- back/src/song/song.controller.ts | 3 ++ front/components/RowCustom.tsx | 36 ++++++++++++++++ front/components/SongRow.tsx | 69 +++++++++++++++++++++++++++++++ front/views/ArtistDetailsView.tsx | 59 +++++++++++++++----------- 4 files changed, 144 insertions(+), 23 deletions(-) create mode 100644 front/components/RowCustom.tsx create mode 100644 front/components/SongRow.tsx diff --git a/back/src/song/song.controller.ts b/back/src/song/song.controller.ts index 63ac65e..5e69056 100644 --- a/back/src/song/song.controller.ts +++ b/back/src/song/song.controller.ts @@ -26,6 +26,7 @@ import { createReadStream, existsSync } from 'fs'; import { ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger'; import { HistoryService } from 'src/history/history.service'; import { JwtAuthGuard } from 'src/auth/jwt-auth.guard'; +import { IsDefined } from 'class-validator'; @Controller('song') @ApiTags('song') @@ -107,6 +108,7 @@ export class SongController { @Query() filter: Prisma.SongWhereInput, @Query('skip', new DefaultValuePipe(0), ParseIntPipe) skip: number, @Query('take', new DefaultValuePipe(20), ParseIntPipe) take: number, + // @Query('artistId') artistId: number, ): Promise> { try { const ret = await this.songService.songs({ @@ -115,6 +117,7 @@ export class SongController { where: { ...filter, id: filter.id ? +filter.id : undefined, + // artistId: artistId ? +artistId : undefined, }, }); return new Plage(ret, req); diff --git a/front/components/RowCustom.tsx b/front/components/RowCustom.tsx new file mode 100644 index 0000000..f72cded --- /dev/null +++ b/front/components/RowCustom.tsx @@ -0,0 +1,36 @@ +import { useColorScheme } from "react-native"; +import { RootState, useSelector } from "../state/Store"; +import { Box, Pressable } from "native-base"; + +const RowCustom = ( + props: Parameters[0] & { onPress?: () => void } +) => { + const settings = useSelector((state: RootState) => state.settings.local); + const systemColorMode = useColorScheme(); + const colorScheme = settings.colorScheme; + + return ( + + {({ isHovered, isPressed }) => ( + + {props.children} + + )} + + ); +}; + +export default RowCustom; \ No newline at end of file diff --git a/front/components/SongRow.tsx b/front/components/SongRow.tsx new file mode 100644 index 0000000..1924e86 --- /dev/null +++ b/front/components/SongRow.tsx @@ -0,0 +1,69 @@ +import { HStack, Image, Text } from "native-base"; +import Song, { SongWithArtist } from "../models/Song"; +import RowCustom from "./RowCustom"; +import TextButton from "./TextButton"; + + +type SongRowProps = { + song: Song | SongWithArtist; // TODO: remove Song + onPress: () => void; +}; + +const SongRow = ({ song, onPress }: SongRowProps) => { + return ( + + + {song.name} + + + {song.name} + + + {song.artistId ?? "artist"} + + + + + + ); +}; + +export default SongRow; \ No newline at end of file diff --git a/front/views/ArtistDetailsView.tsx b/front/views/ArtistDetailsView.tsx index 4485263..a1358aa 100644 --- a/front/views/ArtistDetailsView.tsx +++ b/front/views/ArtistDetailsView.tsx @@ -1,40 +1,53 @@ -import { VStack, Text, Image, Heading, IconButton, Icon, Container } from 'native-base'; +import { VStack, Text, Box, Image, Heading, IconButton, Icon, Container, Center, useBreakpointValue } from 'native-base'; import { Ionicons } from '@expo/vector-icons'; import { SafeAreaView } from 'react-native'; import { useQuery } from 'react-query'; import LoadingComponent from '../components/Loading'; import API from '../API'; - -const handleFavorite = () => { - -}; +import Song from '../models/Song'; +import SongRow from '../components/SongRow'; +import { useNavigation } from '@react-navigation/native'; const ArtistDetailsView = ({ artistId }: any) => { const { isLoading, data: artistData, error } = useQuery(['artist', artistId], () => API.getArtist(artistId)); + const screenSize = useBreakpointValue({ base: "small", md: "big" }); + const isMobileView = screenSize == "small"; + let songData = [] as Song[]; + const navigation = useNavigation(); if (isLoading) { - return ; + return
; } return ( - - {artistData?.name} - - {artistData?.name} - } - onPress={() => handleFavorite()} - variant="unstyled" - _pressed={{ opacity: 0.6 }} - /> - - + + {artistData?.name} + + Abba + + {songData.map((comp, index) => ( + { + API.createSearchHistoryEntry(comp.name, "song", Date.now()); + navigation.navigate("Song", { songId: comp.id }); + }} + /> + )) + } + + + + ); };