diff --git a/.gitignore b/.gitignore index fa001aa..b74381e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ out/ out/roku-deploy.zip +.vscode/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index dca2ab3..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "brightscript", - "request": "launch", - "name": "BrightScript Debug: Launch", - "stopOnEntry": false, - "host": "${promptForHost}", - "password": "mega", - "rootDir": "${workspaceFolder}", - "enableDebuggerAutoRecovery": false, - "stopDebuggerOnAppExit": false - } - ] -} \ No newline at end of file diff --git a/components/rowListContent.brs b/components/rowListContent.brs index a37fbf2..b2109bc 100644 --- a/components/rowListContent.brs +++ b/components/rowListContent.brs @@ -1,11 +1,25 @@ sub init() - m.global.http.request = { payload: { + m.http = createObject("roSGNode", "httpTask") + m.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.http.control = "RUN" + m.http.observeFieldScoped("response", "populateRowList") end sub -sub useResponse() - ?m.global.http.response +sub populateRowList() + for each item in m.http.response.body + itemNode = m.top.createChild("ContentNode") + itemNode.title = item.title + for each data in item.data + itemData = itemNode.createChild("ContentNode") + itemData.setFields({ + title: data.title + HDPosterURL: data.thumbnail + 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..d69ae6b 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.getScene() end sub sub showContent() @@ -26,6 +27,16 @@ end sub sub handleFocus() scale = 1 + (m.top.focusPercent * 0.15) m.itemPoster.scale = [scale, scale] + if m.top.focusPercent = 1 + m.parentComponent.backgroundURI = m.itemPoster.uri + m.parentComponent.HeroDetails = { + MainBoldLabel: m.itemTitle.text + DateAndDurationLabel: "21 Sep 21 | 3m" + DescriptionLabel: m.itemDescription.text + CategoryLabel: "World" + focus: m.itemPoster.uri + } + end if end sub sub handleRowFocus() diff --git a/components/rowListScene.brs b/components/rowListScene.brs index 22d7821..d3baadd 100644 --- a/components/rowListScene.brs +++ b/components/rowListScene.brs @@ -1,12 +1,20 @@ sub init() - m.global.addField("http", "node", FALSE) m.global.addField("ratio", "float", FALSE) - m.global.http = createObject("roSGNode", "httpTask") - m.global.http.control = "RUN" + m.flag = true m.global.ratio = 1 m.rowList = m.top.findNode("mainRowList") + m.currFocus = invalid + 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.fadeInAnimation = m.top.findNode("fadeInAnimation") + m.fadeOutAnimation = m.top.findNode("fadeOutAnimation") m.rowList.content = createObject("roSGNode", "RowListContent") m.rowList.setFocus(true) + m.rowList.findNode("RowListItem") + m.top.observeField("HeroDetails", "handleHeroDetails") + m.fadeOutAnimation.observeField("state", "handleAnimationDone") videoMode = createObject("roDeviceInfo") if videoMode.GetVideoMode() = "720p" m.global.ratio = 0.66 @@ -21,3 +29,30 @@ sub init() m.rowList.itemSize = [1400, INT(m.rowList.itemSize[1] * m.global.ratio)] end if end sub + +sub handleHeroDetails() + if m.flag + m.flag = false + handleUpdate() + else + handleItemFocusChange() + end if +end sub + +sub handleAnimationDone(event) + if event.getData() = "stopped" + handleUpdate() + m.fadeInAnimation.control = "start" + end if +end sub + +sub handleItemFocusChange() + m.fadeOutAnimation.control = "start" +end sub + +sub handleUpdate() + 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..15be50a 100644 --- a/components/rowListScene.xml +++ b/components/rowListScene.xml @@ -1,7 +1,27 @@