49 lines
1.4 KiB
Plaintext
49 lines
1.4 KiB
Plaintext
import "HomeScreenUtils.bs"
|
|
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
|
import "pkg:/components/Navigation/Navigation.bs"
|
|
import "pkg:/source/utils/FocusManagement.bs"
|
|
import "pkg:/source/utils/Locale.bs"
|
|
import "pkg:/source/utils/RemoteKeys.bs"
|
|
|
|
function Init()
|
|
m.top.focusable = true
|
|
m.rowList = m.top.FindNode("rowList")
|
|
m.rowList.screen = m.top
|
|
m.pendingLoadTasks = {}
|
|
end function
|
|
|
|
function OnNodeReady()
|
|
SetNavigation(invalid, RemoteKeys.Back, m.navBar)
|
|
SetNavigation(invalid, RemoteKeys.Left, m.navBar)
|
|
|
|
m.rowList@.BindNode()
|
|
|
|
' TODO:P1 home screen should only be refreshed when the user navigates to it
|
|
' (similar to bookmarks screen)
|
|
m.preferences.observeFieldScoped("misc.home_screen_layout", FuncName(OnHomeLayoutChange))
|
|
OnHomeLayoutChange()
|
|
end function
|
|
|
|
function OnHomeLayoutChange() as void
|
|
m.rowList.feeds = HomeScreenUtils.GetFeed(m.top.feedFile, m.preferences)
|
|
end function
|
|
|
|
function OnFocusChange() as void
|
|
if not m.top.focus
|
|
return
|
|
end if
|
|
NodeSetFocus(m.rowList, true)
|
|
end function
|
|
|
|
function OnKeyEvent(key as string, press as boolean) as boolean
|
|
if NavigationKeyHandler(key, press).handled
|
|
return true
|
|
end if
|
|
return false
|
|
end function
|
|
|
|
function GetContextMenuOptionsForItem(_rowItem as object) as object
|
|
refresh = ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.RefreshHome), m.rowList, "Refresh", [invalid])
|
|
return [refresh]
|
|
end function
|