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,25 +0,0 @@
import "pkg:/source/utils/General.bs"
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
@asynctask
function AppVersionTask() as object
latest = "N/A"
args = {
parseJson: false
}
response = Requests().request("HEAD", "https://github.com/iBicha/playlet/releases/latest", args)
if response.statusCode = 200
if response.headers.location <> invalid
regex = CreateObject("roRegex", "/v?(\d+\.\d+\.\d+)", "")
match = regex.match(response.headers.location)
if match.Count() = 2
latest = match[1]
end if
end if
end if
return {
latest: latest
}
end function
@@ -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'