* Sort imports * Lint fix --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
68 lines
1.9 KiB
Plaintext
68 lines
1.9 KiB
Plaintext
import "pkg:/source/utils/StringUtils.bs"
|
|
import "pkg:/source/utils/TimeUtils.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
function Init()
|
|
m.titleLabel = m.top.FindNode("titleLabel")
|
|
m.authorLabel = m.top.FindNode("authorLabel")
|
|
m.viewCountDateLabel = m.top.FindNode("viewCountDateLabel")
|
|
m.liveRect = m.top.FindNode("liveRect")
|
|
m.upcomingRect = m.top.FindNode("upcomingRect")
|
|
m.durationRect = m.top.FindNode("durationRect")
|
|
m.durationLabel = m.top.FindNode("durationLabel")
|
|
m.thumbnail = m.top.FindNode("thumbnail")
|
|
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
|
|
end function
|
|
|
|
function OnContentSet() as void
|
|
content = m.top.itemContent
|
|
|
|
if content = invalid
|
|
return
|
|
end if
|
|
|
|
m.titleLabel.text = content.title
|
|
m.authorLabel.text = content.author
|
|
|
|
if not StringUtils.IsNullOrEmpty(content.publishedText)
|
|
label = content.publishedText
|
|
if not StringUtils.IsNullOrEmpty(content.viewCountText)
|
|
label = `${label} • ${content.viewCountText}`
|
|
end if
|
|
m.viewCountDateLabel.text = label
|
|
else if content.isUpcoming = true
|
|
m.viewCountDateLabel.text = content.premiereTimestampText
|
|
end if
|
|
|
|
m.thumbnail.uri = content.thumbnail
|
|
|
|
m.durationRect.visible = false
|
|
m.upcomingRect.visible = false
|
|
m.liveRect.visible = false
|
|
|
|
if ValidInt(content.lengthSeconds) <> 0
|
|
SetDurationText(content.lengthText)
|
|
m.durationRect.visible = true
|
|
else
|
|
if content.isUpcoming = true
|
|
m.upcomingRect.visible = true
|
|
else if content.liveNow
|
|
m.liveRect.visible = true
|
|
end if
|
|
end if
|
|
end function
|
|
|
|
function SetDurationText(text as string)
|
|
label = m.durationLabel
|
|
rect = m.durationRect
|
|
|
|
rectParent = rect.getParent()
|
|
|
|
label.text = text
|
|
size = label.localBoundingRect()
|
|
|
|
rect.width = size.width + 16
|
|
rect.translation = [rectParent.width - rect.width, 162]
|
|
end function
|
|
|