@@ -2,28 +2,204 @@ import React, {FC} from 'react';
22import { StyleSheet } from 'react-native' ;
33import Modal from 'react-native-modal' ;
44import styled from '@emotion/native' ;
5+ import Feather from 'react-native-vector-icons/Feather' ;
6+ import MaterialCommunity from 'react-native-vector-icons/MaterialCommunityIcons' ;
7+ import MaterialIcons from 'react-native-vector-icons/MaterialIcons' ;
8+ import { Album , Artist , Track } from '../../Types' ;
9+ import { useCover } from '../../Hooks/useCover' ;
10+ import SvgMic from '../Icons/Mic' ;
511
612const Container = styled . View `
713 background-color: #000;
8- height: 300px;
14+ height: 420px;
15+ ` ;
16+
17+ const MetadataRow = styled . View `
18+ height: 110px;
19+ width: 100%;
20+ flex-direction: row;
21+ align-items: center;
22+ padding-left: 20px;
23+ background-color: #000;
24+ ` ;
25+
26+ const Separator = styled . View `
27+ height: 1px;
28+ width: 100%;
29+ background-color: #3e3e3ec4;
30+ margin-bottom: 10px;
31+ ` ;
32+
33+ const Cover = styled . Image `
34+ width: 80px;
35+ height: 80px;
36+ ` ;
37+
38+ const NoAlbumCover = styled . View `
39+ width: 80px;
40+ height: 80px;
41+ background-color: #161515;
42+ align-items: center;
43+ justify-content: center;
44+ ` ;
45+
46+ const Title = styled . Text `
47+ color: #fff;
48+ font-family: 'Gilroy-Bold';
49+ font-size: 16px;
50+ ` ;
51+
52+ const ArtistName = styled . Text `
53+ color: #a7a7a9;
54+ font-family: 'Gilroy-Bold';
55+ font-size: 14px;
56+ margin-top: 2px;
57+ ` ;
58+
59+ const MediaInfo = styled . View `
60+ flex-direction: column;
61+ margin-left: 15px;
62+ flex: 1;
63+ ` ;
64+
65+ const IconWrapper = styled . View `
66+ height: 40px;
67+ width: 40px;
68+ justify-content: center;
69+ margin-right: 10px;
70+ ` ;
71+
72+ const Action = styled . TouchableWithoutFeedback `` ;
73+
74+ const ActionWrapper = styled . View `
75+ height: 60px;
76+ width: 100%;
77+ flex-direction: row;
78+ align-items: center;
79+ padding-left: 20px;
80+ background-color: #000;
81+ ` ;
82+
83+ const ActionTitle = styled . Text `
84+ color: #fff;
85+ font-family: 'Gilroy-Bold';
86+ font-size: 16px;
987` ;
1088
1189export type ContextMenuProps = {
1290 isVisible : boolean ;
1391 onClose : ( ) => void ;
92+ item ?: Artist | Album | Track ;
93+ type : 'artist' | 'album' | 'track' | '' ;
94+ onPlayNext : ( item : Album | Track ) => void ;
95+ onAddToPlaylist : ( item : Album | Track ) => void ;
96+ onDownload : ( item : Album | Track ) => void ;
97+ onGoToArtist : ( item : Album | Track ) => void ;
98+ onGoToAlbum : ( item : Album | Track ) => void ;
1499} ;
15100
16- const ContextMenu : FC < ContextMenuProps > = ( { isVisible, onClose} ) => {
101+ const ContextMenu : FC < ContextMenuProps > = props => {
102+ const {
103+ isVisible,
104+ onClose,
105+ onAddToPlaylist,
106+ onDownload,
107+ onGoToAlbum,
108+ onGoToArtist,
109+ onPlayNext,
110+ item,
111+ type,
112+ } = props ;
113+ const itemCover = {
114+ artist : ( item as Artist ) ?. picture ,
115+ album : ( item as Album ) ?. cover ,
116+ track : ( item as Track ) ?. cover ,
117+ '' : undefined ,
118+ } ;
119+ const cover = useCover ( itemCover [ type ] ) ;
17120 return (
18121 < Modal
19122 isVisible = { isVisible }
20123 backdropOpacity = { 0.03 }
21124 onBackdropPress = { onClose }
22125 onSwipeComplete = { onClose }
23- swipeThreshold = { 500 }
24126 swipeDirection = { [ 'down' ] }
25127 style = { styles . modal } >
26- < Container > </ Container >
128+ < Container >
129+ < MetadataRow >
130+ { itemCover [ type ] && < Cover source = { { uri : cover } } /> }
131+ { ! itemCover [ type ] && (
132+ < NoAlbumCover >
133+ < Feather name = "disc" size = { 40 } color = "#a7a7a9" />
134+ </ NoAlbumCover >
135+ ) }
136+ < MediaInfo >
137+ < Title numberOfLines = { 1 } ellipsizeMode = "tail" >
138+ { type === 'artist'
139+ ? ( item as Artist ) ?. name
140+ : ( item as Album ) ?. title }
141+ </ Title >
142+ < ArtistName numberOfLines = { 1 } ellipsizeMode = "tail" >
143+ { type === 'artist'
144+ ? ( item as Artist ) ?. name
145+ : ( item as Album ) ?. artist }
146+ </ ArtistName >
147+ </ MediaInfo >
148+ </ MetadataRow >
149+ < Separator />
150+ < Action onPress = { ( ) => onPlayNext ( item as Album | Track ) } >
151+ < ActionWrapper >
152+ < IconWrapper >
153+ < MaterialIcons name = "playlist-play" size = { 31 } color = "#ab28fc" />
154+ </ IconWrapper >
155+ < ActionTitle > Play next</ ActionTitle >
156+ </ ActionWrapper >
157+ </ Action >
158+ { ( type === 'track' || type === 'album' ) && (
159+ < >
160+ < Action onPress = { ( ) => onDownload ( item as Album | Track ) } >
161+ < ActionWrapper >
162+ < IconWrapper >
163+ < MaterialCommunity
164+ name = "download"
165+ size = { 25 }
166+ color = "#ab28fc"
167+ />
168+ </ IconWrapper >
169+ < ActionTitle > Download</ ActionTitle >
170+ </ ActionWrapper >
171+ </ Action >
172+ < Action onPress = { ( ) => onAddToPlaylist ( item as Album | Track ) } >
173+ < ActionWrapper >
174+ < IconWrapper >
175+ < MaterialIcons
176+ name = "playlist-add"
177+ size = { 28 }
178+ color = "#ab28fc"
179+ />
180+ </ IconWrapper >
181+ < ActionTitle > Add to playlist</ ActionTitle >
182+ </ ActionWrapper >
183+ </ Action >
184+ < Action onPress = { ( ) => onGoToAlbum ( item as Album | Track ) } >
185+ < ActionWrapper >
186+ < IconWrapper >
187+ < Feather name = "disc" size = { 24 } color = "#ab28fc" />
188+ </ IconWrapper >
189+ < ActionTitle > Go to Album</ ActionTitle >
190+ </ ActionWrapper >
191+ </ Action >
192+ < Action onPress = { ( ) => onGoToArtist ( item as Album | Track ) } >
193+ < ActionWrapper >
194+ < IconWrapper >
195+ < SvgMic height = { 26 } width = { 26 } fill = "#ab28fc" />
196+ </ IconWrapper >
197+ < ActionTitle > Go to Artist</ ActionTitle >
198+ </ ActionWrapper >
199+ </ Action >
200+ </ >
201+ ) }
202+ </ Container >
27203 </ Modal >
28204 ) ;
29205} ;
0 commit comments