mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 10:27:49 +02:00
48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
local monarch
|
|
|
|
go.property("screen_proxy", msg.url("#collectionproxy"))
|
|
go.property("screen_id", hash(""))
|
|
go.property("popup", false)
|
|
go.property("popup_on_popup", false)
|
|
go.property("timestep_below_popup", 1)
|
|
go.property("transition_url", msg.url())
|
|
go.property("focus_url", msg.url())
|
|
|
|
|
|
function init(self)
|
|
monarch = require "monarch.monarch"
|
|
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,
|
|
}
|
|
)
|
|
end
|
|
|
|
function final(self)
|
|
monarch.unregister(self.screen_id)
|
|
end
|
|
|
|
function on_message(self, message_id, message, sender)
|
|
if message_id == hash("show") then
|
|
monarch.show(self.screen_id, { clear = message.clear })
|
|
elseif message_id == hash("hide") then
|
|
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
|
|
end
|