Skip to content

Commit

Permalink
Merge pull request #1446 from cewert/import-npm-bgv
Browse files Browse the repository at this point in the history
Copy ButtonGroupVert code into app instead of using NPM package
  • Loading branch information
1hitsong authored Oct 31, 2023
2 parents 617bfe7 + 5641e8e commit bd94f9c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 10 deletions.
44 changes: 44 additions & 0 deletions components/ButtonGroupVert.bs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
sub init()
m.top.layoutDirection = "vert"
m.top.observeField("focusedChild", "onFocusChanged")
m.top.observeField("focusButton", "onFocusButtonChanged")
end sub

sub onFocusChanged()
if m.top.hasFocus()
m.top.getChild(0).setFocus(true)
m.top.focusButton = 0
end if
end sub

sub onFocusButtonChanged()
m.top.getChild(m.top.focusButton).setFocus(true)
end sub

function onKeyEvent(key as string, press as boolean) as boolean
if key = "OK"
m.top.selected = m.top.focusButton
return true
end if

if not press then return false

if key = "down"
i = m.top.focusButton
target = i + 1
if target >= m.top.getChildCount() then return false
m.top.focusButton = target
return true
else if key = "up"
i = m.top.focusButton
target = i - 1
if target < 0 then return false
m.top.focusButton = target
return true
else if key = "left" or key = "right"
m.top.escape = key
return true
end if

return false
end function
7 changes: 7 additions & 0 deletions components/ButtonGroupVert.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="ButtonGroupVert" extends="ButtonGroup">
<interface>
<field id="escape" type="string" alwaysNotify="true" />
<field id="selected" type="integer" alwaysNotify="true" />
</interface>
</component>
4 changes: 2 additions & 2 deletions components/music/ArtistView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@

</SectionScroller>

<bgv_ButtonGroupVert id="sectionNavigation" translation="[-100, 175]" itemSpacings="[10]">
<ButtonGroupVert id="sectionNavigation" translation="[-100, 175]" itemSpacings="[10]">
<sob_SlideOutButton background="#070707" focusBackground="#00a4dc" highlightBackground="#555555" padding="20" icon="pkg:/images/icons/details.png" text="Details" height="50" width="60" />
<sob_SlideOutButton id="albumsLink" background="#070707" focusBackground="#00a4dc" highlightBackground="#555555" padding="20" icon="pkg:/images/icons/cd.png" text="Albums" height="50" width="60" />
<sob_SlideOutButton id="appearsOnLink" background="#070707" focusBackground="#00a4dc" highlightBackground="#555555" padding="20" icon="pkg:/images/icons/cassette.png" text="Appears On" height="50" width="60" />
</bgv_ButtonGroupVert>
</ButtonGroupVert>

<Animation id="pageLoad" duration="1" repeat="false">
<Vector2DFieldInterpolator key="[0.5, 1.0]" keyValue="[[-100, 175], [40, 175]]" fieldToInterp="sectionNavigation.translation" />
Expand Down
7 changes: 0 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "Roku app for Jellyfin media server",
"dependencies": {
"@rokucommunity/bslib": "0.1.1",
"bgv": "npm:[email protected]",
"brighterscript-formatter": "1.6.34",
"intKeyboard": "npm:[email protected]",
"log": "npm:[email protected]",
Expand Down

0 comments on commit bd94f9c

Please sign in to comment.