From 5e3e66ae5aa8d5c0162b82fa2c260153ae8c9e09 Mon Sep 17 00:00:00 2001
From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com>
Date: Sun, 10 Oct 2021 13:38:04 +0200
Subject: [PATCH] timer pt1
---
.gitignore | 2 ++
components/rowListContent.brs | 2 +-
components/rowListContent.xml | 2 +-
components/rowListItem.xml | 2 +-
components/rowListScene.brs | 62 ++++++++++++++++++++++++-----------
components/rowListScene.xml | 11 +++++--
6 files changed, 55 insertions(+), 26 deletions(-)
diff --git a/.gitignore b/.gitignore
index fa001aa..a2a1892 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
out/
out/roku-deploy.zip
+.history/
+.vscode
\ No newline at end of file
diff --git a/components/rowListContent.brs b/components/rowListContent.brs
index a37fbf2..24c6956 100644
--- a/components/rowListContent.brs
+++ b/components/rowListContent.brs
@@ -2,7 +2,7 @@ sub init()
m.global.http.request = { payload: {
userId: 1,
title: "WOW, IT WORKED ^_^",
- }, url: "https://jsonplaceholder.typicode.com/albums", requestType: "GET"}
+ }, url: "https://jsonplaceholder.typicode.com/albums", requestType: "GET" }
m.global.http.observeFieldScoped("response", "useResponse")
end sub
diff --git a/components/rowListContent.xml b/components/rowListContent.xml
index 28e7d8e..f70ce16 100644
--- a/components/rowListContent.xml
+++ b/components/rowListContent.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/components/rowListItem.xml b/components/rowListItem.xml
index 65e51b9..897af09 100644
--- a/components/rowListItem.xml
+++ b/components/rowListItem.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/components/rowListScene.brs b/components/rowListScene.brs
index 22d7821..ac6aaf5 100644
--- a/components/rowListScene.brs
+++ b/components/rowListScene.brs
@@ -1,23 +1,45 @@
sub init()
- m.global.addField("http", "node", FALSE)
- m.global.addField("ratio", "float", FALSE)
- m.global.http = createObject("roSGNode", "httpTask")
- m.global.http.control = "RUN"
- m.global.ratio = 1
- m.rowList = m.top.findNode("mainRowList")
- m.rowList.content = createObject("roSGNode", "RowListContent")
- m.rowList.setFocus(true)
- videoMode = createObject("roDeviceInfo")
- if videoMode.GetVideoMode() = "720p"
- m.global.ratio = 0.66
+ initGetNodes()
+ m.btnGroup.setFocus(true)
+ initObservers()
+end sub
+
+sub initGetNodes()
+ m.btnGroup = m.top.findNode("btnGroup")
+ m.start = m.btnGroup.findNode("start")
+ m.stopTimer = m.btnGroup.findNode("stopTimer")
+ ' m.timer = m.top.findNode("timer")
+ m.timeLabel = m.top.findNode("timeLabel")
+end sub
+
+sub initObservers()
+ m.start.observeField("buttonSelected", "start")
+ m.stopTimer.observeField("buttonSelected", "stopTimer")
+ m.timer = createObject("roTimespan")
+ ' m.timer.observeField("fire", "changeText")
+end sub
+
+sub start()
+ m.timeLabel.text = "00:00"
+ m.timer.Mark()
+end sub
+
+sub stopTimer()
+ time = m.timer.TotalSeconds()
+ if time MOD 60 = 0
+ seconds = "00"
+ minutes = Str(time / 60)
+ else
+ minutes = Str(INT(time / 60))
+ seconds = Str(INT(time MOD 60))
end if
- if m.global.ratio = 0.66
- m.rowList.rowHeights = [Cdbl(m.rowList.rowHeights[0] * m.global.ratio) + 10]
- m.rowList.rowItemSpacing = [[5, 0]]
- m.rowList.focusXOffset = [Cdbl(m.rowList.focusXOffset[0] * m.global.ratio) - 50]
- m.rowList.rowItemSize = [[INT(m.rowList.rowItemSize[0][0] * m.global.ratio) + 20, INT(m.rowList.rowItemSize[0][1] * m.global.ratio)]]
- m.rowList.translation = [INT(m.rowList.translation[0] * m.global.ratio), INT(m.rowList.translation[1] / m.global.ratio) - 100]
- m.rowList.rowLabelOffset = [[INT(m.rowList.rowLabelOffset[0][0] * m.global.ratio), INT(m.rowList.rowLabelOffset[0][1] * m.global.ratio) - 6]]
- m.rowList.itemSize = [1400, INT(m.rowList.itemSize[1] * m.global.ratio)]
+ minutes = minutes.trim()
+ seconds = seconds.trim()
+ if Len(minutes) = 1
+ minutes = "0" + minutes
end if
-end sub
+ if Len(seconds) = 1
+ seconds = "0" + seconds
+ end if
+ m.timeLabel.text = minutes + ":" + seconds
+end sub
\ No newline at end of file
diff --git a/components/rowListScene.xml b/components/rowListScene.xml
index bc7e6b9..e9f270e 100644
--- a/components/rowListScene.xml
+++ b/components/rowListScene.xml
@@ -1,7 +1,12 @@
-
-
+
+
-
+
+
+
+
+
+
\ No newline at end of file