Feature/app info screen (#69)

* Add app info screen

* Better app info page

* Small refactor for the navbar screens

* Changelog
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-04-18 16:52:15 -04:00
1 parent 8169c7223d
commit 32bcc1dfc0
11 files changed
+105 -66

No files matched your search

+1
View File
@@ -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)
@@ -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
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="AppInfoScreen" extends="Group">
<interface>
</interface>
<children>
<LabelList
translation="[160,92]"
itemSize="[1020,48]"
font='font:SmallestBoldSystemFont'>
<ContentNode id="KeyValueListContent" role="content">
</ContentNode>
</LabelList>
</children>
</component>
+20 -21
View File
@@ -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()
+1
View File
@@ -5,6 +5,7 @@
<SearchScreen id="SearchScreen" visible="false" />
<HomeGridScreen id="HomeGridScreen" />
<SettingsScreen id="SettingsScreen" visible="false" />
<AppInfoScreen id="AppInfoScreen" visible="false" />
<NavBar id="NavBar" />
<VideoContainer id="VideoContainer" />
</children>
+10 -1
View File
@@ -4,7 +4,7 @@
<interface>
<field id="focusIndex" type="int" alwaysNotify="true" />
<field id="escapeIndex" type="int" alwaysNotify="true" />
</interface>
</interface>
<children>
<Rectangle
height="720"
@@ -42,6 +42,15 @@
text="Settings"
height="50"
width="80" />
<IconButton
id="appInfoButton"
background="#242424"
focusBackground="#ff1c30"
padding="20"
icon="pkg:/images/icons/info.png"
text="Info"
height="50"
width="80" />
</ButtonGroup>
</Rectangle>
</children>
@@ -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
@@ -2,28 +2,16 @@
<component name="SettingsScreen" extends="Group">
<interface>
<field id="appVersion" type="string" value="N/A" onChange="SetVersionLabel" />
<field id="libVersion" type="string" value="N/A" onChange="SetVersionLabel" />
<field id="latestVersion" type="string" value="N/A" onChange="SetVersionLabel" />
<field id="libUrl" type="string" value="N/A" onChange="SetPlayletLibUrlLabel" />
<field id="url" type="string" onChange="OnUrlSet" />
</interface>
<children>
<Label
id='VersionLabel'
height='60'
width='1280'
font='font:MediumBoldSystemFont'
horizAlign="center"
translation="[0,80]"
/>
<Label
id='PlayletLibUrlLabel'
height='60'
width='1280'
font='font:SmallestBoldSystemFont'
horizAlign="center"
translation="[0,120]"
translation="[0,92]"
text="Open in a web browser to configure Playlet:"
/>
<QRPoster
id='SettingsQRPoster'
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 122.88 122.88"
style="enable-background:new 0 0 122.88 122.88" xml:space="preserve"><g><path fill="#FFFFFF" d="M61.44,9.23c-1.85,0-3.64,0.08-5.35,0.25c-1.71,0.17-3.44,0.42-5.17,0.77c-1.72,0.34-3.39,0.77-5,1.26 c-1.59,0.49-3.16,1.07-4.7,1.72l-0.1,0.05l0,0c-1.63,0.7-3.18,1.45-4.67,2.25c-1.5,0.81-2.94,1.68-4.31,2.6 c-1.38,0.93-2.72,1.92-3.99,2.97c-1.27,1.05-2.5,2.16-3.68,3.35l-0.04,0.04c-1.18,1.18-2.29,2.4-3.33,3.66 c-1.05,1.28-2.04,2.61-2.97,3.99c-0.92,1.36-1.78,2.8-2.59,4.3c-0.8,1.49-1.56,3.05-2.26,4.67l-0.05,0.11l0,0l-0.07,0.14 c-0.63,1.5-1.19,3.04-1.67,4.61c-0.49,1.59-0.9,3.23-1.24,4.93c-0.35,1.73-0.6,3.45-0.77,5.17c-0.17,1.72-0.25,3.5-0.25,5.35 c0,1.85,0.08,3.64,0.25,5.35c0.17,1.71,0.42,3.44,0.77,5.17c0.35,1.72,0.77,3.39,1.27,5c0.49,1.57,1.05,3.13,1.7,4.66 c0.04,0.07,0.07,0.14,0.1,0.21c0.69,1.6,1.43,3.13,2.23,4.6c0.81,1.5,1.68,2.94,2.59,4.3c0.93,1.39,1.92,2.72,2.98,4 c1.02,1.24,2.11,2.44,3.26,3.59c0.07,0.06,0.13,0.12,0.19,0.19c1.16,1.16,2.36,2.24,3.59,3.26c1.28,1.05,2.61,2.04,3.99,2.97 c1.36,0.92,2.8,1.78,4.3,2.59c1.49,0.8,3.05,1.56,4.67,2.26l0.21,0.1c1.52,0.64,3.07,1.2,4.67,1.69c1.58,0.49,3.23,0.9,4.92,1.24 c1.73,0.35,3.45,0.6,5.17,0.77c1.72,0.17,3.5,0.25,5.35,0.25c1.85,0,3.64-0.08,5.35-0.25c1.71-0.17,3.44-0.42,5.17-0.77 c1.72-0.35,3.39-0.77,5-1.27c1.59-0.49,3.16-1.07,4.71-1.73l0.09-0.04l0-0.01c1.63-0.7,3.18-1.45,4.67-2.25 c1.5-0.81,2.94-1.68,4.31-2.6c1.38-0.93,2.72-1.92,3.99-2.97c1.25-1.03,2.45-2.12,3.62-3.29c0.06-0.06,0.11-0.12,0.18-0.18 c1.15-1.15,2.23-2.35,3.25-3.58c1.05-1.28,2.05-2.61,2.98-4c0.92-1.36,1.78-2.8,2.59-4.3c0.8-1.49,1.56-3.04,2.26-4.67l0.1-0.22 c0.64-1.51,1.2-3.06,1.69-4.65c0.49-1.59,0.9-3.23,1.24-4.93c0.35-1.73,0.6-3.45,0.77-5.17c0.17-1.72,0.25-3.5,0.25-5.35 c0-1.85-0.08-3.64-0.25-5.35c-0.17-1.71-0.42-3.44-0.77-5.17c-0.35-1.72-0.77-3.39-1.27-5c-0.49-1.59-1.07-3.16-1.73-4.71 l-0.04-0.09l0,0c-0.7-1.63-1.45-3.18-2.25-4.67c-0.81-1.5-1.68-2.94-2.59-4.3c-0.93-1.38-1.92-2.72-2.97-3.99 c-1.02-1.24-2.12-2.45-3.28-3.61c-0.07-0.06-0.13-0.12-0.18-0.18c-1.16-1.16-2.35-2.24-3.59-3.26c-1.28-1.05-2.61-2.04-3.99-2.97 c-1.37-0.92-2.8-1.78-4.3-2.59c-1.49-0.8-3.04-1.56-4.67-2.25l-0.19-0.09c-1.52-0.64-3.08-1.21-4.68-1.7 c-1.58-0.49-3.23-0.9-4.93-1.24c-1.73-0.35-3.45-0.6-5.17-0.77C65.08,9.31,63.29,9.23,61.44,9.23L61.44,9.23z M63.34,31.17 c2.19,0,3.91,0.63,5.16,1.88c1.24,1.25,1.87,2.96,1.87,5.17c0,2.24-1.07,4.22-3.21,5.97c-2.16,1.74-4.66,2.62-7.52,2.62 c-2.14,0-3.85-0.6-5.16-1.8c-1.31-1.22-1.96-2.79-1.96-4.75c0-2.47,1.07-4.59,3.19-6.4C57.82,32.06,60.37,31.17,63.34,31.17 L63.34,31.17L63.34,31.17z M75.55,91.71H47.33v-4.75h5.3V57.95h-5.3v-3.78h13.19c3.33,0,6.61-0.4,9.85-1.22v34.01h5.18L75.55,91.71 L75.55,91.71L75.55,91.71z M49.12,1.2c1.96-0.39,3.99-0.69,6.08-0.89C57.29,0.1,59.37,0,61.44,0c2.07,0,4.15,0.1,6.24,0.31 c2.09,0.2,4.12,0.5,6.08,0.89c1.94,0.39,3.88,0.88,5.82,1.48c1.88,0.58,3.74,1.26,5.58,2.04l0.19,0.07l0,0l0.06,0.02 c1.85,0.8,3.65,1.67,5.38,2.61c1.71,0.93,3.4,1.95,5.07,3.07c1.63,1.1,3.21,2.27,4.73,3.52c1.52,1.25,2.97,2.56,4.34,3.95 c1.38,1.38,2.7,2.83,3.95,4.34c1.25,1.52,2.42,3.09,3.52,4.73c1.09,1.63,2.11,3.32,3.06,5.06l0,0l0.01,0 c0.94,1.74,1.82,3.54,2.61,5.39c0.02,0.05,0.04,0.1,0.06,0.15c0.78,1.83,1.46,3.7,2.05,5.6c0.61,1.96,1.11,3.92,1.5,5.89 c0.39,1.96,0.69,3.99,0.89,6.08c0.2,2.09,0.3,4.17,0.3,6.24c0,2.07-0.1,4.15-0.31,6.24c-0.2,2.09-0.5,4.12-0.89,6.08 c-0.39,1.94-0.88,3.88-1.48,5.82c-0.58,1.89-1.27,3.76-2.05,5.62l-0.04,0.09l0,0l-0.05,0.11c-0.8,1.85-1.67,3.65-2.61,5.38 c-0.93,1.71-1.95,3.4-3.07,5.07c-1.1,1.63-2.27,3.21-3.52,4.73c-1.25,1.52-2.56,2.96-3.95,4.34c-1.38,1.38-2.83,2.7-4.35,3.95 c-1.52,1.25-3.09,2.42-4.72,3.51c-1.63,1.09-3.32,2.11-5.06,3.06c-1.78,0.96-3.57,1.84-5.39,2.62c-0.05,0.02-0.1,0.04-0.16,0.06 c-1.83,0.78-3.7,1.46-5.6,2.05c-1.96,0.61-3.92,1.11-5.88,1.5c-1.96,0.39-3.99,0.69-6.08,0.89c-2.09,0.2-4.17,0.3-6.24,0.3 s-4.15-0.1-6.24-0.3c-2.09-0.2-4.12-0.5-6.08-0.89c-1.94-0.39-3.88-0.88-5.82-1.48c-1.89-0.58-3.76-1.27-5.61-2.05l-0.2-0.08l0,0 c-1.85-0.8-3.65-1.67-5.38-2.61c-1.71-0.93-3.4-1.95-5.07-3.07c-1.63-1.09-3.21-2.27-4.72-3.51c-1.52-1.25-2.97-2.57-4.35-3.95 c-1.38-1.38-2.7-2.83-3.95-4.34c-1.25-1.52-2.42-3.1-3.52-4.73c-1.09-1.63-2.11-3.32-3.06-5.06c-0.97-1.78-1.84-3.58-2.62-5.4 c-0.02-0.05-0.04-0.1-0.06-0.15c-0.78-1.83-1.46-3.7-2.05-5.6c-0.61-1.96-1.11-3.93-1.5-5.89c-0.39-1.96-0.69-3.99-0.89-6.08 C0.1,65.59,0,63.51,0,61.44c0-2.07,0.1-4.15,0.31-6.24c0.2-2.09,0.5-4.12,0.89-6.08c0.39-1.94,0.88-3.88,1.48-5.82 c0.58-1.88,1.26-3.74,2.04-5.59l0.09-0.23l0,0c0.8-1.85,1.67-3.65,2.61-5.38c0.93-1.71,1.95-3.4,3.07-5.07 c1.1-1.63,2.27-3.21,3.52-4.73c1.25-1.52,2.56-2.96,3.95-4.34c1.38-1.38,2.83-2.7,4.34-3.95c1.52-1.25,3.09-2.42,4.73-3.52 c1.67-1.12,3.36-2.14,5.07-3.07l0.13-0.06c1.73-0.94,3.48-1.78,5.26-2.55c0.05-0.02,0.1-0.04,0.15-0.06 c1.83-0.78,3.7-1.46,5.6-2.05C45.19,2.09,47.15,1.59,49.12,1.2L49.12,1.2z"/></g></svg>

After

Width:  |  Height:  |  Size: 4.9 KiB