Skip to content

Commit

Permalink
Implemented search feature (complete)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0is1 committed Sep 30, 2024
1 parent 28f355e commit 745c7aa
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/screens/AlbumsScreen/components/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useNavigation } from '@react-navigation/native';
const Card = ({ albumData, index }) => {
const { setPlaylist } = useContext(PlayerContext);
const navigation = useNavigation();
albumData.title = albumData.title ? albumData.title : albumData.name;
return (
<TouchableOpacity onPress={() => handleAlbum({
albumData: albumData,
Expand All @@ -18,7 +19,7 @@ const Card = ({ albumData, index }) => {
navigation: navigation
})} style={[styles.card, { height: index % 3 === 0 ? 250 : 180 }]}>
<ImageBackground
source={{ uri: albumData.image.replace("150x150", "500x500") }}
source={{ uri: albumData.image.replace("150x150", "500x500").replace("50x50", "500x500") }}
style={styles.image}
imageStyle={styles.imageOverlay}
>
Expand Down
4 changes: 2 additions & 2 deletions src/screens/SearchScreen/SearchScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SearchScreen = () => {
clearTimeout(timer);
}
const newTimer = setTimeout(async () => {
const response = await serviceProvider.getSearch(searchInput, 1, searchType);
const response = await serviceProvider.getSearch(encodeURIComponent(searchInput), 1, searchType);
setResp(response);
}, 1000);
setTimer(newTimer);
Expand All @@ -37,7 +37,7 @@ const SearchScreen = () => {
<View>
<Navbar setSearchInput={setSearchInput} />
<ModeSelector setSearchType={setSearchType} searchType={searchType} />
<SearchList searchData={resp}/>
<SearchList searchData={!searchInput?resp:resp.results}/>
</View>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SearchScreen/components/ModeSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ModeSelector = ({ setSearchType, searchType }) => {
{ label: "Playlists", value: 0 },
{ label: "Songs", value: 1 },
{ label: "Albums", value: 2 },
{ label: "Artists", value: 3 }
{ label: "Artists", value: 4 }
];

return (
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SearchScreen/components/SearchList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StyleSheet, Text, ScrollView } from 'react-native'
import React from 'react'
import MasonryList from '@react-native-seoul/masonry-list';
import Card from "../../AlbumsScreen/components/Card";
const SearchList = ({ searchData }) => {
const SearchList = ({ searchData }) => {
const renderCard = ({ item, index }) => (
<Card albumData={item} index={index} />
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/albumParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const handleAlbum = async ({
albumCover: data.image.replace("150x150", "500x500"),
items: data.topSongs.map((item, i) => {
return {
songName: item.album,
songName: item.song,
duration: item.duration,
songCover: item.image.replace("150x150", "500x500"),
playUrl: item.encrypted_media_url,
Expand Down

0 comments on commit 745c7aa

Please sign in to comment.