From 1fd97c9fb7c1fe6b34c1cf1f827de40a99774dac Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Tue, 28 Sep 2021 15:27:08 +0200 Subject: [PATCH 1/7] made animated scroll --- components/rowListContent.brs | 13 +++++++--- components/rowListScene.brs | 48 ++++++++++++++++++++++++++++++++--- components/rowListScene.xml | 17 ++++++++++++- 3 files changed, 71 insertions(+), 7 deletions(-) diff --git a/components/rowListContent.brs b/components/rowListContent.brs index a37fbf2..18ff5c6 100644 --- a/components/rowListContent.brs +++ b/components/rowListContent.brs @@ -2,10 +2,17 @@ sub init() m.global.http.request = { payload: { userId: 1, title: "WOW, IT WORKED ^_^", - }, url: "https://jsonplaceholder.typicode.com/albums", requestType: "GET"} + }, url: "https://alghool.net/RokuDev/data.json", requestType: "GET" } m.global.http.observeFieldScoped("response", "useResponse") end sub sub useResponse() - ?m.global.http.response -end sub + itemNode = m.top.createChild("ContentNode") + itemNode.title = m.global.http.response.body[0].TITLE + for each itemData in m.global.http.response.body[0].data + itemDetails = itemNode.createChild("ContentNode") + itemDetails.title = itemData.title + itemDetails.HDPosterUrl = itemData.thumbnail + itemDetails.description = itemData.longDescription + end for +end sub \ No newline at end of file diff --git a/components/rowListScene.brs b/components/rowListScene.brs index 22d7821..91aaa2d 100644 --- a/components/rowListScene.brs +++ b/components/rowListScene.brs @@ -4,9 +4,22 @@ sub init() m.global.http = createObject("roSGNode", "httpTask") m.global.http.control = "RUN" m.global.ratio = 1 - m.rowList = m.top.findNode("mainRowList") - m.rowList.content = createObject("roSGNode", "RowListContent") - m.rowList.setFocus(true) + m.rowList1 = m.top.findNode("rowList1") + m.rowList2 = m.top.findNode("rowList2") + m.rowList3 = m.top.findNode("rowList3") + m.rowList4 = m.top.findNode("rowList4") + m.rowList5 = m.top.findNode("rowList5") + m.rowList6 = m.top.findNode("rowList6") + m.parent = m.top.findNode("rowListParty") + m.scrollAnimation = m.top.findNode("scroll") + m.rowList1.content = createObject("roSGNode", "RowListContent") + m.rowList2.content = createObject("roSGNode", "RowListContent") + m.rowList3.content = createObject("roSGNode", "RowListContent") + m.rowList4.content = createObject("roSGNode", "RowListContent") + m.rowList5.content = createObject("roSGNode", "RowListContent") + m.rowList6.content = createObject("roSGNode", "RowListContent") + m.rowFocused = 0 + m.rowList1.setFocus(true) videoMode = createObject("roDeviceInfo") if videoMode.GetVideoMode() = "720p" m.global.ratio = 0.66 @@ -21,3 +34,32 @@ sub init() m.rowList.itemSize = [1400, INT(m.rowList.itemSize[1] * m.global.ratio)] end if end sub + +sub animateScroll(direction as String) + if direction = "down" and m.rowFocused < 5 + m.rowFocused++ + for i = 0 to 5 + m.scrollAnimation.getChild(i).keyValue = [[0, m.parent.getChild(i).translation[1]], [0, m.parent.getChild(i).translation[1] - 300]] + end for + m.parent.getChild(m.rowFocused).setFocus(true) + m.scrollAnimation.control = "start" + else if direction = "up" and m.rowFocused > 0 + for i = 0 to 5 + m.scrollAnimation.getChild(i).keyValue = [[0, m.parent.getChild(i).translation[1]], [0, m.parent.getChild(i).translation[1] + 300]] + end for + m.parent.getChild(m.rowFocused).setFocus(true) + m.scrollAnimation.control = "start" + end if +end sub + +function onKeyEvent(key as String, press as Boolean) as Boolean + if press + if key = "down" + animateScroll(key) + return true + else if key = "up" + animateScroll(key) + return true + end if + end if +end function \ No newline at end of file diff --git a/components/rowListScene.xml b/components/rowListScene.xml index bc7e6b9..c22316e 100644 --- a/components/rowListScene.xml +++ b/components/rowListScene.xml @@ -2,6 +2,21 @@