Skip to content

Commit 3fc9473

Browse files
appstore: install progress bar
1 parent fb96e6c commit 3fc9473

File tree

1 file changed

+14
-6
lines changed
  • internal_filesystem/builtin/apps/com.example.appstore/assets

1 file changed

+14
-6
lines changed

internal_filesystem/builtin/apps/com.example.appstore/assets/appstore.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
install_button = None
99
please_wait_label = None
1010
app_detail_screen = None
11+
progress_bar = None
1112

1213
class App:
1314
def __init__(self, name, publisher, short_description, long_description, icon_url, download_url, fullname, version):
@@ -138,7 +139,7 @@ def create_apps_list():
138139

139140

140141
def show_app_detail(app):
141-
global app_detail_screen, install_button
142+
global app_detail_screen, install_button, progress_bar
142143
app_detail_screen = lv.obj()
143144
app_detail_screen.set_size(lv.pct(100), lv.pct(100))
144145
back_button = lv.button(app_detail_screen)
@@ -174,10 +175,10 @@ def show_app_detail(app):
174175
publisher_label.set_text(app.publisher)
175176
publisher_label.set_style_text_font(lv.font_montserrat_16, 0)
176177
#
177-
#progress_bar = lv.bar(cont)
178-
#progress_bar.set_width(lv.pct(100))
179-
#progress_bar.set_range(0, 100)
180-
#progress_bar.set_value(50, lv.ANIM.OFF)
178+
progress_bar = lv.bar(cont)
179+
progress_bar.add_flag(lv.obj.FLAG.HIDDEN)
180+
progress_bar.set_width(lv.pct(100))
181+
progress_bar.set_range(0, 100)
181182
install_button = lv.button(cont)
182183
install_button.align_to(detail_cont, lv.ALIGN.OUT_BOTTOM_MID, 0, lv.pct(5))
183184
install_button.set_size(lv.pct(100), 40)
@@ -195,14 +196,21 @@ def show_app_detail(app):
195196

196197

197198
def toggle_install(download_url, fullname):
198-
global install_button
199+
global install_button, progress_bar
199200
label = install_button.get_child(0)
200201
if label.get_text() == "(Re)Install Latest Version":
201202
install_button.remove_flag(lv.obj.FLAG.CLICKABLE) # TODO: change color so it's clear the button is not clickable
202203
label.set_text("Please wait...") # TODO: Put "Cancel" if cancellation is possible
204+
progress_bar.remove_flag(lv.obj.FLAG.HIDDEN)
205+
progress_bar.set_value(40, lv.ANIM.OFF)
203206
# TODO: do the download and install in a new thread with a few sleeps so it can be cancelled...
204207
download_and_unzip(download_url, f"/apps/{fullname}")
208+
progress_bar.set_value(80, lv.ANIM.OFF)
209+
time.sleep_ms(500)
210+
progress_bar.set_value(100, lv.ANIM.OFF)
211+
time.sleep(500)
205212
label.set_text("Installed!") # Opening doesn't work because it races along with the launcher to use the screen...
213+
progress_bar.add_flag(lv.obj.FLAG.HIDDEN)
206214
#install_button.add_flag(lv.obj.FLAG.CLICKABLE)
207215
elif label.get_text() == "Open":
208216
print("Open button clicked, starting app...")

0 commit comments

Comments
 (0)