Skip to content

Commit

Permalink
Render page tasks dinamically
Browse files Browse the repository at this point in the history
Signed-off-by: Simó Albert i Beltran <sim6@bona.gent>
  • Loading branch information
sim6 committed May 17, 2024
1 parent 42b3e7a commit 36d4039
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion errands/widgets/base/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self):
Log.debug(f"{self.title} Page: Load")
setattr(State, f"{self.page_name}_page", self)
self.__build_ui()
self.max_tasks = 50
self.update_ui()

# ------ PRIVATE METHODS ------ #
Expand All @@ -45,6 +46,10 @@ def __build_ui(self):
maximum_size=1000, tightening_threshold=300, child=self.task_list
),
)
content.get_vadjustment().connect(
"value-changed", self.on_vadjustment_value_changed
)

self.status_page.bind_property(
"visible",
content,
Expand All @@ -64,6 +69,16 @@ def __build_ui(self):
)
)

def on_vadjustment_value_changed(self, adjustment):
if (
# Check if the scroll is at the bottom
adjustment.get_value() + adjustment.get_page_size()
>= adjustment.get_upper()
and self.max_tasks < len(self.tasks_data)
):
self.max_tasks += 10
self.update_ui()

# ------ PROPERTIES ------ #

@property
Expand Down Expand Up @@ -95,7 +110,7 @@ def update_status(self):

def update_ui(self):
Log.debug(f"{self.title} Page: Update UI")
tasks = self.tasks_data
tasks = self.tasks_data[: self.max_tasks]
tasks_uids: list[str] = [t.uid for t in tasks]
widgets_uids: list[str] = [t.uid for t in self.tasks]

Expand Down

0 comments on commit 36d4039

Please sign in to comment.