From 5395bbb03a78b06f8f3a16d4eaa39f3debeff402 Mon Sep 17 00:00:00 2001 From: danis Date: Mon, 25 Sep 2023 14:24:08 +0200 Subject: [PATCH] Duration component --- front/components/DurationComponent.tsx | 29 ++++++++++++++++++++++++++ front/components/FavSongRow.tsx | 2 ++ front/components/SongRow.tsx | 24 +++------------------ front/views/SongLobbyView.tsx | 2 ++ 4 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 front/components/DurationComponent.tsx diff --git a/front/components/DurationComponent.tsx b/front/components/DurationComponent.tsx new file mode 100644 index 0000000..87ac0e6 --- /dev/null +++ b/front/components/DurationComponent.tsx @@ -0,0 +1,29 @@ +import { Box, Icon, Text } from 'native-base'; +import { MaterialIcons } from '@expo/vector-icons'; + +type DurationComponentProps = { + length: number; +}; + +const DurationComponent = ({ length }: DurationComponentProps) => { + const minutes = Math.floor(length / 60); + const seconds = Math.round(length - minutes * 60); + + return ( + + + + {`${minutes}'${seconds}` ?? '--\'--'} + + + ); +}; + +export default DurationComponent; \ No newline at end of file diff --git a/front/components/FavSongRow.tsx b/front/components/FavSongRow.tsx index c015b2a..db1b060 100644 --- a/front/components/FavSongRow.tsx +++ b/front/components/FavSongRow.tsx @@ -4,6 +4,7 @@ import TextButton from './TextButton'; import { LikedSongWithDetails } from '../models/LikedSong'; import { MaterialIcons } from '@expo/vector-icons'; import API from '../API'; +import DurationComponent from './DurationComponent'; type FavSongRowProps = { FavSong: LikedSongWithDetails; // TODO: remove Song @@ -54,6 +55,7 @@ const FavSongRow = ({ FavSong, onPress }: FavSongRowProps) => { > {FavSong.addedDate.toLocaleDateString()} + Promise; }; -type DurationInfoProps = { - length: number; -}; - -const DurationInfo = ({ length }: DurationInfoProps) => { - const minutes = Math.floor(length / 60); - const seconds = Math.round(length - minutes * 60); - - return ( - - {`${minutes}'${seconds}` ?? '--.--'} - - ); -}; - const SongRow = ({ song, onPress, handleLike, isLiked }: SongRowProps) => { return ( @@ -75,7 +56,8 @@ const SongRow = ({ song, onPress, handleLike, isLiked }: SongRowProps) => { > {song.artistId ?? 'artist'} - + {/* */} + ) => { } /> +