101 lines
2.5 KiB
Plaintext
101 lines
2.5 KiB
Plaintext
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
|
import "pkg:/components/Navigation/Navigation.bs"
|
|
import "pkg:/source/utils/FocusManagement.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
function Init()
|
|
m.noBookmarks = m.top.findNode("noBookmarks")
|
|
m.yesBookmarks = m.top.findNode("yesBookmarks")
|
|
m.rowList = m.top.FindNode("rowList")
|
|
m.rowList.screen = m.top
|
|
m.isDirty = true
|
|
|
|
m.top.ObserveField("visible", FuncName(OnVisibleChange))
|
|
end function
|
|
|
|
function OnNodeReady()
|
|
SetNavigation(invalid, "back", m.navBar)
|
|
SetNavigation(invalid, "left", m.navBar)
|
|
|
|
m.rowList@.BindNode()
|
|
|
|
OnBookmarksChange()
|
|
m.bookmarks.ObserveField("contentChange", FuncName(OnBookmarksChange))
|
|
end function
|
|
|
|
function OnFocusChange() as void
|
|
if not m.top.focus
|
|
return
|
|
end if
|
|
|
|
if m.yesBookmarks.visible
|
|
NodeSetFocus(m.rowList, true)
|
|
else
|
|
NodeSetFocus(m.navBar, true)
|
|
end if
|
|
end function
|
|
|
|
function OnVisibleChange()
|
|
if m.top.visible and m.isDirty
|
|
OnBookmarksChange()
|
|
end if
|
|
end function
|
|
|
|
function Refresh(_unused as dynamic)
|
|
m.isDirty = true
|
|
OnBookmarksChange()
|
|
end function
|
|
|
|
function OnBookmarksChange() as void
|
|
if not m.top.visible
|
|
m.isDirty = true
|
|
return
|
|
end if
|
|
m.isDirty = false
|
|
|
|
hasBookmarks = m.bookmarks.content.getChildCount() > 0
|
|
m.noBookmarks.visible = not hasBookmarks
|
|
m.yesBookmarks.visible = hasBookmarks
|
|
m.top.focusable = hasBookmarks
|
|
|
|
if hasBookmarks
|
|
SetRowListContent(m.bookmarks.content)
|
|
else
|
|
if m.rowList.hasFocus()
|
|
NodeSetFocus(m.navBar, true)
|
|
end if
|
|
end if
|
|
end function
|
|
|
|
function SetRowListContent(bookmarksContent as object)
|
|
bookmarkGroupNodes = bookmarksContent.getChildren(-1, 0)
|
|
|
|
feeds = []
|
|
for each bookmarkGroupNode in bookmarkGroupNodes
|
|
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0)
|
|
feedSources = []
|
|
for each bookmarkNode in bookmarkNodes
|
|
feedSources.push(bookmarkNode.feedSource)
|
|
end for
|
|
|
|
feeds.push({
|
|
"title": bookmarkGroupNode.title,
|
|
"feedSources": feedSources
|
|
})
|
|
end for
|
|
|
|
m.rowList.feeds = feeds
|
|
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
|
|
refreshItem = ContextMenuUtils.CreateOption("Refresh Bookmarks", m.top, "Refresh", [invalid])
|
|
return [refreshItem]
|
|
end function
|