3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-27 02:17:53 +02:00
Monarch-Extension/monarch/screen.script
2017-09-04 12:01:57 +02:00

47 lines
1.5 KiB
Plaintext

local monarch = require "monarch.monarch"
go.property("screen_proxy", msg.url("#collectionproxy"))
go.property("screen_id", hash(""))
go.property("popup", false)
go.property("transition_show_in", msg.url())
go.property("transition_show_out", msg.url())
go.property("transition_back_in", msg.url())
go.property("transition_back_out", msg.url())
function init(self)
print("screen init", self.proxy)
monarch.register(self.screen_id, self.screen_proxy, self.popup, {
show_in = self.transition_show_in,
show_out = self.transition_show_out,
back_in = self.transition_back_in,
back_out = self.transition_back_out,
})
end
function final(self)
print("screen final", self.proxy)
monarch.unregister(self.screen_id)
end
function on_message(self, message_id, message, sender)
print("screen on_message", message_id, sender)
if message_id == hash("show") then
monarch.show(self.screen_id, message.clear)
elseif message_id == hash("hide") then
monarch.hide(self.screen_id)
elseif message_id == hash("back") then
monarch.hide(self.screen_id)
elseif message_id == hash("transition_show_in") then
msg.post(sender, "transition_done")
elseif message_id == hash("transition_show_out") then
msg.post(sender, "transition_done")
elseif message_id == hash("transition_back_in") then
msg.post(sender, "transition_done")
elseif message_id == hash("transition_back_out") then
msg.post(sender, "transition_done")
else
monarch.on_message(message_id, message, sender)
end
end