<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Roku Corp.  All Rights Reserved. -->
<component name="Expired" extends="Group" initialFocus="Button">
	<script type="text/brightscript" >
		 <![CDATA[
		
			sub init()
			  m.button = m.top.findNode("buttons")
			  m.button.setFocus(true)
			  m.button.observeField("itemSelected","showDialog")
			end sub
			
			sub showDialog()
				dialog = createObject("roSGNode", "Dialog")
				dialog.message = "Are you sure you want to Unlink Device?"
				dialog.buttons = ["Yes", "No"]
				dialog.observeField("buttonSelected", "ButtonSelected")
				m.top.getScene().dialog = dialog
			end sub
			
			sub ButtonSelected()
				if m.top.getScene().dialog.buttonSelected = 0
				'print "In unlink()"
				  m.unlinkTask = createObject("roSGNode","unlinkTask")
				  m.unlinkTask.observeField("state","unlinkDone")
		          m.busyDialog = createObject("roSGNode", "ProgressDialog")
		          m.top.getScene().dialog = m.busyDialog
				else
				  m.top.getScene().dialog.close = true
				end if
			end sub
			
			
			
			sub unlinkDone()
			    'print "in unlinkDone()"
			    if m.unlinkTask.state = "stop" then
			        if m.unlinkTask.validated then
			            m.busyDialog.close = true 
			            m.dialog = createObject("roSGNode", "Dialog")
			            m.dialog.title = "Unlinked Successfully"
			            m.dialog.optionsDialog = true
			            m.dialog.message = "You have successfully unlinked this device from your account" 
				        m.dialog.buttons = ["OK"]
                        m.dialog.observeField("buttonSelected", "unlinkSuccess")
			            m.top.getScene().dialog = m.dialog
			        else 
			        	m.busyDialog.close = true 
			            m.dialog = createObject("roSGNode", "Dialog")
			            m.dialog.title = "Unlinking Failed"
			            m.dialog.optionsDialog = true
			            m.dialog.message = "The unlinking process failed." 
				        m.dialog.buttons = ["OK"]
                        m.dialog.observeField("buttonSelected", "showExitButton")
			            m.top.getScene().dialog = m.dialog
			        end if 
			    end if
			 end sub
			  
			 sub unlinkSuccess()
			    m.top.getScene().close = true
			 end sub
			 
			 sub showExitButton()
			    m.top.getScene().dialog.close = true
			 end sub

		]]>

  	</script>
	<interface>
		<!-- Main menu close handler -->
		<field id="close" type="bool"/>
	</interface>
  <children>

    <Rectangle
      opacity="0.9"
      color="#000000"
	  translation="[350,340]"
      width="1200"
      height="380"/>

    <Label
      font="font:LargeBoldSystemFont"
      height="100"
	  horizAlign = "center"
	  translation="[600,350]"
      text="Your Account has been Expired" />

    <Label
      font="font:MediumBoldSystemFont"
      width="900"
	  height="220"
      wrap="true"
	  translation="[400,440]"
      text="Your account has expired for some reason, to see what your reason was, contact your provider and you will get help to restore your account and enjoy your service again." />
	  
    <Poster
	  uri="pkg:/images/aviso.png"
      translation="[1280, 560]"
      width="200"
      height="150" 
      loadDisplayMode="scaleToFit"/>
	<LabelList
	  id="buttons"
	  translation="[1300, 980]"
	  textHorizAlign="center">
			<ContentNode id = "buttonsContent" role = "content" >
		    	<ContentNode title="Unlink Device" />
		    </ContentNode>
	</LabelList> 

  </children>

</component>
