* Change default instance * Fix cropped buttons * Lint fix * changelog --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
108 lines
3.3 KiB
Plaintext
108 lines
3.3 KiB
Plaintext
import "pkg:/components/Navigation/Navigation.bs"
|
|
import "pkg:/components/Services/Invidious/InvidiousService.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, "down", m.publicInstances)
|
|
SetNavigation(m.editButton, "down", m.testButton)
|
|
SetNavigation(m.publicInstances, "up", m.editButton)
|
|
|
|
SetNavigation(m.publicInstances, "down", m.testButton)
|
|
|
|
SetNavigation(m.testButton, "up", m.publicInstances)
|
|
SetNavigation(m.testButton, "up", m.editButton)
|
|
SetNavigation(m.saveButton, "up", m.publicInstances)
|
|
SetNavigation(m.saveButton, "up", m.editButton)
|
|
|
|
SetNavigation(m.saveButton, "left", m.testButton)
|
|
SetNavigation(m.testButton, "right", m.saveButton)
|
|
|
|
m.currentNavigtionNode = m.editButton
|
|
m.textEditBox.hintText = `e.g. ${Invidious.DEFAULT_INSTANCE}`
|
|
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 = "options" and press
|
|
' A pass-through to the app controller, so it can toggle picture-in-picture
|
|
return false
|
|
end if
|
|
|
|
if key = "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(invalid)
|
|
testing.instance = m.top.text
|
|
testing.run = true
|
|
end function
|
|
|
|
function OnEditButtonSelected()
|
|
keyboardDialog = createObject("roSGNode", "StandardKeyboardDialog")
|
|
keyboardDialog.title = "Edit Instance"
|
|
keyboardDialog.message = [`Enter the instance url (e.g. ${Invidious.DEFAULT_INSTANCE})`]
|
|
keyboardDialog.text = m.top.text
|
|
keyboardDialog.buttons = ["OK", "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(invalid)
|
|
end function
|