From a7eca3c6984e3b3ef46d8184e095c2bf338e690b Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Thu, 23 Sep 2021 15:31:38 +0200 Subject: [PATCH 01/22] api and return data handled - UI remaining --- components/keyboardScene.brs | 25 +++++++++++++++++++++++++ components/keyboardScene.xml | 13 +++++++++++++ components/rowListScene.brs | 3 --- components/tasks/httpTask.brs | 35 +++++++++++++++++------------------ components/tasks/httpTask.xml | 2 +- source/main.brs | 2 +- 6 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 components/keyboardScene.brs create mode 100644 components/keyboardScene.xml diff --git a/components/keyboardScene.brs b/components/keyboardScene.brs new file mode 100644 index 0000000..b5f0712 --- /dev/null +++ b/components/keyboardScene.brs @@ -0,0 +1,25 @@ +sub init() + m.keyboard = m.top.findNode("keyboard") + m.keyboard.setFocus(true) + m.queryText = "Please enter something to search for .." + m.keyboard.textEditBox.observeField("text", "handleText") + m.global.addField("http", "node", FALSE) + m.global.http = createObject("roSGNode", "httpTask") + m.global.http.observeFieldScoped("response", "useResponse") + m.global.http.control = "RUN" +end sub + +sub handleText() + m.queryText = m.keyboard.textEditBox.text + m.global.http.request = { payload: {}, url: "https://jsonplaceholder.typicode.com/photos", requestType: "GET" } +end sub + +sub useResponse() + itemsThatContainString = [] + for each item in m.global.http.response.body + if item.title.inStr(m.queryText) + itemsThatContainString.push(item) + end if + end for + ?itemsThatContainString.Count() +end sub \ No newline at end of file diff --git a/components/keyboardScene.xml b/components/keyboardScene.xml new file mode 100644 index 0000000..801b723 --- /dev/null +++ b/components/keyboardScene.xml @@ -0,0 +1,13 @@ + + + + + +