From 9af2531c8e7d69fa66953d84b47a0b33017bb4d6 Mon Sep 17 00:00:00 2001 From: Shivam Date: Mon, 9 Sep 2019 15:20:57 +0530 Subject: [PATCH] react router model view added page loader changed --- public/index.html | 24 ++-- src/components/App.js | 2 +- src/components/AppContainer.js | 4 +- src/components/CurrentSection.js | 148 ++++++++++++++--------- src/components/player/MainPlayer.js | 6 +- src/components/player/MiniMusicArt.js | 2 +- src/components/player/MiniMusicStyle.css | 8 ++ src/components/player/MusicArt.js | 2 +- 8 files changed, 123 insertions(+), 73 deletions(-) diff --git a/public/index.html b/public/index.html index 8dbcef0..1f1e8a6 100644 --- a/public/index.html +++ b/public/index.html @@ -31,7 +31,8 @@ bottom: 0; } - .full-page-loader > img { + .full-page-loader > svg { + width: 200px; animation: 1.8s infinite heartbeat; } @@ -43,7 +44,7 @@ transform: scale(1.05); } 50% { - transform: scale(1); + transform: scale(1) rotate(360deg); } 75% { transform: scale(1.05); @@ -62,11 +63,20 @@

- Ylight Logo +
diff --git a/src/components/App.js b/src/components/App.js index 819088c..ff7571a 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -14,4 +14,4 @@ function App() { export default App; -// this do not works \ No newline at end of file +// this do not works \ No newline at end of file diff --git a/src/components/AppContainer.js b/src/components/AppContainer.js index 45d67da..a0e909d 100644 --- a/src/components/AppContainer.js +++ b/src/components/AppContainer.js @@ -65,8 +65,8 @@ const AppContainer = () => { > - - + + diff --git a/src/components/CurrentSection.js b/src/components/CurrentSection.js index 3269d00..d4694fc 100644 --- a/src/components/CurrentSection.js +++ b/src/components/CurrentSection.js @@ -42,7 +42,7 @@ import { import SettingsPage from "./sections/SettingsPage"; // import the db from save song - +import MainPlayer from "../components/player/MainPlayer"; // pages const LoginPage = lazy(() => import("./LoginPage")); const RenderDatabase = lazy(() => import("./RenderDatabase")); @@ -85,6 +85,7 @@ const CustomTabs = withStyles({ })(Tab); let deferredPrompt = undefined; +let previousLocation, modifiedLocation; window.addEventListener("beforeinstallprompt", e => { // Stash the event so it can be triggered later. @@ -92,9 +93,7 @@ window.addEventListener("beforeinstallprompt", e => { }); const CurrentSection = ({ history, location }) => { - const [{ currentVideoSnippet, searchResult }] = useContext( - GlobalContext - ); + const [{ currentVideoSnippet, searchResult }] = useContext(GlobalContext); console.log(currentVideoSnippet); const [songsHistoryState, setSongsHistory] = useState([]); @@ -159,6 +158,14 @@ const CurrentSection = ({ history, location }) => { if (isThisNewUser === "no") { setRedirectState(true); } + // if this is not a new user redirect it to home + previousLocation = location; + const unlisten = history.listen(location => { + if (location.pathname !== "/play") { + previousLocation = location; + console.log(previousLocation); + } + }); }, []); useEffect(() => { @@ -166,8 +173,20 @@ const CurrentSection = ({ history, location }) => { if (redirectState && history.location.pathname === "/") { history.replace("/home"); } + + // if the location is not play then we will push new location }, [setRedirectState, history, redirectState]); + + + const checkPrevLocation = () => { + if (location.pathname === "/play") { + return previousLocation; + } else { + return location; + } + }; + // we will load the homepage with all the playlists const continueToHome = () => { localStorage.setItem("isThisNew", "no"); @@ -187,67 +206,82 @@ const CurrentSection = ({ history, location }) => { }); } }; + + const returnMainPlayer = props => { + // we will return the main player if the path is not the "/" + + if (window.location.pathname !== "/") { + return ; + } else { + return null; + } + }; + // the set tab value will keep the tab active on their route // there are 4 tabs so there will be 3 indexes return (
- { - return ; - }} - /> - } - /> - { - setTabValue(0); - return ; - }} - /> - { - setTabValue(1); - return ; - }} - /> - { - setTabValue(2); - return ; - }} - /> - { - setTabValue(3); + + { + return ; + }} + /> + } + /> + { + setTabValue(0); + return ; + }} + /> + { + setTabValue(1); + return ; + }} + /> + { + setTabValue(2); + return ; + }} + /> + { + setTabValue(3); - return ; - }} - /> - { - window.location.replace( - "https://play.google.com/store/apps/details?id=com.ylightmusic.app" - ); - return
Redirecting you to play store
; - }} - /> + return ; + }} + /> + { + window.location.replace( + "https://play.google.com/store/apps/details?id=com.ylightmusic.app" + ); + return
Redirecting you to play store
; + }} + /> + + + - - + + + +
+ returnMainPlayer(props)} /> - - -
{/* if the player is on then return 100px else 50px*/} diff --git a/src/components/player/MainPlayer.js b/src/components/player/MainPlayer.js index 8687034..d2a9184 100644 --- a/src/components/player/MainPlayer.js +++ b/src/components/player/MainPlayer.js @@ -309,7 +309,8 @@ const MainPlayer = ({ location, history }) => { setMinimized(true); history.push({ pathname: "/play", - search: `?id=${currentVideoSnippet.id}` + search: `?id=${currentVideoSnippet.id}`, + state: { modal: true } }); } }; @@ -565,9 +566,6 @@ const MainPlayer = ({ location, history }) => { }} id="audio-element" onLoadedData={updateSongDB} - onCanPlay={() => { - setAudioState("loaded"); - }} // crossOrigin="anonymous" onPlay={() => setAudioState("playing")} onPlaying={() => setAudioState("playing")} diff --git a/src/components/player/MiniMusicArt.js b/src/components/player/MiniMusicArt.js index 2fccdad..2525bc1 100644 --- a/src/components/player/MiniMusicArt.js +++ b/src/components/player/MiniMusicArt.js @@ -20,7 +20,7 @@ const MiniMuiscArt = ({ playPause, data, playNext, emptyPlayer }) => {
- {data.title.slice(0, 14)} + {data.title} {data.channelTitle}
diff --git a/src/components/player/MiniMusicStyle.css b/src/components/player/MiniMusicStyle.css index 3e50f1d..1912870 100644 --- a/src/components/player/MiniMusicStyle.css +++ b/src/components/player/MiniMusicStyle.css @@ -5,6 +5,7 @@ transform: translate3d(0, 0, 0); } + .miniArtContainer { width: 90px; height: 90px; @@ -39,6 +40,13 @@ div.details { margin: 5px 8px; } +.mainContainer .details * { + width: 35%; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + div.buttons { position: fixed; diff --git a/src/components/player/MusicArt.js b/src/components/player/MusicArt.js index 29738f2..74f9229 100644 --- a/src/components/player/MusicArt.js +++ b/src/components/player/MusicArt.js @@ -142,7 +142,7 @@ const MusicArt = ({ data, rating, audioEl }) => { />
- + {shortTitle(data)}