Add Channel support (#144)

* Add Channel support

* Cross fade

* add todo
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-09-15 17:34:07 -04:00
1 parent 38a054a46a
commit f452bf23de
16 files changed
+347 -60

No files matched your search

@@ -0,0 +1,8 @@
namespace ChannelUtils
function Open(contentNode as object)
channelView = CreateObject("roSGNode", "ChannelView")
m.appController@.PushScreen(channelView)
channelView@.BindNode(invalid)
channelView.content = contentNode
end function
end namespace
@@ -0,0 +1,77 @@
import "pkg:/source/roku_modules/log/LogMixin.brs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
import "pkg:/source/utils/StringUtils.bs"
function Init()
m.log = new log.Logger("ChannelView")
m.banner = m.top.findNode("banner")
m.thumbnail = m.top.findNode("thumbnail")
m.authorLabel = m.top.findNode("authorLabel")
m.rowList = m.top.FindNode("rowList")
m.banner.ObserveField("loadStatus", FuncName(OnBannerLoadStatus))
end function
function OnNodeready()
m.rowList@.BindNode(invalid)
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.rowList, true)
end function
function OnContentSet() as void
content = m.top.content
if content = invalid
return
end if
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
' TODO:P1 handle case where there's no banner - a big portion of the screen is blank
m.banner.uri = content.banner
if StringUtils.IsNullOrEmpty(content.thumbnail)
m.thumbnail.uri = ""
else
if m.thumbnail.uri <> content.thumbnail or m.thumbnail.loadStatus = "failed"
m.thumbnail.loadingBitmapUri = m.thumbnail.uri
m.thumbnail.uri = content.thumbnail
end if
end if
m.rowList.content = content
content@.LoadChannel(m.invidious)
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if press = false
return false
end if
if key = "back"
Close()
return true
end if
return false
end function
function Close()
m.appController@.PopScreen(invalid)
end function
function OnBannerLoadStatus() as void
status = m.banner.loadStatus
if status <> "ready"
return
end if
aspect = m.banner.bitmapWidth / m.banner.bitmapHeight
m.banner.height = m.banner.width / aspect
end function
@@ -0,0 +1,58 @@
<component name="ChannelView" extends="Group" includes="AutoBind,Focus">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" />
</interface>
<children>
<Rectangle
width="1280"
height="720"
color="0x242424">
</Rectangle>
<Poster
id="banner"
translation="[0,0]"
width="1280" />
<Poster
translation="[115,180]"
width="104"
height="104"
uri="pkg:/images/circle-mask-500.png">
<!-- TODO:P1 figure out why the masksize need to be 150 but the image is 100 -->
<MaskGroup
translation="[2,2]"
masksize="[150,150]"
maskuri="pkg:/images/circle-mask-500.png">
<Poster
id="thumbnail"
width="100"
height="100" />
</MaskGroup>
</Poster>
<Label
id="authorLabel"
translation="[228,226]"
font="font:MediumBoldSystemFont" />
<VideoRowList
itemComponentName="RowCell"
id="rowList"
focusable="false"
translation="[0,320]"
numRows="1"
rowitemSize="[[350,196]]"
rowItemSpacing="[[25,0]]"
itemSize="[1280,326]"
itemSpacing="[0,65]"
rowLabelOffset="[[115,20]]"
focusXOffset="[115]"
showRowLabel="[true]"
rowFocusAnimationStyle="floatingfocus"
variableWidthItems="true"
focusBitmapUri="pkg:/images/focus_grid.9.png" />
</children>
</component>