* Translated using Weblate (English (United States)) Currently translated at 100.0% (316 of 316 strings) Translation: Playlet/Playlet Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/en_US/ * Translated using Weblate (German) Currently translated at 100.0% (316 of 316 strings) Translation: Playlet/Playlet Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/de/ * Translated using Weblate (French (Canada)) Currently translated at 98.7% (312 of 316 strings) Translation: Playlet/Playlet Translate-URL: https://hosted.weblate.org/projects/playlet/playlet/fr_CA/ * Fix case * remove "unfinished" attribute * UI Refactor (#394) * Setting category refactor * tweak * Wip navbar * profile icon support * screen offset * Nav bar animation * Flexible navbar * initial focus fix * Fix settings * changelog * comment * Lint fix --------- Co-authored-by: Lacey Anaya <yecakeh263@anawalls.com> Co-authored-by: github-action linter <githubaction@githubaction.com>
48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
import "pkg:/source/utils/FocusManagement.bs"
|
|
import "pkg:/source/utils/Types.bs"
|
|
|
|
' TODO:P1 this is a duplicate of AppRoot, refactor to use the same code
|
|
function Init()
|
|
m.scrollAnimation = m.top.findNode("scrollAnimation")
|
|
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
|
|
m.lastFocusedChild = invalid
|
|
m.top.observeField("focusedChild", FuncName(OnFocusedChildChange))
|
|
end function
|
|
|
|
function OnFocusChange() as void
|
|
if not m.top.focus
|
|
return
|
|
end if
|
|
|
|
focusNode = invalid
|
|
if m.lastFocusedChild <> invalid
|
|
focusNode = m.lastFocusedChild
|
|
else if m.top.getChildCount() > 0
|
|
focusNode = m.top.getChild(0)
|
|
end if
|
|
|
|
if focusNode <> invalid
|
|
NodeSetFocus(focusNode, true)
|
|
end if
|
|
end function
|
|
|
|
function OnFocusedChildChange() as void
|
|
if m.top.focusedChild <> invalid
|
|
m.lastFocusedChild = m.top.focusedChild
|
|
end if
|
|
end function
|
|
|
|
function OnAnimateToPosition() as void
|
|
m.scrollAnimation.control = "stop"
|
|
|
|
current = m.top.translation[0]
|
|
destination = m.top.animateToPosition
|
|
|
|
if current = destination
|
|
return
|
|
end if
|
|
|
|
m.scrollAnimationInterpolator.keyValue = [[current, 0], [(current + destination) / 2, 0], [destination, 0]]
|
|
m.scrollAnimation.control = "start"
|
|
end function
|