3
0
mirror of https://github.com/britzl/monarch.git synced 2025-09-28 02:22:20 +02:00

Added support for collection factories

This commit is contained in:
Björn Ritzl
2018-07-27 13:28:36 +02:00
parent 3a7187b844
commit 3443484cce
8 changed files with 322 additions and 119 deletions

View File

@@ -1,7 +1,7 @@
local monarch
go.property("screen_proxy", msg.url("#collectionproxy"))
go.property("screen_id", hash(""))
go.property("screen_id", hash("UNIQUE ID HERE"))
go.property("popup", false)
go.property("popup_on_popup", false)
go.property("timestep_below_popup", 1)
@@ -10,19 +10,22 @@ go.property("focus_url", msg.url())
function init(self)
print("WARNING - screen.script is deprecated. Please use screen_proxy.script")
monarch = require "monarch.monarch"
local url = msg.url()
assert(not self.popup_on_popup or (self.popup_on_popup and self.popup), "Popup on Popups can only be set if the Popup flag is set")
monarch.register(
self.screen_id,
self.screen_proxy,
{
popup = self.popup,
popup_on_popup = self.popup_on_popup,
transition_url = self.transition_url,
focus_url = self.focus_url,
timestep_below_popup = self.timestep_below_popup,
}
)
assert(self.screen_proxy ~= url, "You must specify either a proxy URL")
assert(self.timestep_below_popup >= 0, "Timestep must be positive")
local settings = {
popup = self.popup,
popup_on_popup = self.popup_on_popup,
transition_url = self.transition_url ~= url and self.transition_url or nil,
focus_url = self.focus_url ~= url and self.focus_url or nil,
timestep_below_popup = self.timestep_below_popup,
}
monarch.register_proxy(self.screen_id, self.screen_proxy, settings)
end
function final(self)
@@ -36,11 +39,6 @@ function on_message(self, message_id, message, sender)
monarch.back()
elseif message_id == hash("back") then
monarch.back()
elseif message_id == monarch.TRANSITION.SHOW_IN
or message_id == monarch.TRANSITION.SHOW_OUT
or message_id == monarch.TRANSITION.BACK_IN
or message_id == monarch.TRANSITION.BACK_OUT then
msg.post(sender, monarch.TRANSITION.DONE)
else
monarch.on_message(message_id, message, sender)
end