Multiple profiles (#312)
* Navbar user profile * profiles stuff * fix profile * Lint fix * Some ui experiments * More ui work * progress * Lint fix * migration, web api, wip * profile view and web app * web app and apis * Invidious and profiles * Lint fix * bug fix * Remove ActionContentNode * Profile icon button, profile color * Lint fix * reset server url * href that doesn't work * remove activate button on active profile * TODO * Fin. * Final touches --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
8e03ca0ea6
commit
394dd23999
60 files changed
+1725
-311
No files matched your search
@@ -0,0 +1,2 @@
|
||||
<component name="ProfileRowList" extends="RowList">
|
||||
</component>
|
||||
@@ -0,0 +1,68 @@
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
function Init()
|
||||
m.normalFont = m.top.findNode("normalFont")
|
||||
m.boldFont = m.top.findNode("boldFont")
|
||||
end function
|
||||
|
||||
function OnContentSet() as void
|
||||
content = m.top.itemContent
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
if content.type = "login"
|
||||
m.top.circlePosterInnerUri = "pkg:/images/icons/user-200.png"
|
||||
' bs:disable-next-line LINT3023
|
||||
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
|
||||
m.top.letter = ""
|
||||
m.top.username = "Login"
|
||||
m.top.serverUrl = ""
|
||||
m.top.crownVisible = false
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.circlePosterInnerUri = "pkg:/images/white-circle.png"
|
||||
m.top.circlePosterInnerBlendColor = content.color
|
||||
username = content.username
|
||||
m.top.username = username
|
||||
if not StringUtils.IsNullOrEmpty(username)
|
||||
m.top.letter = UCase(username.Left(1))
|
||||
else
|
||||
m.top.letter = ""
|
||||
end if
|
||||
m.top.serverUrl = content.serverUrl
|
||||
m.top.crownVisible = content.isSelected
|
||||
end function
|
||||
|
||||
function OnRowListHasFocus()
|
||||
if not m.top.rowListHasFocus
|
||||
m.top.animate = false
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnItemHasFocus()
|
||||
m.top.animate = (m.top.itemHasFocus or m.top.focusPercent > 0.5) and m.top.rowListHasFocus
|
||||
end function
|
||||
|
||||
function OnFocusPercent()
|
||||
if m.top.focusPercent > 0.5 and m.top.rowListHasFocus
|
||||
m.top.animate = true
|
||||
else
|
||||
m.top.animate = false
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnAnimate()
|
||||
animate = m.top.animate
|
||||
m.top.shadowVisible = animate
|
||||
m.top.serverLabelVisible = animate
|
||||
m.top.circlePosterTranslation = [20, 20]
|
||||
if animate
|
||||
m.top.UsernameLabelFont = m.boldFont
|
||||
m.top.animationControl = "start"
|
||||
else
|
||||
m.top.UsernameLabelFont = m.normalFont
|
||||
m.top.animationControl = "stop"
|
||||
end if
|
||||
end function
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<component name="ProfileRowListCell" extends="Group">
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
<field id="letter" type="string" alias="LetterLabel.text" />
|
||||
<field id="username" type="string" alias="UsernameLabel.text" />
|
||||
<field id="serverUrl" type="string" alias="ServerLabel.text" />
|
||||
<field id="circlePosterInnerUri" type="uri" alias="circlePosterInner.uri" />
|
||||
<field id="circlePosterInnerBlendColor" type="uri" alias="circlePosterInner.blendColor" />
|
||||
<field id="UsernameLabelFont" type="boolean" alias="UsernameLabel.font" />
|
||||
<field id="rowListHasFocus" type="boolean" onChange="OnRowListHasFocus" />
|
||||
<field id="itemHasFocus" type="boolean" onChange="OnItemHasFocus" />
|
||||
<field id="focusPercent" type="float" onChange="OnFocusPercent" />
|
||||
<field id="circlePosterTranslation" type="vector2d" alias="circlePoster.translation" />
|
||||
<field id="animate" type="boolean" onChange="OnAnimate" />
|
||||
<field id="animationControl" type="string" alias="floatAnimation.control" />
|
||||
<field id="shadowVisible" type="boolean" alias="shadowPoster.visible" />
|
||||
<field id="crownVisible" type="boolean" alias="CrownPoster.visible" />
|
||||
<field id="serverLabelVisible" type="boolean" alias="ServerLabel.visible" />
|
||||
</interface>
|
||||
<children>
|
||||
<Font id="normalFont" uri="font:SystemFontFile" size="24" />
|
||||
<Font id="boldFont" uri="font:BoldSystemFontFile" size="26" />
|
||||
|
||||
<Group translation="[20,50]">
|
||||
<Group
|
||||
id="shadowScaler"
|
||||
translation="[100,20]">
|
||||
<Group translation="[-100,-20]">
|
||||
<Poster
|
||||
id="shadowPoster"
|
||||
uri="pkg:/images/white-circle.png"
|
||||
blendColor="#000000"
|
||||
width="200"
|
||||
height="40"
|
||||
translation="[0,200]"
|
||||
visible="false">
|
||||
</Poster>
|
||||
</Group>
|
||||
</Group>
|
||||
|
||||
<Poster
|
||||
id="circlePoster"
|
||||
width="160"
|
||||
height="160"
|
||||
translation="[20,20]"
|
||||
uri="pkg:/images/white-circle.png">
|
||||
<Poster
|
||||
id="circlePosterInner"
|
||||
width="152"
|
||||
height="152"
|
||||
blendColor="#9696c8"
|
||||
uri="pkg:/images/white-circle.png"
|
||||
translation="[4,4]">
|
||||
<Label
|
||||
id="LetterLabel"
|
||||
width="152"
|
||||
height="152"
|
||||
vertAlign="center"
|
||||
horizAlign="center">
|
||||
<Font role="font" uri="font:SystemFontFile" size="120" />
|
||||
</Label>
|
||||
</Poster>
|
||||
<Poster
|
||||
id="CrownPoster"
|
||||
width="60"
|
||||
height="60"
|
||||
translation="[50,-60]"
|
||||
uri="pkg:/images/icons/crown.png"
|
||||
visible="false">
|
||||
</Poster>
|
||||
</Poster>
|
||||
<Label
|
||||
id="UsernameLabel"
|
||||
width="200"
|
||||
horizAlign="center"
|
||||
translation="[0,250]">
|
||||
</Label>
|
||||
<Label
|
||||
id="ServerLabel"
|
||||
width="400"
|
||||
horizAlign="center"
|
||||
translation="[-100,310]"
|
||||
visible="false">
|
||||
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||
</Label>
|
||||
</Group>
|
||||
<Animation
|
||||
id="floatAnimation"
|
||||
repeat="true"
|
||||
duration="4"
|
||||
easeFunction="inOutQuad">
|
||||
<Vector2DFieldInterpolator
|
||||
key="[ 0.0, 0.5, 0.55, 1.0 ]"
|
||||
keyValue="[ [20,40], [20,10], [20,10], [20,40]]"
|
||||
fieldToInterp="circlePoster.translation" />
|
||||
<Vector2DFieldInterpolator
|
||||
key="[ 0.0, 0.5, 0.55, 1.0 ]"
|
||||
keyValue="[ [0.7,1], [1.05,1],[1.05,1] , [0.7,1] ]"
|
||||
fieldToInterp="shadowScaler.scale" />
|
||||
<FloatFieldInterpolator
|
||||
key="[ 0.0, 0.5, 0.55, 1.0 ]"
|
||||
keyValue="[0.3, 0.05 ,0.05, 0.3 ]"
|
||||
fieldToInterp="shadowPoster.opacity" />
|
||||
</Animation>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,63 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/ProfileView/ProfileViewUtils.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
m.top.focusable = true
|
||||
m.profileRowList = m.top.FindNode("ProfileRowList")
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
SetNavigation(invalid, "back", m.navBar)
|
||||
SetNavigation(invalid, "left", m.navBar)
|
||||
|
||||
m.profileRowList.content = m.profiles.content
|
||||
m.profileRowList.observeFieldScoped("rowItemSelected", FuncName(OnRowItemSelected))
|
||||
m.profiles.observeFieldScoped("currentProfile", FuncName(OnCurrentProfileChanged))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
if not m.top.focus
|
||||
return
|
||||
end if
|
||||
NodeSetFocus(m.profileRowList, 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 OnRowItemSelected() as void
|
||||
index = m.profileRowList.rowItemSelected[1]
|
||||
row = m.profileRowList.content.GetChild(0)
|
||||
selectedProfile = row.GetChild(index)
|
||||
if selectedProfile.type = "login"
|
||||
dialog = CreateObject("roSGNode", "LoginDialog")
|
||||
dialog@.BindNode()
|
||||
m.top.getScene().dialog = dialog
|
||||
return
|
||||
end if
|
||||
|
||||
ProfileViewUtils.Open(selectedProfile, m.appController)
|
||||
end function
|
||||
|
||||
function OnCurrentProfileChanged() as void
|
||||
currentProfile = m.profiles.currentProfile
|
||||
if currentProfile = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
row = m.profileRowList.content.GetChild(0)
|
||||
allProfiles = row.getChildren(-1, 0)
|
||||
for i = 0 to allProfiles.Count() - 1
|
||||
if currentProfile.id = allProfiles[i].id
|
||||
m.profileRowList.jumpToRowItem = [0, i]
|
||||
return
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
@@ -0,0 +1,21 @@
|
||||
<component name="ProfileScreen" extends="Group" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="navBar" type="node" bind="/NavBar" />
|
||||
<field id="profiles" type="node" bind="/Profiles" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
</interface>
|
||||
|
||||
<children>
|
||||
<ProfileRowList
|
||||
id="ProfileRowList"
|
||||
translation="[0,160]"
|
||||
numRows="2"
|
||||
rowitemSize="[[240,340]]"
|
||||
rowItemSpacing="[[0,0]]"
|
||||
itemSize="[1280,500]"
|
||||
focusXOffset="[200]"
|
||||
itemComponentName="ProfileRowListCell"
|
||||
rowFocusAnimationStyle="floatingfocus"
|
||||
focusBitmapUri="pkg:/images/focus-glow-padding-19.9.png" />
|
||||
</children>
|
||||
</component>
|
||||
Reference in new issue
Block a user