-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample.gui_script
More file actions
81 lines (67 loc) · 2.08 KB
/
Copy pathsample.gui_script
File metadata and controls
81 lines (67 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
local flow = require "flow/flow"
local bottom_sheet_sample = require "sample/screens/bottom_sheet/shared"
local function animate_new_multipliers(self, dt, nav)
if not nav then return false end
local current_screen = nav.current()
local params = current_screen and current_screen.params or nil
local multipliers = params and params.multipliers or nil
if not multipliers then return false end
local needs_invalidate = false
for _, mult in ipairs(multipliers) do
if mult.is_new then
mult.anim_progress = (mult.anim_progress or 0) + dt / 0.3
if mult.anim_progress >= 1 then
mult.anim_progress = 1
mult.is_new = false
else
needs_invalidate = true
end
end
end
if needs_invalidate then
nav.invalidate()
end
return needs_invalidate
end
local function handle_bottom_sheet_result(self, message_id, message)
if message_id ~= bottom_sheet_sample.DISMISSED_MESSAGE_ID then
return false
end
local nav = self.navigation
local current = nav and nav.current() or nil
if not current or current.id ~= "bottom_sheet_demo" then
return false
end
local params = current.params or {}
local sheet_params = message and message.params or {}
params.sheet_active = false
params.sheet_type = sheet_params.sheet_type or params.sheet_type or "actions"
params.sheet_size = sheet_params.sheet_size or params.sheet_size or "half"
params.last_action = sheet_params.last_action or params.last_action
params.message = message and message.result or "Dismissed by backdrop"
nav.invalidate()
return true
end
function init(self)
flow.init(self, {
on_update = animate_new_multipliers,
on_message = handle_bottom_sheet_result,
})
end
function final(self)
flow.final(self)
end
function update(self, dt)
flow.update(self, dt)
end
function on_message(self, message_id, message, sender)
flow.on_message(self, message_id, message, sender)
end
function on_input(self, action_id, action)
return flow.on_input(self, action_id, action)
end
function on_reload(self)
-- Add reload-handling code here
-- Learn more: https://defold.com/manuals/hot-reload/
-- Remove this function if not needed
end