* update dependencies * Update lint exceptions for colors --------- Co-authored-by: iBicha <iBicha@users.noreply.github.com> Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>
75 lines
2.3 KiB
Plaintext
75 lines
2.3 KiB
Plaintext
import "pkg:/source/utils/Locale.bs"
|
|
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")
|
|
m.smallestSystemFont = m.top.FindNode("smallestSystemFont")
|
|
m.smallestBoldSystemFont = m.top.FindNode("smallestBoldSystemFont")
|
|
end function
|
|
|
|
function OnContentSet() as void
|
|
content = m.top.itemContent
|
|
|
|
if content = invalid
|
|
return
|
|
end if
|
|
|
|
m.top.title = content.title
|
|
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
|
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
|
|
|
|
if ValidInt(content.lengthSeconds) <> 0
|
|
SetDurationLabel(content.lengthText, "#161616FF", 0.8, m.smallestSystemFont)
|
|
m.top.durationRectVisible = true
|
|
else
|
|
if content.isUpcoming = true
|
|
SetDurationLabel(Tr(Locale.RowCell.Upcoming), "#161616FF", 0.8, m.smallestBoldSystemFont)
|
|
m.top.durationRectVisible = true
|
|
else if content.liveNow
|
|
SetDurationLabel(Tr(Locale.RowCell.Live), "#CC0000FF", 0.9, m.smallestBoldSystemFont)
|
|
m.top.durationRectVisible = true
|
|
else
|
|
m.top.durationRectVisible = false
|
|
end if
|
|
end if
|
|
end function
|
|
|
|
function SetDurationLabel(text as string, bgColor as string, bgOpacity as float, font as object) as void
|
|
m.top.duration = text
|
|
|
|
label = m.durationLabel
|
|
rect = m.durationRect
|
|
|
|
if label = invalid or rect = invalid
|
|
return
|
|
end if
|
|
|
|
rectParent = rect.getParent()
|
|
label.font = font
|
|
|
|
size = label.localBoundingRect()
|
|
|
|
rect.width = size.width + 16
|
|
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
|
|
rect.color = bgColor
|
|
rect.opacity = bgOpacity
|
|
end function
|
|
|