diff --git a/components/ListPoster.brs b/components/ListPoster.brs index 55b1ff6a..74f094e3 100644 --- a/components/ListPoster.brs +++ b/components/ListPoster.brs @@ -1,6 +1,10 @@ sub init() m.title = m.top.findNode("title") + m.title.translation = [2, 0] + m.poster = m.top.findNode("poster") + m.poster.translation = [2, 0] + m.backdrop = m.top.findNode("backdrop") m.backdrop.color = "#404040FF" @@ -13,25 +17,49 @@ sub updateSize() m.poster = m.top.findNode("poster") m.backdrop = m.top.findNode("backdrop") + image = invalid + if m.top.itemContent <> invalid and m.top.itemContent.image <> invalid + image = m.top.itemContent.image + end if + + if image = invalid + m.backdrop.visible = true + else + m.backdrop.visible = false + end if + ' TODO - abstract this in case the parent doesnt have itemSize maxSize = m.top.getParent().itemSize + ' Always reserve the bottom for the Poster Title + m.title.wrap = true + m.title.maxLines = 2 + m.title.width = m.poster.width + m.title.height = 80 + m.title.translation = [0, int(maxSize[1]) - m.title.height] + + ratio = 1.5 + if image <> invalid + ratio = image.height / image.width + end if + m.poster.width = int(maxSize[0]) - 4 - m.poster.height = m.poster.width * 1.5 + m.poster.height = m.poster.width * ratio + + posterVertSpace = int(maxSize[1]) - m.title.height + + if m.poster.height > posterVertSpace + ' Do a thing to shrink the image if it is too tall + end if + + m.poster.translation = [2, (posterVertSpace - m.poster.height) / 2] m.backdrop.width = m.poster.width m.backdrop.height = m.poster.height - m.title.wrap = true - m.title.maxLines = 2 - m.title.width = m.poster.width - m.title.height = int(maxSize[1]) - m.poster.height - m.title.translation = [0, m.poster.height] - end sub function itemContentChanged() as void - updateSize() m.title = m.top.findNode("title") m.poster = m.top.findNode("poster") @@ -40,8 +68,5 @@ function itemContentChanged() as void m.title.text = itemData.title m.poster.uri = itemData.posterUrl - if itemData.mediaType = "Episode" - m.poster.height = m.poster.width * 9/16 - m.poster.translation = [2, m.poster.width / 2] - end if + updateSize() end function \ No newline at end of file diff --git a/components/ListPoster.xml b/components/ListPoster.xml index 9da1fe12..4e140493 100644 --- a/components/ListPoster.xml +++ b/components/ListPoster.xml @@ -1,12 +1,8 @@ - - + +