From 60cb640e8e8213386194167ce712857e57d4a7b7 Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:20:47 +0200 Subject: [PATCH 1/7] Made the interface to exchange information from item to hero --- components/rowListContent.brs | 19 +++++++++--- components/rowListItem.brs | 10 +++++++ components/rowListScene.brs | 14 +++++++++ components/rowListScene.xml | 55 ++++++++++++++++++++++++++++++++++- 4 files changed, 93 insertions(+), 5 deletions(-) diff --git a/components/rowListContent.brs b/components/rowListContent.brs index a37fbf2..2645a4d 100644 --- a/components/rowListContent.brs +++ b/components/rowListContent.brs @@ -2,10 +2,21 @@ sub init() m.global.http.request = { payload: { userId: 1, title: "WOW, IT WORKED ^_^", - }, url: "https://jsonplaceholder.typicode.com/albums", requestType: "GET"} - m.global.http.observeFieldScoped("response", "useResponse") + }, url: "https://alghool.net/RokuDev/data.json", requestType: "GET"} + m.global.http.observeFieldScoped("response", "populateRowList") end sub -sub useResponse() - ?m.global.http.response +sub populateRowList() + items = m.global.http.response.body + for each item in items + itemNode = m.top.createChild("ContentNode") + itemNode.title = item.title + for each data in item.data + itemData = itemNode.createChild("ContentNode") + itemData.title = data.title + itemData.HDPosterUrl = data.thumbnail + itemData.description = data.longDescription + end for + m.top.appendChild(itemNode) + end for end sub diff --git a/components/rowListItem.brs b/components/rowListItem.brs index 227b724..7713bf8 100644 --- a/components/rowListItem.brs +++ b/components/rowListItem.brs @@ -3,6 +3,7 @@ sub init() m.itemTitle = m.top.findNode("itemTitle") m.itemMask = m.top.findNode("itemMask") m.itemDescription = m.top.findNode("itemDescription") + m.parentComponent = m.top.findNode("rowListScene") end sub sub showContent() @@ -26,6 +27,15 @@ end sub sub handleFocus() scale = 1 + (m.top.focusPercent * 0.15) m.itemPoster.scale = [scale, scale] + if m.top.focusPercent = 1 + m.global.mainScreen.backgroundURI = m.itemPoster.uri + m.global.mainScreen.HeroDetails = { + MainBoldLabel:m.itemTitle.text + DateAndDurationLabel:"21 Sep 21 | 3m" + DescriptionLabel:m.itemDescription.text + CategoryLabel:"World" + } + end if end sub sub handleRowFocus() diff --git a/components/rowListScene.brs b/components/rowListScene.brs index 22d7821..3326d9b 100644 --- a/components/rowListScene.brs +++ b/components/rowListScene.brs @@ -1,12 +1,19 @@ sub init() m.global.addField("http", "node", FALSE) m.global.addField("ratio", "float", FALSE) + m.global.addField("mainScreen", "node", FALSE) + m.global.mainScreen = m.top m.global.http = createObject("roSGNode", "httpTask") m.global.http.control = "RUN" m.global.ratio = 1 m.rowList = m.top.findNode("mainRowList") + m.MainBoldLabel = m.top.findNode("MainBoldLabel") + m.DateAndDurationLabel = m.top.findNode("DateAndDurationLabel") + m.DescriptionLabel = m.top.findNode("DescriptionLabel") + m.CategoryLabel = m.top.findNode("CategoryLabel") m.rowList.content = createObject("roSGNode", "RowListContent") m.rowList.setFocus(true) + m.top.observeField("HeroDetails","handleHeroDetails") videoMode = createObject("roDeviceInfo") if videoMode.GetVideoMode() = "720p" m.global.ratio = 0.66 @@ -21,3 +28,10 @@ sub init() m.rowList.itemSize = [1400, INT(m.rowList.itemSize[1] * m.global.ratio)] end if end sub + +sub handleHeroDetails() + m.MainBoldLabel.text = m.top.HeroDetails.MainBoldLabel + m.DateAndDurationLabel.text = m.top.HeroDetails.DateAndDurationLabel + m.DescriptionLabel.text = m.top.HeroDetails.DescriptionLabel + m.CategoryLabel.text = m.top.HeroDetails.CategoryLabel +end sub \ No newline at end of file diff --git a/components/rowListScene.xml b/components/rowListScene.xml index bc7e6b9..f3ff697 100644 --- a/components/rowListScene.xml +++ b/components/rowListScene.xml @@ -1,7 +1,60 @@