diff --git a/src/components/song.js b/src/components/song.js index 8b692b7..c47c9b1 100644 --- a/src/components/song.js +++ b/src/components/song.js @@ -16,11 +16,12 @@ export const Song = ({ song, openUrl }) => ( export const SongItem = ({ song, selected, - toggle, + onLeftOpen, + onRightOpen, image = true, - play = false, + onPress = false, }) => ( - toggle(song.no)} onPress={play}> + {image && ( diff --git a/src/screens/playlist.js b/src/screens/playlist.js index d8967b2..7309791 100644 --- a/src/screens/playlist.js +++ b/src/screens/playlist.js @@ -1,10 +1,11 @@ import React, { useState } from "react"; -import { FlatList, View } from "react-native"; +import { Alert, FlatList } from "react-native"; import Player from "../components/player"; import { SongItem, SongDetail } from "../components/song"; import { deviceWidth } from "../helpers/styles"; import { getSongs } from "../api/data"; import { AnimatedTabView, Tabs, TabViewItem } from "../components/tabs"; +import { ScrollView } from "react-native-gesture-handler"; export const Playlist = ({ navigation }) => { const [playlist, setPlaylist] = useState([]); @@ -26,11 +27,13 @@ export const Playlist = ({ navigation }) => { navigation.navigate("Page", { url }); }; - const toggleSong = (no) => { + const toggleSong = ({ name, no }) => { if (playlist.find((n) => n === no)) { removeSong(no); + Alert.alert(`${name} listeden kaldırıldı`); } else { addSong(no); + Alert.alert(`${name} listeye eklendi`); } }; @@ -50,21 +53,22 @@ export const Playlist = ({ navigation }) => { const song = songs.filter((s) => s.no === playlist[currentIndex])[0]; const PlaylistDetail = () => ( - + <> item} + style={{ width: deviceWidth }} data={playlist} renderItem={({ item, index }) => ( item === s.no)[0]} selected={item === song.no} - toggle={toggleSong} - play={() => setCurrentIndex(index)} + onRightOpen={() => toggleSong(song)} + onPress={() => setCurrentIndex(index)} /> )} /> - + ); const Songlist = () => ( @@ -76,7 +80,7 @@ export const Playlist = ({ navigation }) => { no === item.no) !== undefined} - toggle={toggleSong} + onLeftOpen={() => toggleSong(item)} /> )} />