-
Notifications
You must be signed in to change notification settings - Fork 2
/
HomeScene.brs
67 lines (67 loc) · 2.74 KB
/
HomeScene.brs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
sub init()
' change to true for testing themes set in /components/data/themes.json
' the setTheme() has a 2nd argument for defining the theme ex. setTheme(true, { "type": "light", "color": "red" })
' ensure that both the "type" and "color" inside the object match the key/values in themes.json
setTheme(true)
' set to true for forcing requirements in /components/data/requirements.json
' set to false to immediately return true and bypass requirements
' optional: test the error message for requirements by changing the minVersion in the requirements.json file from to 20.0
requirements = setRequirements(false)
' start the app if all requirements are met
if requirements then startApp()
end sub
sub startApp()
' create the initial screen stack array in History.brs
initScreenStack()
' create the landing screen node (name) and assign an id
' see REAMDME for additional arguments
addScreen("LandingScreen", "landingScreen")
end sub
function addNode(params as object) as object
' check that the object from params is valid
if (params <> invalid and params.count() > 0)
' check that the screenName value in the object is valid
if (params.screenName <> invalid and len(params.screenName) > 0)
' create the node using the params.screen value
node = createObject("roSGNode", params.screenName)
' check that the created node is valid
if (node <> invalid)
' check if the node ID is not yet assigned
if (node.id = invalid or (node.id <> invalid and len(node.id) = 0))
' check if the screenId is valid and has a string length greater than zero
if (params.screenId <> invalid and len(params.screenId) > 0)
' assign the node ID using params.screenId
node.id = params.screenId
else
' assign the node ID usind params.screenName
node.id = params.screenName
end if
end if
' add the screen to History.brs
if (not addHistory(node, params.showScreen, params.hidePrevScreen, params.addToStack))
' show a console message stating that the node could not be added to HomeScene
? " "
? "there was an error adding " + node.id + " to HomeScene"
else
' set focus to node
node.setFocus(true)
end if
' return the node
return node
end if
end if
end if
end function
sub removeNode(params as object)
if (not removeHistory(params.node, params.showPrevScreen, params.removeFromStack))
' show a console message stating that the node could not be added to HomeScene
? " "
? "there was an error removing the node from HomeScene"
end if
end sub
sub onMessage(obj)
' get the message string
message = obj.getData()
' check that the message string is not invalid and not empty then create message dialog
if message <> invalid and len(message) > 0 then createDialog(getMessage(message))
end sub