Skip to content

Commit c243bb4

Browse files
Bar is shown in launcher and animates away in other apps
1 parent 9fc1ee7 commit c243bb4

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

internal_filesystem/main.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,24 @@
5555
def open_drawer():
5656
global drawer_open
5757
if not drawer_open:
58+
show_bar_animation.start()
5859
drawer_open=True
59-
notification_bar.set_pos(0,0)
60-
notification_bar.remove_flag(lv.obj.FLAG.HIDDEN)
6160
drawer.remove_flag(lv.obj.FLAG.HIDDEN)
6261

63-
def close_drawer():
62+
def close_drawer(to_launcher=False):
6463
global drawer_open
6564
if drawer_open:
6665
drawer_open=False
6766
drawer.add_flag(lv.obj.FLAG.HIDDEN)
68-
animation.start()
67+
if not to_launcher:
68+
hide_bar_animation.start()
6969

70-
def toggle_drawer(event):
71-
global drawer_open
72-
if drawer_open:
73-
close_drawer()
74-
else:
75-
open_drawer()
7670

77-
78-
# Create notification bar object
71+
# Create notification bar
7972
notification_bar = lv.obj(lv.layer_top())
8073
notification_bar.set_style_bg_color(COLOR_NOTIF_BAR_BG, 0)
8174
notification_bar.set_size(TFT_HOR_RES, NOTIFICATION_BAR_HEIGHT)
8275
notification_bar.set_pos(0, 0)
83-
notification_bar.add_flag(lv.obj.FLAG.HIDDEN)
8476
notification_bar.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
8577
notification_bar.set_scroll_dir(lv.DIR.VER)
8678
notification_bar.set_style_border_width(0, 0)
@@ -155,12 +147,20 @@ def update_memfree(timer):
155147
#notification_bar.add_event_cb(toggle_drawer, lv.EVENT.CLICKED, None)
156148

157149
# hide bar animation
158-
animation = lv.anim_t()
159-
animation.init()
160-
animation.set_var(notification_bar)
161-
animation.set_values(0, -NOTIFICATION_BAR_HEIGHT)
162-
animation.set_time(2000)
163-
animation.set_custom_exec_cb(lambda not_used, value : notification_bar.set_y(value))
150+
hide_bar_animation = lv.anim_t()
151+
hide_bar_animation.init()
152+
hide_bar_animation.set_var(notification_bar)
153+
hide_bar_animation.set_values(0, -NOTIFICATION_BAR_HEIGHT)
154+
hide_bar_animation.set_time(2000)
155+
hide_bar_animation.set_custom_exec_cb(lambda not_used, value : notification_bar.set_y(value))
156+
157+
# show bar animation
158+
show_bar_animation = lv.anim_t()
159+
show_bar_animation.init()
160+
show_bar_animation.set_var(notification_bar)
161+
show_bar_animation.set_values(-NOTIFICATION_BAR_HEIGHT, 0)
162+
show_bar_animation.set_time(1000)
163+
show_bar_animation.set_custom_exec_cb(lambda not_used, value : notification_bar.set_y(value))
164164

165165

166166
drawer=lv.obj(lv.layer_top())
@@ -229,7 +229,7 @@ def wifi_event(e):
229229
def launcher_event(e):
230230
print("Launcher button pressed!")
231231
global drawer_open,rootscreen
232-
close_drawer()
232+
close_drawer(True)
233233
lv.screen_load(rootscreen)
234234

235235
launcher_btn.add_event_cb(launcher_event,lv.EVENT.CLICKED,None)
@@ -357,10 +357,11 @@ def start_app(app_dir, is_launcher=False):
357357
app_name, start_script = parse_manifest(manifest_path)
358358
start_script_fullpath = f"{app_dir}/{start_script}"
359359
execute_script_new_thread(start_script_fullpath, True, is_launcher, True)
360-
# Show notification bar, then start animation to hide it
361-
notification_bar.set_pos(0,0)
362-
notification_bar.remove_flag(lv.obj.FLAG.HIDDEN)
363-
animation.start()
360+
# Launchers have the bar, other apps don't have it
361+
if is_launcher:
362+
show_bar_animation.start()
363+
else:
364+
hide_bar_animation.start()
364365

365366
def restart_launcher():
366367
# The launcher might have been updated from the builtin one, so check that:

0 commit comments

Comments
 (0)