44 lines
1021 B
Plaintext
44 lines
1021 B
Plaintext
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
|
|
m.top.thumbnailUri = content.thumbnail
|
|
|
|
if ValidInt(content.lengthSeconds) <> 0
|
|
SetDurationText(content.lengthText)
|
|
m.top.durationRectVisible = true
|
|
else
|
|
m.top.durationRectVisible = false
|
|
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, 72]
|
|
end function
|