Files
playlet-piped/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
T
Brahim Hadricheandgithub-action linter 3559a3fff6 Queue UI (#199)
* Refactor long press

* Lint fix

* Queue UI, refactor PlayQueue to use ContentNode

* Add queue notification hint

* Play at index

* Play queue with highlight

* Priority

* Comment

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-11-12 17:45:00 -05:00

77 lines
2.1 KiB
Plaintext

import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
FindChildren()
end function
function FindChildren()
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")
end function
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
if m.titleLabel = invalid
FindChildren()
end if
m.titleLabel.text = content.title
m.authorLabel.text = content.author
if content.isUpcoming = true
m.viewCountDateLabel.text = content.premiereTimestampText
else 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
m.viewCountDateLabel.text = ""
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, rect.translation[1]]
end function