diff --git a/CHANGELOG.md b/CHANGELOG.md index a2fc551b..36f5dc00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - Add watched videos to Invidious watch history +- App info screen ### Fixed - A crash where the metadata of a video is not validated [#57](https://github.com/iBicha/playlet/issues/57) diff --git a/playlet-lib/src/components/AppInfoScreen/AppInfoScreen.bs b/playlet-lib/src/components/AppInfoScreen/AppInfoScreen.bs new file mode 100644 index 00000000..e28b2155 --- /dev/null +++ b/playlet-lib/src/components/AppInfoScreen/AppInfoScreen.bs @@ -0,0 +1,52 @@ +import "pkg:/source/utils/General.bs" +import "pkg:/components/AppInfoScreen/AppVersionTask.bs" +import "pkg:/source/asyncTask/asyncTask.bs" + +function Init() + m.displayNames = { + "version": "Playlet Version", + "lib_version": "Playlet Library Version", + "lib_version_latest": "Playlet Library Latest Version", + "lib_url": "Playlet Library URL", + "lib_url_type": "Playlet Library URL Type", + "git_commit_hash": "Playlet Git Commit Hash", + "lib_git_commit_hash": "Playlet Library Git Commit Hash", + "id": "App ID" + } + + m.keyValueList = m.top.findNode("KeyValueListContent") + m.appInfo = GetAppInfo() + m.appInfo["lib_version_latest"] = "N/A" + m.appInfo["lib_url"] = "N/A" + m.appInfo["lib_url_type"] = "N/A" + + scene = m.top.getScene() + if scene.playletLibLoadedUrl <> invalid + m.appInfo["lib_url"] = scene.playletLibLoadedUrl.link + m.appInfo["lib_url_type"] = scene.playletLibLoadedUrl.type + end if + + UpdateKeyValueList() + GetLatestVersion() +end function + +function UpdateKeyValueList() + while m.keyValueList.getChildCount() > 0 + m.keyValueList.removeChildIndex(0) + end while + + for each item in m.appInfo + value = `${m.displayNames[item]}: ${m.appInfo[item]}` + contentNode = m.keyValueList.createChild("ContentNode") + contentNode.title = value + end for +end function + +function GetLatestVersion() + StartAsyncTask(AppVersionTask, {}, function(output as object) as void + if output.result.latest <> invalid + m.appInfo["lib_version_latest"] = output.result.latest + UpdateKeyValueList() + end if + end function) +end function diff --git a/playlet-lib/src/components/AppInfoScreen/AppInfoScreen.xml b/playlet-lib/src/components/AppInfoScreen/AppInfoScreen.xml new file mode 100644 index 00000000..ed3fe40c --- /dev/null +++ b/playlet-lib/src/components/AppInfoScreen/AppInfoScreen.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/components/SettingsScreen/AppVersionTask.bs b/playlet-lib/src/components/AppInfoScreen/AppVersionTask.bs similarity index 100% rename from playlet-lib/src/components/SettingsScreen/AppVersionTask.bs rename to playlet-lib/src/components/AppInfoScreen/AppVersionTask.bs diff --git a/playlet-lib/src/components/MainScene.bs b/playlet-lib/src/components/MainScene.bs index 46aae0d3..ad4707a4 100644 --- a/playlet-lib/src/components/MainScene.bs +++ b/playlet-lib/src/components/MainScene.bs @@ -15,11 +15,25 @@ function Init() m.currentFocued = m.homeGridScreen m.settingsScreen = m.top.findNode("SettingsScreen") + m.appInfoScreen = m.top.findNode("AppInfoScreen") m.searchScreen = m.top.findNode("SearchScreen") m.searchScreen.ObserveField("escape", "OnSearchScreenEscape") m.navBar = m.top.findNode("NavBar") + m.navBarScreens = [{ + node: m.searchScreen, + canEscape: true + }, { + node: m.homeGridScreen, + canEscape: true + }, { + node: m.settingsScreen, + canEscape: false + }, { + node: m.appInfoScreen, + canEscape: false + }] m.navBar.ObserveField("escapeIndex", "OnNavBarEscape") m.navBar.ObserveField("focusIndex", "OnNavIndexChange") @@ -54,14 +68,9 @@ end function function OnNavBarEscape() index = m.navBar.escapeIndex - if index = 0 - m.searchScreen.focus = true - m.currentFocued = m.searchScreen - else if index = 1 - m.homeGridScreen.focus = true - m.currentFocued = m.homeGridScreen - else if index = 2 - m.settingsScreen.focus = true + m.navBarScreens[index].node.focus = true + if m.navBarScreens[index].canEscape + m.currentFocued = m.navBarScreens[index].node end if end function @@ -70,19 +79,9 @@ function OnNavIndexChange() as void if index = -1 return end if - if index = 0 - m.searchScreen.visible = true - m.homeGridScreen.visible = false - m.settingsScreen.visible = false - else if index = 1 - m.searchScreen.visible = false - m.homeGridScreen.visible = true - m.settingsScreen.visible = false - else if index = 2 - m.searchScreen.visible = false - m.homeGridScreen.visible = false - m.settingsScreen.visible = true - end if + for i = 0 to m.navBarScreens.count() - 1 + m.navBarScreens[i].node.visible = i = index + end for end function function OnWebServerLogin() diff --git a/playlet-lib/src/components/MainScene.xml b/playlet-lib/src/components/MainScene.xml index 220a9ca0..61fa09d2 100644 --- a/playlet-lib/src/components/MainScene.xml +++ b/playlet-lib/src/components/MainScene.xml @@ -5,6 +5,7 @@ + diff --git a/playlet-lib/src/components/NavBar/NavBar.xml b/playlet-lib/src/components/NavBar/NavBar.xml index 6bc3a585..f10e295e 100644 --- a/playlet-lib/src/components/NavBar/NavBar.xml +++ b/playlet-lib/src/components/NavBar/NavBar.xml @@ -4,7 +4,7 @@ - + + diff --git a/playlet-lib/src/components/SettingsScreen/SettingsScreen.bs b/playlet-lib/src/components/SettingsScreen/SettingsScreen.bs index 59a3f189..afb8267c 100644 --- a/playlet-lib/src/components/SettingsScreen/SettingsScreen.bs +++ b/playlet-lib/src/components/SettingsScreen/SettingsScreen.bs @@ -1,23 +1,9 @@ import "pkg:/source/utils/General.bs" import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/asyncTask/asyncTask.bs" -import "pkg:/components/SettingsScreen/AppVersionTask.bs" function Init() - m.versionLabel = m.top.findNode("VersionLabel") - m.playletLibUrlLabel = m.top.findNode("PlayletLibUrlLabel") - m.top.url = `http://${GetLocalIpAddress()}:8888` - - appInfo = GetAppInfo() - m.top.appVersion = appInfo.version - m.top.libVersion = appInfo.lib_version - - scene = m.top.getScene() - if scene.playletLibLoadedUrl <> invalid - m.top.libUrl = `[${scene.playletLibLoadedUrl.type}|${scene.playletLibLoadedUrl.link}]` - end if - GetLatestVersion() end function function OnUrlSet() @@ -29,19 +15,3 @@ function OnUrlSet() urlLabel = m.top.findNode("urlLabel") urlLabel.text = url end function - -function GetLatestVersion() - StartAsyncTask(AppVersionTask, {}, function(output as object) as void - if output.result.latest <> invalid - m.top.latestVersion = output.result.latest - end if - end function) -end function - -function SetVersionLabel() - m.versionLabel.text = `Playlet: ${m.top.appVersion} | Playlet-Lib: ${m.top.libVersion} | Latest: ${m.top.latestVersion}` -end function - -function SetPlayletLibUrlLabel() - m.playletLibUrlLabel.text = `Playlet-Lib: ${m.top.libUrl}` -end function diff --git a/playlet-lib/src/components/SettingsScreen/SettingsScreen.xml b/playlet-lib/src/components/SettingsScreen/SettingsScreen.xml index 788c377c..d04a24c3 100644 --- a/playlet-lib/src/components/SettingsScreen/SettingsScreen.xml +++ b/playlet-lib/src/components/SettingsScreen/SettingsScreen.xml @@ -2,28 +2,16 @@ - - - -