Skip to content

Commit 9de4953

Browse files
Fix drawer hide/show issue
1 parent f831171 commit 9de4953

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

internal_filesystem/lib/mpos/ui/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
foreground_app_name=None
3636

37-
animator = WidgetAnimator()
38-
3937
def get_pointer_xy():
4038
indev = lv.indev_active()
4139
if indev:
@@ -80,16 +78,16 @@ def open_drawer():
8078
if not drawer_open:
8179
open_bar()
8280
drawer_open=True
83-
animator.show_widget(drawer, anim_type="slide_down", duration=1000, delay=0)
81+
WidgetAnimator.show_widget(drawer, anim_type="slide_down", duration=1000, delay=0)
8482

8583
def close_drawer(to_launcher=False):
8684
global drawer_open, drawer, foreground_app_name
8785
if drawer_open:
8886
drawer_open=False
89-
animator.hide_widget(drawer, anim_type="slide_up", duration=1000, delay=0)
9087
if not to_launcher and not mpos.apps.is_launcher(foreground_app_name):
9188
print(f"close_drawer: also closing bar because to_launcher is {to_launcher} and foreground_app_name is {foreground_app_name}")
9289
close_bar()
90+
WidgetAnimator.hide_widget(drawer, anim_type="slide_up", duration=1000, delay=0)
9391

9492
def open_bar():
9593
print("opening bar...")

internal_filesystem/lib/mpos/ui/anim.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def hide_widget(widget, anim_type="fade", duration=500, delay=0):
9595
anim.set_custom_exec_cb(lambda anim, value: widget.set_y(value))
9696
anim.set_path_cb(lv.anim_t.path_ease_in_out)
9797
# Set HIDDEN flag after animation
98-
anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget))
98+
anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget, original_y))
9999
elif anim_type == "slide_up":
100100
print("hide with slide_up")
101101
# Create slide-up animation (y from original y to -height)
@@ -110,18 +110,18 @@ def hide_widget(widget, anim_type="fade", duration=500, delay=0):
110110
anim.set_custom_exec_cb(lambda anim, value: widget.set_y(value))
111111
anim.set_path_cb(lv.anim_t.path_ease_in_out)
112112
# Set HIDDEN flag after animation
113-
anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget))
113+
anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget, original_y))
114114

115115
# Store and start animation
116116
#self.animations[widget] = anim
117117
anim.start()
118118

119119
@staticmethod
120-
def hide_complete_cb(widget):
120+
def hide_complete_cb(widget, original_y=None):
121121
#print("hide_complete_cb")
122122
widget.add_flag(lv.obj.FLAG.HIDDEN)
123-
#if original_y:
124-
# widget.set_y(original_y) # in case it shifted slightly due to rounding etc
123+
if original_y:
124+
widget.set_y(original_y) # in case it shifted slightly due to rounding etc
125125

126126

127127
def smooth_show(widget):

0 commit comments

Comments
 (0)