* innertube structure * Basic search results parsing * Lint fix * Fix ctt * adjust parser, parse trending pages * Lint fix * channel wip * channel parsing - wip * OAuth support * cancellation utils * Lint fix * Home feed with tv client * Lint fix * add some browse endpoints * oauth adjust * refactor * Add nodes * More parsing * oauth refactor * playlist * WIP: built-in instance * WIP: Channels now kinda load * Channel view * workaround for playlist pagination * default instance and display name * video thumbnails * changelog * privacy --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
136 lines
4.5 KiB
Plaintext
136 lines
4.5 KiB
Plaintext
import "pkg:/components/Dialog/DialogPalette.bs"
|
|
import "pkg:/components/Navigation/Navigation.bs"
|
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
|
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
|
import "pkg:/source/utils/RemoteKeys.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
function Init()
|
|
m.textEditBox = m.top.findNode("textEditBox")
|
|
m.editButton = m.top.findNode("editButton")
|
|
m.testButton = m.top.findNode("testButton")
|
|
m.saveButton = m.top.findNode("saveButton")
|
|
|
|
m.publicInstances = m.top.findNode("instances")
|
|
|
|
m.editButton.observeField("buttonSelected", FuncName(OnEditButtonSelected))
|
|
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
|
m.testButton.observeField("buttonSelected", FuncName(OnTestButtonSelected))
|
|
m.publicInstances.observeField("instance", FuncName(OnPublicInstanceSelected))
|
|
|
|
SetNavigation(m.editButton, RemoteKeys.Down, m.publicInstances)
|
|
SetNavigation(m.editButton, RemoteKeys.Down, m.testButton)
|
|
SetNavigation(m.publicInstances, RemoteKeys.Up, m.editButton)
|
|
|
|
SetNavigation(m.publicInstances, RemoteKeys.Down, m.testButton)
|
|
|
|
SetNavigation(m.testButton, RemoteKeys.Up, m.publicInstances)
|
|
SetNavigation(m.testButton, RemoteKeys.Up, m.editButton)
|
|
SetNavigation(m.saveButton, RemoteKeys.Up, m.publicInstances)
|
|
SetNavigation(m.saveButton, RemoteKeys.Up, m.editButton)
|
|
|
|
SetNavigation(m.saveButton, RemoteKeys.Left, m.testButton)
|
|
SetNavigation(m.testButton, RemoteKeys.Right, m.saveButton)
|
|
|
|
m.currentNavigtionNode = m.editButton
|
|
m.textEditBox.hintText = `e.g. ${Invidious.INSTANCE_EXAMPLE}`
|
|
|
|
SetButtonPositions()
|
|
|
|
SetPublicInstancesPosition()
|
|
m.publicInstances.observeField("width", FuncName(SetPublicInstancesPosition))
|
|
end function
|
|
|
|
function SetButtonPositions()
|
|
testButtonWidth = m.testButton.width
|
|
saveButtonWidth = m.saveButton.width
|
|
buttonsWith = testButtonWidth + saveButtonWidth + 20
|
|
m.testButton.translation = [960 / 2 - buttonsWith / 2, m.testButton.translation[1]]
|
|
m.saveButton.translation = [960 / 2 + buttonsWith / 2 - saveButtonWidth, m.saveButton.translation[1]]
|
|
end function
|
|
|
|
function SetPublicInstancesPosition() as void
|
|
width = m.publicInstances.width
|
|
if width = 0
|
|
return
|
|
end if
|
|
|
|
m.publicInstances.translation = [960 / 2 - width / 2, m.publicInstances.translation[1]]
|
|
end function
|
|
|
|
function OnFocusChange() as void
|
|
if not m.top.focus
|
|
return
|
|
end if
|
|
|
|
NodeSetFocus(m.currentNavigtionNode, true)
|
|
end function
|
|
|
|
function OnKeyEvent(key as string, press as boolean) as boolean
|
|
navigation = NavigationKeyHandler(key, press)
|
|
if navigation.handled
|
|
m.currentNavigtionNode = navigation.node
|
|
return true
|
|
end if
|
|
|
|
if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
|
|
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
|
|
return false
|
|
end if
|
|
|
|
if key = RemoteKeys.Back and press
|
|
Close()
|
|
return true
|
|
end if
|
|
|
|
return true
|
|
end function
|
|
|
|
function OnPublicInstanceSelected()
|
|
m.top.text = m.publicInstances.instance
|
|
m.currentNavigtionNode = m.testButton
|
|
NodeSetFocus(m.testButton, true)
|
|
end function
|
|
|
|
function OnTestButtonSelected()
|
|
testing = CreateObject("roSGNode", "InvidiousInstanceTesting")
|
|
m.appController@.PushScreen(testing)
|
|
testing@.BindNode()
|
|
testing.instance = m.top.text
|
|
testing.run = true
|
|
end function
|
|
|
|
function OnEditButtonSelected()
|
|
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
|
|
SetPalette(keyboardDialog)
|
|
' TODO:P2 localize
|
|
keyboardDialog.title = "Edit Instance"
|
|
' TODO:P2 localize
|
|
keyboardDialog.message = [`Enter the instance url (e.g. ${Invidious.INSTANCE_EXAMPLE})`]
|
|
keyboardDialog.text = m.top.text
|
|
keyboardDialog.buttons = [Tr(Locale.Buttons.OK), Tr(Locale.Buttons.Cancel)]
|
|
keyboardDialog.observeField("buttonSelected", FuncName(OnKeyboardButton))
|
|
|
|
m.top.getScene().dialog = keyboardDialog
|
|
end function
|
|
|
|
function OnKeyboardButton(event as object)
|
|
keyboard = event.getRoSGNode()
|
|
buttonSelected = keyboard.buttonSelected
|
|
if buttonSelected = 0
|
|
m.top.text = keyboard.text
|
|
m.currentNavigtionNode = m.testButton
|
|
NodeSetFocus(m.testButton, true)
|
|
end if
|
|
keyboard.close = true
|
|
end function
|
|
|
|
function OnSaveButtonSelected()
|
|
m.top.save = true
|
|
Close()
|
|
end function
|
|
|
|
function Close()
|
|
m.appController@.PopScreen()
|
|
end function
|