jf-roku/components/PersonDetails.brs

171 lines
5.5 KiB
Plaintext
Raw Normal View History

2022-03-13 08:46:03 +00:00
sub init()
m.dscr = m.top.findNode("description")
m.vidsList = m.top.findNode("extrasGrid")
m.btnGrp = m.top.findNode("buttons")
2023-02-01 18:46:54 +00:00
m.btnGrp.observeField("escape", "onButtonGroupEscaped")
2022-03-13 08:46:03 +00:00
m.favBtn = m.top.findNode("favorite-button")
m.extrasGrp = m.top.findNode("extrasGrp")
m.extrasGrp.opacity = 1.0
createDialogPallete()
m.top.optionsAvailable = false
end sub
sub loadPerson()
item = m.top.itemContent
itemData = item.json
m.top.Id = itemData.id
2023-02-07 19:10:01 +00:00
name = m.top.findNode("Name")
name.Text = itemData.Name
name.font.size = 70
2022-03-13 08:46:03 +00:00
if itemData.PremiereDate <> invalid and itemData.PremiereDate <> ""
2023-02-07 04:27:46 +00:00
lifeStringLabel = createObject("rosgnode", "Label")
lifeStringLabel.id = "premierDate"
lifeStringLabel.font = "font:SmallestBoldSystemFont"
lifeStringLabel.height = "100"
lifeStringLabel.vertAlign = "bottom"
2023-02-07 19:10:01 +00:00
name.vertAlign = "top"
name.font.size = 60
2023-02-07 04:27:46 +00:00
m.top.findNode("title_rectangle").appendChild(lifeStringLabel)
2022-03-13 08:46:03 +00:00
birthDate = CreateObject("roDateTime")
birthDate.FromISO8601String(itemData.PremiereDate)
deathDate = CreateObject("roDatetime")
lifeString = tr("Born") + ": " + birthDate.AsDateString("short-month-no-weekday")
if itemData.EndDate <> invalid and itemData.EndDate <> ""
deathDate.FromISO8601String(itemData.EndDate)
lifeString = lifeString + " * " + tr("Died") + ": " + deathDate.AsDateString("short-month-no-weekday")
end if
' Calculate age
age = deathDate.getYear() - birthDate.getYear()
if deathDate.getMonth() < birthDate.getMonth()
age--
else if deathDate.getMonth() = birthDate.getMonth()
if deathDate.getDayOfMonth() < birthDate.getDayOfMonth()
age--
end if
end if
lifeString = lifeString + " * " + tr("Age") + ": " + stri(age)
2023-02-07 19:10:01 +00:00
lifeStringLabel.Text = lifeString
2022-03-13 08:46:03 +00:00
end if
2023-02-07 04:27:46 +00:00
if itemData.Overview <> invalid and itemData.Overview <> ""
m.dscr.text = itemData.Overview
else
m.dscr.text = tr("Biographical information for this person is not currently available.")
2023-02-07 04:48:56 +00:00
m.dscr.horizAlign = "center"
m.dscr.vertAlign = "center"
2023-02-07 04:27:46 +00:00
end if
2022-03-13 08:46:03 +00:00
if item.posterURL <> invalid and item.posterURL <> ""
m.top.findnode("personImage").uri = item.posterURL
else
m.top.findnode("personImage").uri = "pkg:/images/baseline_person_white_48dp.png"
end if
m.vidsList.callFunc("loadPersonVideos", m.top.Id)
setFavoriteColor()
2023-02-04 17:22:49 +00:00
if not m.favBtn.hasFocus() then dscrShowFocus()
2022-03-13 08:46:03 +00:00
end sub
sub dscrShowFocus()
2023-02-04 17:22:49 +00:00
m.dscr.setFocus(true)
m.dscr.opacity = 1.0
m.top.findNode("dscrBorder").color = "#d0d0d0ff"
2022-03-13 08:46:03 +00:00
end sub
2023-02-01 18:46:54 +00:00
sub onButtonGroupEscaped()
key = m.btnGrp.escape
if key = "down"
m.dscr.setFocus(true)
m.dscr.opacity = 1.0
m.top.findNode("dscrBorder").color = "#d0d0d0ff"
end if
end sub
2022-03-13 08:46:03 +00:00
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "OK"
2023-02-01 18:46:54 +00:00
if m.dscr.hasFocus()
2022-03-13 08:46:03 +00:00
createFullDscrDlg()
return true
end if
return false
end if
if key = "back"
m.global.sceneManager.callfunc("popScene")
return true
end if
if key = "down"
2023-02-01 18:46:54 +00:00
if m.dscr.hasFocus()
2022-03-13 08:46:03 +00:00
m.dscr.opacity = 0.6
m.top.findNode("dscrBorder").color = "#data202020ff"
2023-02-01 08:54:58 +00:00
m.vidsList.setFocus(true)
m.top.findNode("VertSlider").reverse = false
m.top.findNode("pplAnime").control = "start"
2022-03-13 08:46:03 +00:00
return true
end if
else if key = "up"
2023-02-01 08:54:58 +00:00
if m.dscr.hasFocus()
m.favBtn.setFocus(true)
m.dscr.opacity = 0.6
m.top.findNode("dscrBorder").color = "#data202020ff"
return true
else if m.vidsList.isInFocusChain() and m.vidsList.itemFocused = 0
2022-03-13 08:46:03 +00:00
m.top.findNode("VertSlider").reverse = true
m.top.findNode("pplAnime").control = "start"
2023-02-04 17:22:49 +00:00
dscrShowFocus()
2022-03-13 08:46:03 +00:00
return true
end if
end if
return false
end function
sub setFavoriteColor()
fave = m.top.itemContent.favorite
fave_button = m.top.findNode("favorite-button")
if fave <> invalid and fave
fave_button.textColor = "#00ff00ff"
fave_button.focusedTextColor = "#269926ff"
2022-05-11 16:07:38 +00:00
fave_button.text = tr("Favorite")
2022-03-13 08:46:03 +00:00
else
fave_button.textColor = "0xddddddff"
fave_button.focusedTextColor = "#262626ff"
2022-05-11 16:07:38 +00:00
fave_button.text = tr("Set Favorite")
2022-03-13 08:46:03 +00:00
end if
end sub
sub createFullDscrDlg()
dlg = CreateObject("roSGNode", "OverviewDialog")
2023-02-01 18:46:54 +00:00
dlg.Title = m.top.itemContent.json.Name
2023-02-01 19:35:16 +00:00
dlg.width = 1290
2022-03-13 08:46:03 +00:00
dlg.palette = m.dlgPalette
2023-02-01 21:03:55 +00:00
dlg.overview = m.dscr.text
2022-03-13 08:46:03 +00:00
m.fullDscrDlg = dlg
m.top.getScene().dialog = dlg
2023-02-01 18:46:54 +00:00
2022-03-13 08:46:03 +00:00
end sub
sub createDialogPallete()
m.dlgPalette = createObject("roSGNode", "RSGPalette")
m.dlgPalette.colors = {
DialogBackgroundColor: "0x262828FF",
DialogItemColor: "0x00EF00FF",
DialogTextColor: "0xb0b0b0FF",
DialogFocusColor: "0xcececeFF",
DialogFocusItemColor: "0x202020FF",
DialogSecondaryTextColor: "0xf8f8f8ff",
DialogSecondaryItemColor: "0xcc7ecc4D",
DialogInputFieldColor: "0x80FF8080",
KeyboardDialogColor: "0x80FF804D",
2022-03-13 08:46:03 +00:00
DialogFootprintColor: "0x80FF804D"
}
end sub
function shortDate(isoDate) as string
myDate = CreateObject("roDateTime")
myDate.FromISO8601String(isoDate)
return myDate.AsDateString("short-month-no-weekday")
end function