Files
playlet-piped/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
T
Brahim Hadriche 0f000590a0 Fixes for RowList cells (#244)
* Fixes for RowList cells

* typo
2023-12-30 22:32:43 -05:00

68 lines
1.7 KiB
Plaintext

import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
end function
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.top.title = content.title
m.top.author = content.author
if content.isUpcoming = true
m.top.viewCountDate = 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.top.viewCountDate = label
else
m.top.viewCountDate = ""
end if
m.top.thumbnailUri = content.thumbnail
m.top.durationRectVisible = false
m.top.upcomingRectVisible = false
m.top.liveRectVisible = false
if ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.top.durationRectVisible = true
else
if content.isUpcoming = true
m.top.upcomingRectVisible = true
else if content.liveNow
m.top.liveRectVisible = true
end if
end if
end function
function SetDurationText(text as string) as void
m.top.duration = text
label = m.durationLabel
rect = m.durationRect
if label = invalid or rect = invalid
return
end if
rectParent = rect.getParent()
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function