mirror of
https://github.com/britzl/monarch.git
synced 2025-11-26 19:00:53 +01:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68cda52c0d | ||
|
|
81237762be | ||
|
|
8001d370c2 | ||
|
|
ac409eb4c8 | ||
|
|
5f776b0bc4 | ||
|
|
9a47129135 | ||
|
|
4ea29a9efa | ||
|
|
fa7cf75d3a | ||
|
|
bbc4baa5e1 | ||
|
|
0085704614 | ||
|
|
e37b9bde89 | ||
|
|
21b16e1473 | ||
|
|
36291f3762 | ||
|
|
fd5f82c40b | ||
|
|
92bddc742b | ||
|
|
0c0446746c |
16
.github/workflows/ci-workflow.yml
vendored
Normal file
16
.github/workflows/ci-workflow.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_run:
|
||||||
|
name: Build and run
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Run.sh
|
||||||
|
env:
|
||||||
|
DEFOLD_USER: bjorn.ritzl@gmail.com
|
||||||
|
DEFOLD_AUTH: foobar
|
||||||
|
DEFOLD_BOOSTRAP_COLLECTION: /test/test.collectionc
|
||||||
|
run: ./.travis/run.sh
|
||||||
@@ -15,9 +15,7 @@ addons:
|
|||||||
language: java
|
language: java
|
||||||
|
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- oraclejdk11
|
||||||
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|||||||
@@ -188,6 +188,15 @@ Monarch comes with a system for setting up transitions easily in a gui_script us
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
It is also possible to assign transitions to multiple nodes:
|
||||||
|
|
||||||
|
function init(self)
|
||||||
|
self.transition = transitions.create() -- note that no node is passed to transition.create()!
|
||||||
|
.show_in(gui.get_node("node1"), transitions.slide_in_right, gui.EASING_OUTQUAD, 0.6, 0)
|
||||||
|
.show_in(gui.get_node("node2"), transitions.slide_in_right, gui.EASING_OUTQUAD, 0.6, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
The predefined transitions provided by ```monarch.transitions.gui``` are:
|
The predefined transitions provided by ```monarch.transitions.gui``` are:
|
||||||
|
|
||||||
* ```slide_in_right```
|
* ```slide_in_right```
|
||||||
|
|||||||
@@ -677,16 +677,16 @@ function M.show(id, options, data, cb)
|
|||||||
-- close all popups, one by one
|
-- close all popups, one by one
|
||||||
while top.popup do
|
while top.popup do
|
||||||
stack[#stack] = nil
|
stack[#stack] = nil
|
||||||
show_out(top, screen, function()
|
show_out(top, screen, callbacks.track())
|
||||||
assert(coroutine.resume(co))
|
callbacks.yield_until_done()
|
||||||
end)
|
|
||||||
coroutine.yield()
|
|
||||||
top = stack[#stack]
|
top = stack[#stack]
|
||||||
end
|
end
|
||||||
-- unload and transition out from top
|
-- unload and transition out from top
|
||||||
-- unless we're showing the same screen as is already visible
|
-- wait until we are done if showing the same screen as is already visible
|
||||||
if top and top.id ~= screen.id then
|
local same_screen = top and top.id == screen.id
|
||||||
show_out(top, screen, callbacks.track())
|
show_out(top, screen, callbacks.track())
|
||||||
|
if same_screen then
|
||||||
|
callbacks.yield_until_done()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -817,7 +817,13 @@ function M.is_preloading(id)
|
|||||||
local screen = screens[id]
|
local screen = screens[id]
|
||||||
return screen.preloading
|
return screen.preloading
|
||||||
end
|
end
|
||||||
|
function M.is_preloaded(id)
|
||||||
|
assert(id, "You must provide a screen id")
|
||||||
|
id = tohash(id)
|
||||||
|
assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id)))
|
||||||
|
local screen = screens[id]
|
||||||
|
return screen.preloaded
|
||||||
|
end
|
||||||
|
|
||||||
--- Invoke a callback when a specific screen has been preloaded
|
--- Invoke a callback when a specific screen has been preloaded
|
||||||
-- This is mainly useful on app start when wanting to show a screen that
|
-- This is mainly useful on app start when wanting to show a screen that
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ function M.create()
|
|||||||
local callback = nil
|
local callback = nil
|
||||||
local callback_count = 0
|
local callback_count = 0
|
||||||
|
|
||||||
|
local function is_done()
|
||||||
|
return callback_count == 0
|
||||||
|
end
|
||||||
|
|
||||||
local function invoke_if_done()
|
local function invoke_if_done()
|
||||||
if callback_count == 0 and callback then
|
if callback_count == 0 and callback then
|
||||||
local ok, err = pcall(callback)
|
local ok, err = pcall(callback)
|
||||||
@@ -37,6 +41,17 @@ function M.create()
|
|||||||
invoke_if_done()
|
invoke_if_done()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function instance.yield_until_done()
|
||||||
|
local co = coroutine.running()
|
||||||
|
callback = function()
|
||||||
|
coroutine.resume(co)
|
||||||
|
end
|
||||||
|
invoke_if_done()
|
||||||
|
if not is_done() then
|
||||||
|
coroutine.yield()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -405,18 +405,13 @@ return function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("should be able to preload a screen and always keep it loaded", function()
|
it("should be able to preload a screen and always keep it loaded", function()
|
||||||
monarch.show(SCREEN_PRELOAD, nil, { count = 1 })
|
monarch.show(SCREEN_PRELOAD)
|
||||||
assert(wait_until_shown(SCREEN_PRELOAD), "Screen_preload was never shown")
|
assert(wait_until_shown(SCREEN_PRELOAD), "Screen_preload was never shown")
|
||||||
-- first time the screen gets loaded it will increment the count
|
monarch.back()
|
||||||
assert(monarch.data(SCREEN_PRELOAD).count == 2)
|
assert(wait_until_hidden(SCREEN_PRELOAD), "Screen_preload was never hidden")
|
||||||
|
assert(monarch.is_preloaded(SCREEN_PRELOAD))
|
||||||
monarch.show(SCREEN_PRELOAD, { clear = true }, { count = 1 })
|
|
||||||
assert(wait_until_shown(SCREEN_PRELOAD), "Screen_preload was never shown")
|
|
||||||
-- second time the screen gets shown it will already be loaded and not increment the count
|
|
||||||
assert(monarch.data(SCREEN_PRELOAD).count == 1)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
it("should be able to reload a preloaded screen", function()
|
it("should be able to reload a preloaded screen", function()
|
||||||
monarch.show(SCREEN_PRELOAD, nil, { count = 1 })
|
monarch.show(SCREEN_PRELOAD, nil, { count = 1 })
|
||||||
assert(wait_until_shown(SCREEN_PRELOAD), "Screen_preload was never shown")
|
assert(wait_until_shown(SCREEN_PRELOAD), "Screen_preload was never shown")
|
||||||
|
|||||||
Reference in New Issue
Block a user