Skip to content

Commit 112f2d7

Browse files
committed
Fix: update ListView properties for better layout and scrolling behavior
1 parent c22c062 commit 112f2d7

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

sdk/python/examples/poc/src/main.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def discover_examples():
3030
if len(parts) < 2:
3131
continue # expect control_name/file.py
3232

33-
control_name = parts[0].replace("_", " ").title()
33+
control_name = "".join(word.title() for word in parts[0].split("_"))
3434
slug = "/".join(parts)
3535
module_name = "examples.controls." + ".".join(parts)
3636

@@ -43,7 +43,6 @@ def discover_examples():
4343
if runner is None:
4444
continue
4545

46-
print(control_name)
4746
controls.setdefault(control_name, []).append({"slug": slug, "runner": runner})
4847

4948
return controls
@@ -55,6 +54,27 @@ def discover_examples():
5554
}
5655

5756

57+
def pretty_example_title(slug: str) -> str:
58+
parts = slug.split("/")
59+
if not parts:
60+
return slug
61+
62+
def prettify(token: str) -> str:
63+
return " ".join(word.title() for word in token.replace("_", " ").split())
64+
65+
rest = parts[1:]
66+
if not rest:
67+
return prettify(parts[0])
68+
69+
# Direct file under control: just show the file name.
70+
if len(rest) == 1:
71+
return prettify(rest[0])
72+
73+
# Subfolders: use the deepest group as the leading label.
74+
groups, leaf = rest[:-1], rest[-1]
75+
return f"{prettify(groups[-1])} / {prettify(leaf)}"
76+
77+
5878
def main(page: ft.Page):
5979
page.title = "Examples POC"
6080
page.padding = 20
@@ -91,14 +111,12 @@ def render_home():
91111
),
92112
ft.ListView(
93113
spacing=4,
94-
height=None,
114+
expand=True,
115+
scroll=ft.ScrollMode.AUTO,
95116
controls=[
96117
ft.ListTile(
97118
title=ft.Text(
98-
ex["slug"]
99-
.split("/")[-1]
100-
.replace("_", " ")
101-
.title(),
119+
value=pretty_example_title(ex["slug"]),
102120
weight=ft.FontWeight.W_600,
103121
),
104122
subtitle=ft.Text(f"/{ex['slug']}"),
@@ -135,7 +153,9 @@ def prepare_page():
135153
page.appbar = None
136154
page.clean()
137155
page.overlay.clear()
156+
page.pop_dialog()
138157
page.floating_action_button = None
158+
page.update()
139159

140160
def render_example(slug: str):
141161
info = EXAMPLES_BY_SLUG.get(slug)

0 commit comments

Comments
 (0)