Duration component
This commit is contained in:
@@ -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 (
|
||||||
|
<Box flexDirection={'row'} >
|
||||||
|
<Icon as={MaterialIcons} name="timer" color="coolGray.800" _dark={{
|
||||||
|
color: "warmGray.50"
|
||||||
|
}} />
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
flexShrink: 0,
|
||||||
|
}}
|
||||||
|
fontSize={'sm'}
|
||||||
|
>
|
||||||
|
{`${minutes}'${seconds}` ?? '--\'--'}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DurationComponent;
|
||||||
@@ -4,6 +4,7 @@ import TextButton from './TextButton';
|
|||||||
import { LikedSongWithDetails } from '../models/LikedSong';
|
import { LikedSongWithDetails } from '../models/LikedSong';
|
||||||
import { MaterialIcons } from '@expo/vector-icons';
|
import { MaterialIcons } from '@expo/vector-icons';
|
||||||
import API from '../API';
|
import API from '../API';
|
||||||
|
import DurationComponent from './DurationComponent';
|
||||||
|
|
||||||
type FavSongRowProps = {
|
type FavSongRowProps = {
|
||||||
FavSong: LikedSongWithDetails; // TODO: remove Song
|
FavSong: LikedSongWithDetails; // TODO: remove Song
|
||||||
@@ -54,6 +55,7 @@ const FavSongRow = ({ FavSong, onPress }: FavSongRowProps) => {
|
|||||||
>
|
>
|
||||||
{FavSong.addedDate.toLocaleDateString()}
|
{FavSong.addedDate.toLocaleDateString()}
|
||||||
</Text>
|
</Text>
|
||||||
|
<DurationComponent length={FavSong.details.details.length} />
|
||||||
</HStack>
|
</HStack>
|
||||||
<IconButton
|
<IconButton
|
||||||
colorScheme="primary"
|
colorScheme="primary"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import Song, { SongWithArtist } from '../models/Song';
|
|||||||
import RowCustom from './RowCustom';
|
import RowCustom from './RowCustom';
|
||||||
import TextButton from './TextButton';
|
import TextButton from './TextButton';
|
||||||
import { MaterialIcons } from '@expo/vector-icons';
|
import { MaterialIcons } from '@expo/vector-icons';
|
||||||
|
import DurationComponent from './DurationComponent';
|
||||||
|
|
||||||
type SongRowProps = {
|
type SongRowProps = {
|
||||||
song: Song | SongWithArtist; // TODO: remove Song
|
song: Song | SongWithArtist; // TODO: remove Song
|
||||||
@@ -11,26 +12,6 @@ type SongRowProps = {
|
|||||||
handleLike: (state: boolean, songId: number) => Promise<void>;
|
handleLike: (state: boolean, songId: number) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DurationInfoProps = {
|
|
||||||
length: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
const DurationInfo = ({ length }: DurationInfoProps) => {
|
|
||||||
const minutes = Math.floor(length / 60);
|
|
||||||
const seconds = Math.round(length - minutes * 60);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
flexShrink: 0,
|
|
||||||
}}
|
|
||||||
fontSize={'sm'}
|
|
||||||
>
|
|
||||||
{`${minutes}'${seconds}` ?? '--.--'}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const SongRow = ({ song, onPress, handleLike, isLiked }: SongRowProps) => {
|
const SongRow = ({ song, onPress, handleLike, isLiked }: SongRowProps) => {
|
||||||
return (
|
return (
|
||||||
<RowCustom width={'100%'}>
|
<RowCustom width={'100%'}>
|
||||||
@@ -75,7 +56,8 @@ const SongRow = ({ song, onPress, handleLike, isLiked }: SongRowProps) => {
|
|||||||
>
|
>
|
||||||
{song.artistId ?? 'artist'}
|
{song.artistId ?? 'artist'}
|
||||||
</Text>
|
</Text>
|
||||||
<DurationInfo length={song.details.length} />
|
{/* <DurationInfo length={song.details.length} /> */}
|
||||||
|
<DurationComponent length={song.details.length} />
|
||||||
</HStack>
|
</HStack>
|
||||||
<IconButton
|
<IconButton
|
||||||
colorScheme="rose"
|
colorScheme="rose"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import API from '../API';
|
|||||||
import TextButton from '../components/TextButton';
|
import TextButton from '../components/TextButton';
|
||||||
import { RouteProps, useNavigation } from '../Navigation';
|
import { RouteProps, useNavigation } from '../Navigation';
|
||||||
import ScoreGraph from '../components/ScoreGraph';
|
import ScoreGraph from '../components/ScoreGraph';
|
||||||
|
import DurationComponent from '../components/DurationComponent';
|
||||||
|
|
||||||
interface SongLobbyProps {
|
interface SongLobbyProps {
|
||||||
// The unique identifier to find a song
|
// The unique identifier to find a song
|
||||||
@@ -66,6 +67,7 @@ const SongLobbyView = (props: RouteProps<SongLobbyProps>) => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Text>
|
</Text>
|
||||||
|
<DurationComponent length={songQuery.data?.details.length} />
|
||||||
<TextButton
|
<TextButton
|
||||||
translate={{ translationKey: 'playBtn' }}
|
translate={{ translationKey: 'playBtn' }}
|
||||||
width="auto"
|
width="auto"
|
||||||
|
|||||||
Reference in New Issue
Block a user