Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made animated scroll #6

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions components/rowListContent.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 41 additions & 3 deletions components/rowListScene.brs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ 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.rows = m.top.getChild(1).getChildren(6, 0)
m.parent = m.top.findNode("rowListParty")
m.scrollAnimation = m.top.findNode("scroll")
for each row in m.rows
row.content = createObject("roSGNode", "RowListContent")
end for
m.rowFocused = 0
mcherri marked this conversation as resolved.
Show resolved Hide resolved
m.rows[0].setFocus(true)
videoMode = createObject("roDeviceInfo")
if videoMode.GetVideoMode() = "720p"
m.global.ratio = 0.66
Expand All @@ -21,3 +26,36 @@ 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 < 4 and m.scrollAnimation.state = "stopped"
m.rowFocused++
m.scrollAnimation.getChild(0).keyValue = [[0, m.parent.translation[1]], [0, m.parent.translation[1] - 300]]
m.parent.getChild(m.rowFocused).setFocus(true)
m.scrollAnimation.control = "start"
else if direction = "up" and m.rowFocused = 1 and m.scrollAnimation.state = "stopped"
m.parent.getChild(m.rowFocused - 1).setFocus(true)
else if direction = "up" and m.rowFocused > 1 and m.scrollAnimation.state = "stopped"
m.rowFocused--
m.scrollAnimation.getChild(0).keyValue = [[0, m.parent.translation[1]], [0, m.parent.translation[1] + 300]]
m.parent.getChild(m.rowFocused).setFocus(true)
m.scrollAnimation.control = "start"
else if direction = "down" and m.rowFocused = 4 and m.scrollAnimation.state = "stopped"
m.parent.getChild(m.rowFocused + 1).setFocus(true)
m.rowFocused = 5
else if direction = "up" and m.rowFocused = 5 and m.scrollAnimation.state = "stopped"
m.parent.getChild(m.rowFocused - 1).setFocus(true)
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
12 changes: 11 additions & 1 deletion components/rowListScene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<component name="rowListScene" extends="Scene" initialFocus="mainRowList">
<script type="text/brightscript" uri="rowListScene.brs" />
<children>
<RowList id="mainRowList" rowSpacings="[0.0]" focusXOffset="[-150.0]" translation="[ 0, 330 ]" rowLabelOffset="[[220.0,-6.0]]" itemComponentName="RowListItem" numRows="2" itemSize="[ 1608, 250 ]" rowItemSize="[ [368, 250] ]" rowHeights="[250.0]" vertFocusAnimationStyle="fixedFocusWrap" rowFocusAnimationStyle="fixedFocusWrap" showRowLabel="[true]" rowItemSpacing="[[0.0,0.0]]" drawFocusFeedback="false" rowLabelFont="font:LargeBoldSystemFont" />
<Group id="rowListParty">
<RowList id="rowList1" rowSpacings="[0.0]" focusXOffset="[-150.0]" translation="[ 0, 100 ]" rowLabelOffset="[[220.0,-6.0]]" itemComponentName="RowListItem" numRows="2" itemSize="[ 1608, 250 ]" rowItemSize="[ [368, 250] ]" rowHeights="[250.0]" vertFocusAnimationStyle="floatingFocus" rowFocusAnimationStyle="floatingFocus" showRowLabel="[true]" rowItemSpacing="[[0.0,0.0]]" drawFocusFeedback="false" rowLabelFont="font:LargeBoldSystemFont" />
<RowList id="rowList2" rowSpacings="[0.0]" focusXOffset="[-150.0]" translation="[ 0, 400 ]" rowLabelOffset="[[220.0,-6.0]]" itemComponentName="RowListItem" numRows="2" itemSize="[ 1608, 250 ]" rowItemSize="[ [368, 250] ]" rowHeights="[250.0]" vertFocusAnimationStyle="floatingFocus" rowFocusAnimationStyle="floatingFocus" showRowLabel="[true]" rowItemSpacing="[[0.0,0.0]]" drawFocusFeedback="false" rowLabelFont="font:LargeBoldSystemFont" />
<RowList id="rowList3" rowSpacings="[0.0]" focusXOffset="[-150.0]" translation="[ 0, 700 ]" rowLabelOffset="[[220.0,-6.0]]" itemComponentName="RowListItem" numRows="2" itemSize="[ 1608, 250 ]" rowItemSize="[ [368, 250] ]" rowHeights="[250.0]" vertFocusAnimationStyle="floatingFocus" rowFocusAnimationStyle="floatingFocus" showRowLabel="[true]" rowItemSpacing="[[0.0,0.0]]" drawFocusFeedback="false" rowLabelFont="font:LargeBoldSystemFont" />
<RowList id="rowList4" rowSpacings="[0.0]" focusXOffset="[-150.0]" translation="[ 0, 1000 ]" rowLabelOffset="[[220.0,-6.0]]" itemComponentName="RowListItem" numRows="2" itemSize="[ 1608, 250 ]" rowItemSize="[ [368, 250] ]" rowHeights="[250.0]" vertFocusAnimationStyle="floatingFocus" rowFocusAnimationStyle="floatingFocus" showRowLabel="[true]" rowItemSpacing="[[0.0,0.0]]" drawFocusFeedback="false" rowLabelFont="font:LargeBoldSystemFont" />
<RowList id="rowList5" rowSpacings="[0.0]" focusXOffset="[-150.0]" translation="[ 0, 1300 ]" rowLabelOffset="[[220.0,-6.0]]" itemComponentName="RowListItem" numRows="2" itemSize="[ 1608, 250 ]" rowItemSize="[ [368, 250] ]" rowHeights="[250.0]" vertFocusAnimationStyle="floatingFocus" rowFocusAnimationStyle="floatingFocus" showRowLabel="[true]" rowItemSpacing="[[0.0,0.0]]" drawFocusFeedback="false" rowLabelFont="font:LargeBoldSystemFont" />
<RowList id="rowList6" rowSpacings="[0.0]" focusXOffset="[-150.0]" translation="[ 0, 1600 ]" rowLabelOffset="[[220.0,-6.0]]" itemComponentName="RowListItem" numRows="2" itemSize="[ 1608, 250 ]" rowItemSize="[ [368, 250] ]" rowHeights="[250.0]" vertFocusAnimationStyle="floatingFocus" rowFocusAnimationStyle="floatingFocus" showRowLabel="[true]" rowItemSpacing="[[0.0,0.0]]" drawFocusFeedback="false" rowLabelFont="font:LargeBoldSystemFont" />
<Animation id="scroll" duration="1" repeat="false" easeFunction="linear">
<Vector2DFieldInterpolator id="myInterp1" key="[0.0, 1.0]" fieldToInterp="rowListParty.translation" />
</Animation>
</Group>
</children>
</component>