From 27f49fc8e8411ab22cd9f55987067fc5eba8dd3e Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Fri, 17 Dec 2021 18:19:17 -0800 Subject: [PATCH 01/12] beginning of adding history routing --- resources/cider-ui/index.js | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/resources/cider-ui/index.js b/resources/cider-ui/index.js index 86d691aa..d7263fa1 100644 --- a/resources/cider-ui/index.js +++ b/resources/cider-ui/index.js @@ -233,7 +233,8 @@ const app = new Vue({ pageHistory: [], songstest: false, hangtimer: null, - selectedMediaItems: [] + selectedMediaItems: [], + routes: ["browse", "listen_now", "radio"] }, watch: { page: () => { @@ -257,7 +258,7 @@ const app = new Vue({ this.mk.authorize() this.$forceUpdate() this.mk.privateEnabled = true - this.platform = ipcRenderer.sendSync('cider-platform'); + // this.platform = ipcRenderer.sendSync('cider-platform'); // Set profile name this.chrome.userinfo = await this.mkapi("personalSocialProfile", false, "") // API Fallback @@ -356,6 +357,9 @@ const app = new Vue({ self.playlists.listing = res.data }) document.body.removeAttribute("loading") + if(window.location.hash != "") { + this.appRoute(window.location.hash) + } }, invokeDrawer(panel) { if(this.drawer.panel == panel && this.drawer.open) { @@ -541,6 +545,29 @@ const app = new Vue({ } return hash; }, + appRoute(route) { + if(route == "" || route == "#" || route == "/") { + return; + } + route = route.replace(/#/g, "") + // if the route contains does not include a / then route to the page directly + if (route.indexOf("/") == -1) { + this.page = route + window.location.hash = `${page}/${id}` + return + } + let hash = route.split("/") + let page = hash[0] + let id = hash[1] + console.log(`page: ${page} id: ${id}`) + this.routeView({ + kind: page, + id: id, + attributes: { + playParams: {kind: page, id: id} + } + }) + }, routeView(item) { let self = this @@ -575,12 +602,14 @@ const app = new Vue({ } document.querySelector("#app-content").scrollTop = 0 } + window.location.hash = `${kind}/${id}` }, async getNowPlayingItemDetailed(target) { let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], {"include[songs]": "albums,artists"}); app.searchAndNavigate(u, target) }, async searchAndNavigate(item, target) { + let self = this app.tmpVar = item; switch (target) { case "artist": @@ -615,7 +644,7 @@ const app = new Vue({ } console.log(artistId); if (artistId != "") - app.getArtistFromID(artistId); + self.appRoute(`artist/${artistId}`) break; case "album": let albumId = ''; @@ -642,8 +671,7 @@ const app = new Vue({ } } if (albumId != "") { - app.getTypeFromID("album", albumId, false); - app.page = "album_" + albumId; + self.appRoute(`album/${albumId}`) } break; case "recordLabel": @@ -668,7 +696,6 @@ const app = new Vue({ } if (labelId != "") { app.showingPlaylist = [] - await app.getTypeFromID("recordLabel", labelId, false, {views: 'top-releases,latest-releases,top-artists'}); app.page = "recordLabel_" + labelId; } @@ -1818,6 +1845,11 @@ app.hangtimer = setTimeout(()=>{ } }, 10000) +// add event listener for when window.location.hash changes +window.addEventListener("hashchange", function () { + app.appRoute(window.location.hash) +}); + document.addEventListener('musickitloaded', function () { // MusicKit global is now defined function initMusicKit() { From 832e0f75bf78164a9c745a088ee8abc9583e972d Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Fri, 17 Dec 2021 18:25:30 -0800 Subject: [PATCH 02/12] routes --- resources/cider-ui/index.js | 2 +- resources/cider-ui/views/main.ejs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/cider-ui/index.js b/resources/cider-ui/index.js index d7263fa1..8e207a23 100644 --- a/resources/cider-ui/index.js +++ b/resources/cider-ui/index.js @@ -553,7 +553,7 @@ const app = new Vue({ // if the route contains does not include a / then route to the page directly if (route.indexOf("/") == -1) { this.page = route - window.location.hash = `${page}/${id}` + window.location.hash = this.page return } let hash = route.split("/") diff --git a/resources/cider-ui/views/main.ejs b/resources/cider-ui/views/main.ejs index 9e950199..0f1d3471 100644 --- a/resources/cider-ui/views/main.ejs +++ b/resources/cider-ui/views/main.ejs @@ -174,7 +174,7 @@ @@ -456,7 +456,7 @@ From e2dc9e4c0a7ca3c43b998251c439cda9d38c9562 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Fri, 17 Dec 2021 18:41:00 -0800 Subject: [PATCH 03/12] added navigation bar, always present at the moment --- resources/cider-ui/style.less | 41 +++++++++++++++++++ resources/cider-ui/views/main.ejs | 4 ++ resources/cider-ui/views/svg/chevron-left.svg | 1 + .../cider-ui/views/svg/chevron-right.svg | 1 + 4 files changed, 47 insertions(+) create mode 100644 resources/cider-ui/views/svg/chevron-left.svg create mode 100644 resources/cider-ui/views/svg/chevron-right.svg diff --git a/resources/cider-ui/style.less b/resources/cider-ui/style.less index c4bb6830..7ea4e4ce 100644 --- a/resources/cider-ui/style.less +++ b/resources/cider-ui/style.less @@ -19,6 +19,7 @@ --keyColor-deepPressed: #ff8a9c; --keyColor-deepPressed-rgb: 255, 138, 156; --keyColor-disabled: rgba(250, 88, 106, 0.35); + --navigationBarHeight: 38px; } html, @@ -220,6 +221,7 @@ input[type=range].web-slider::-webkit-slider-runnable-track { top: 0; left: 0; padding: 32px; + padding-top: calc(var(--navigationBarHeight) * 2); width: 100%; } @@ -1489,6 +1491,45 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { /* Cider */ +#navigation-bar { + width: 100%; + background: rgba(0, 0, 0, 0.25); + height: var(--navigationBarHeight); + display: flex; + align-items: center; + padding: 0px 6px; + z-index: 1; + position: sticky; + top: 0; + left: 0; + backdrop-filter: blur(16px) saturate(180%); + border-bottom: 1px solid rgb(200 200 200 / 10%); + .nav-item { + appearance: none; + border: 0px; + height: 32px; + width: 42px; + background: transparent; + padding: 6px; + display: flex; + justify-content: center; + align-items: center; + color: rgba(200, 200, 200, 0.8); + margin: 2px; + border-radius: 3px; + &:hover { + background: var(--selected); + } + &:active { + background: var(--selected-click); + } + > svg { + width: 8px; + pointer-events: none; + } + } +} + .reload-btn { background: rgb(86 86 86 / 52%); border-radius: 100%; diff --git a/resources/cider-ui/views/main.ejs b/resources/cider-ui/views/main.ejs index 0f1d3471..950b07d9 100644 --- a/resources/cider-ui/views/main.ejs +++ b/resources/cider-ui/views/main.ejs @@ -240,6 +240,10 @@
+