Files
playlet-piped/playlet-lib/src/components/PlaylistView/PlaylistViewCell.bs
T

63 lines
1.5 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
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
author = content._author
if not StringUtils.IsNullOrEmpty(author)
videoInfo = content.videoInfo
if not StringUtils.IsNullOrEmpty(videoInfo)
author += `\n` + videoInfo
end if
else
lines = content.lines
if IsArray(lines) and lines.Count() > 0
author = lines[0]
if lines.Count() > 1
author += `\n` + lines[1]
end if
end if
end if
m.top.author = author
m.top.thumbnailUri = content.thumbnail
SetDurationText(content.lengthText)
end function
function SetDurationText(text as string) as void
hasText = text <> ""
m.top.durationRectVisible = hasText
if not hasText
return
end if
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