Skip to content

Commit 3c4a69c

Browse files
committed
[mobile] update ContextMenu
1 parent 50237b8 commit 3c4a69c

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

mobile/src/Components/ContextMenu/ContextMenu.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,25 @@ export type ContextMenuProps = {
9191
onClose: () => void;
9292
item?: Artist | Album | Track;
9393
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;
9499
};
95100

96-
const ContextMenu: FC<ContextMenuProps> = ({
97-
isVisible,
98-
onClose,
99-
item,
100-
type,
101-
}) => {
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;
102113
const itemCover = {
103114
artist: (item as Artist)?.picture,
104115
album: (item as Album)?.cover,
@@ -136,7 +147,7 @@ const ContextMenu: FC<ContextMenuProps> = ({
136147
</MediaInfo>
137148
</MetadataRow>
138149
<Separator />
139-
<Action>
150+
<Action onPress={() => onPlayNext(item as Album | Track)}>
140151
<ActionWrapper>
141152
<IconWrapper>
142153
<MaterialIcons name="playlist-play" size={31} color="#ab28fc" />
@@ -146,7 +157,7 @@ const ContextMenu: FC<ContextMenuProps> = ({
146157
</Action>
147158
{(type === 'track' || type === 'album') && (
148159
<>
149-
<Action>
160+
<Action onPress={() => onDownload(item as Album | Track)}>
150161
<ActionWrapper>
151162
<IconWrapper>
152163
<MaterialCommunity
@@ -158,7 +169,7 @@ const ContextMenu: FC<ContextMenuProps> = ({
158169
<ActionTitle>Download</ActionTitle>
159170
</ActionWrapper>
160171
</Action>
161-
<Action>
172+
<Action onPress={() => onAddToPlaylist(item as Album | Track)}>
162173
<ActionWrapper>
163174
<IconWrapper>
164175
<MaterialIcons
@@ -170,15 +181,15 @@ const ContextMenu: FC<ContextMenuProps> = ({
170181
<ActionTitle>Add to playlist</ActionTitle>
171182
</ActionWrapper>
172183
</Action>
173-
<Action>
184+
<Action onPress={() => onGoToAlbum(item as Album | Track)}>
174185
<ActionWrapper>
175186
<IconWrapper>
176187
<Feather name="disc" size={24} color="#ab28fc" />
177188
</IconWrapper>
178189
<ActionTitle>Go to Album</ActionTitle>
179190
</ActionWrapper>
180191
</Action>
181-
<Action>
192+
<Action onPress={() => onGoToArtist(item as Album | Track)}>
182193
<ActionWrapper>
183194
<IconWrapper>
184195
<SvgMic height={26} width={26} fill="#ab28fc" />

mobile/src/Components/ContextMenu/ContextMenuWithData.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {FC} from 'react';
22
import ContextMenu from './ContextMenu';
33
import {useRecoilState} from 'recoil';
44
import {contextMenuState} from './ContextMenuState';
5+
import {Album, Track} from '../../Types';
56

67
const ContextMenuWithData: FC = () => {
78
const [contextMenu, setContextMenu] = useRecoilState(contextMenuState);
@@ -11,12 +12,38 @@ const ContextMenuWithData: FC = () => {
1112
visible: false,
1213
});
1314
};
15+
const onPlayNext = (item: Album | Track) => {
16+
onClose();
17+
console.log(item);
18+
};
19+
const onDownload = (item: Album | Track) => {
20+
onClose();
21+
console.log(item);
22+
};
23+
const onAddToPlaylist = (item: Album | Track) => {
24+
onClose();
25+
console.log(item);
26+
};
27+
const onGoToArtist = (item: Album | Track) => {
28+
onClose();
29+
console.log(item);
30+
};
31+
const onGoToAlbum = (item: Album | Track) => {
32+
onClose();
33+
console.log(item);
34+
};
35+
1436
return (
1537
<ContextMenu
1638
isVisible={contextMenu.visible}
1739
onClose={onClose}
1840
item={contextMenu.item}
1941
type={contextMenu.type}
42+
onPlayNext={onPlayNext}
43+
onDownload={onDownload}
44+
onAddToPlaylist={onAddToPlaylist}
45+
onGoToArtist={onGoToArtist}
46+
onGoToAlbum={onGoToAlbum}
2047
/>
2148
);
2249
};

0 commit comments

Comments
 (0)