diff --git a/src/components/menu.js b/src/components/menu.js index 3b11aed..36f8b4b 100644 --- a/src/components/menu.js +++ b/src/components/menu.js @@ -38,7 +38,7 @@ export const Menu = (props) => { navigation.navigate("Playlist")} + onPress={() => navigation.navigate("Playlist", { tabIndex: 0 })} /> {/* navigation.navigate("Albums")} diff --git a/src/screens/playlist.js b/src/screens/playlist.js index f31c9d8..910ad56 100644 --- a/src/screens/playlist.js +++ b/src/screens/playlist.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { ScrollView, Text, View } from "react-native"; import Toast from "react-native-root-toast"; import { @@ -28,7 +28,7 @@ import { IconPress, TextInputIcon } from "../components/buttons"; import PromptDialog from "../components/prompt"; import Playlists from "../components/playlists"; -export const Playlist = ({ navigation }) => { +export const Playlist = ({ navigation, route }) => { const [order, setOrder] = useState(0); const [tabIndex, setTabIndex] = useState(0); const [filter, setFilter] = useState(""); @@ -36,6 +36,11 @@ export const Playlist = ({ navigation }) => { const [openDialogVisible, setOpenDialogVisible] = useState(false); const { playlist, setPlaylist, loop, setLoop, songs } = useAppContext(); + useEffect(() => { + if (tabIndex !== route.params?.tabIndex) + setTabIndex(route.params?.tabIndex); + }, [route.params]); + const toggleSong = ({ name, no }) => { if (playlist.list.find((n) => n === no)) { setPlaylist({