Skip to content

Instantly share code, notes, and snippets.

@bbrouse
Last active Apr 26, 2016
Embed
What would you like to do?
Login scene code
<?xml version="1.0" encoding="utf-8" ?>
<component name="LoginScene" extends="BaseScene" >
<interface>
<field id="attemptLogin" type="boolean" value="false" alwaysNotify="true"/>
<field id="isValidUsername" type="boolean" value="false" alwaysNotify="true" onChange="onValidUsernameChange"/>
<field id="isLoginSuccess" type="boolean" value="false" alwaysNotify="true" onChange="onLoginSuccessChange"/>
<field id="username" type="string" value=""/>
<field id="password" type="string" value=""/>
</interface>
<script type="text/brightscript" uri="pkg:/source/common/generalUtils.brs" />
<script type="text/brightscript" >
<![CDATA[
function init()
m.usernameInput = m.top.FindNode("usernameTextEditBox")
m.usernameButton = m.top.FindNode("usernameButton")
m.passwordInput = m.top.FindNode("passwordTextEditBox")
m.passwordButton = m.top.FindNode("passwordButton")
m.loginButton = m.top.FindNode("loginButton")
m.forgotButton = m.top.FindNode("forgotPasswordButton")
m.submitButton = m.top.FindNode("submitButton")
m.keyboard = m.top.FindNode("keyboard")
m.mainGroup = m.top.FindNode("mainGroup")
m.keyboardGroup = m.top.FindNode("keyboardGroup")
m.usernameButton.ObserveField("buttonSelected", "usernameButtonSelected")
m.passwordButton.ObserveField("buttonSelected", "passwordButtonSelected")
m.loginButton.ObserveField("buttonSelected", "loginButtonSelected")
m.forgotButton.ObserveField("buttonSelected", "forgotButtonSelected")
m.submitButton.ObserveField("buttonSelected", "submitButtonSelected")
m.usernameButton.setFocus(true)
end function
function usernameButtonSelected()
m.entry_type = "username"
m.keyboard.text = m.usernameInput.text
m.keyboard.textEditBox.secureMode = false
m.top.FindNode("keyboardHeaderText").text = "Enter your email or username"
m.keyboard.setFocus(true)
m.mainGroup.visible = false
m.keyboardGroup.visible = true
end function
function passwordButtonSelected()
m.entry_type = "password"
m.keyboard.text = m.passwordInput.text
m.keyboard.textEditBox.secureMode = true
m.top.FindNode("keyboardHeaderText").text = "Enter your password"
m.keyboard.setFocus(true)
m.mainGroup.visible = false
m.keyboardGroup.visible = true
end function
function loginButtonSelected()
m.top.attemptLogin = true
end function
function submitButtonSelected()
if m.entry_type = "password"
m.passwordInput.text = m.keyboard.text
m.top.password = m.keyboard.text
m.passwordButton.setFocus(true)
else if m.entry_type = "username"
m.usernameInput.text = m.keyboard.text
m.top.username = m.keyboard.text
m.usernameButton.setFocus(true)
end if
m.mainGroup.visible = true
m.keyboardGroup.visible = false
end function
function onKeyEvent(key as String, press as Boolean) as Boolean
handled = false
if press then
if (key = "up") then
if m.forgotButton.hasFocus() then
m.loginButton.setFocus(true)
handled = true
else if m.loginButton.hasFocus()
m.passwordButton.setFocus(true)
handled = true
else if m.passwordButton.hasFocus()
m.usernameButton.setFocus(true)
handled = true
else if m.submitButton.hasFocus()
m.keyboard.setFocus(true)
handled = true
end if
else if (key = "down")
if m.usernameButton.hasFocus() then
m.passwordButton.setFocus(true)
handled = true
else if m.passwordButton.hasFocus()
m.loginButton.setFocus(true)
handled = true
else if m.loginButton.hasFocus()
m.forgotButton.setFocus(true)
handled = true
else if m.keyboard.isInFocusChain()
m.submitButton.setFocus(true)
handled = true
end if
end if
end if
return handled
end function
]]>
</script>
<children>
<Rectangle
id="background"
color="0xe0dbd3"
width="1280"
height="720"
translation="[0,0]"/>
<Group id="mainGroup" visible="true">
<Poster
uri="pkg:/images/df_logo.png"
width="332"
height="66"
translation="[475,100]" />
<Label
id="headerText"
translation="[314,180]"
color="#2c2621"
text="Watch the best TV Shows &amp; Movies from around the world."
horizAlign="center"
vertAlign="top"
height="40"
width="653"
wrap="true">
<Font role="font" uri="pkg:/fonts/Raleway-Medium.ttf" size="23" />
</Label>
<Label
id="usernameHeader"
translation="[388,268]"
color="#2c2621"
text="Email or Username"
horizAlign="left"
vertAlign="top"
height="24"
width="166">
<Font role="font" uri="pkg:/fonts/OpenSans-Semibold.ttf" size="18" />
</Label>
<TextEditBox
id="usernameTextEditBox"
translation="[388,302]"
maxTextLength="100"
width="505" />
<Button
id="usernameButton"
translation="[373,287]"
text=""
height="80"
maxWidth="535"
minWidth="535"
focusBitmapUri="pkg:/images/settings_focus.9.png"
iconUri="."
focusedIconUri="."/>
<Label
id="passwordHeader"
translation="[388,363]"
color="#2c2621"
text="Password"
horizAlign="left"
vertAlign="top"
height="24"
width="166">
<Font role="font" uri="pkg:/fonts/OpenSans-Semibold.ttf" size="18" />
</Label>
<TextEditBox
id="passwordTextEditBox"
translation="[388,401]"
maxTextLength="100"
width="505"
secureMode="true" />
<Button
id="passwordButton"
translation="[373,386]"
text=""
height="80"
maxWidth="535"
minWidth="535"
focusBitmapUri="pkg:/images/settings_focus.9.png"
iconUri="."
focusedIconUri="."/>
<Group id="loginButtonContainer" translation="[388,477]">
<Rectangle
color="0xfc3154"
width="505"
height="50"/>
<Label
horizAlign="center"
vertAlign="center"
width="505"
height="50"
text="Log in">
<Font role="font" uri="pkg:/fonts/OpenSans-SemiBold.ttf" size="18" />
</Label>
<Button
id="loginButton"
translation="[-15,-15]"
text=""
height="80"
maxWidth="535"
minWidth="535"
focusBitmapUri="pkg:/images/settings_focus.9.png"
iconUri="."
focusedIconUri="."/>
</Group>
<Group id="forgotPasswordButtonContainer" translation="[388,542]">
<OutlinedRectangle
color="0xe0dbd3"
width="505"
height="50"
outlineWidth="2"
outlineColor="0xffffff" />
<Button
id="forgotPasswordButton"
translation="[-15,-15]"
text=""
height="80"
maxWidth="535"
minWidth="535"
focusBitmapUri="pkg:/images/settings_focus.9.png"
iconUri="."
focusedIconUri="."/>
<Label
horizAlign="center"
vertAlign="center"
width="505"
height="50"
text="Forgot Password?"
color="0x2c2724">
<Font role="font" uri="pkg:/fonts/OpenSans-SemiBold.ttf" size="18" />
</Label>
</Group>
</Group>
<Group id="keyboardGroup" visible="false">
<Poster
uri="pkg:/images/df_logo.png"
width="332"
height="66"
translation="[475,100]" />
<Label
id="keyboardHeaderText"
translation="[314,180]"
color="#2c2621"
text="Enter your email or username"
horizAlign="center"
vertAlign="top"
height="40"
width="653"
wrap="true">
<Font role="font" uri="pkg:/fonts/Raleway-Medium.ttf" size="23" />
</Label>
<Keyboard
id="keyboard"
translation="[175,251]"
keyColor="0x2c2724"/>
<Group id="submitButtonContainer" translation="[388,596]">
<Rectangle
color="0xfc3154"
width="505"
height="50"/>
<Label
horizAlign="center"
vertAlign="center"
width="505"
height="50"
text="Submit">
<Font role="font" uri="pkg:/fonts/OpenSans-SemiBold.ttf" size="18" />
</Label>
<Button
id="submitButton"
translation="[-15,-15]"
text=""
height="80"
maxWidth="535"
minWidth="535"
focusBitmapUri="pkg:/images/settings_focus.9.png"
iconUri="."
focusedIconUri="."/>
</Group>
</Group>
</children>
</component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment