Skip to content

Commit 41eb02f

Browse files
committed
fix: optimize storage page ui for mobile devices
1 parent 4f8e852 commit 41eb02f

1 file changed

Lines changed: 34 additions & 27 deletions

File tree

app/ui/views/storage_view.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,28 @@ async def update_file_list(self):
5555
self.path_display.value = self._["current_path"] + ":" + self.current_path
5656
self.file_list.controls.clear()
5757

58+
if self.current_path != self.root_path:
59+
back_button = ft.ElevatedButton(
60+
self._["go_back"],
61+
icon=ft.icons.ARROW_BACK,
62+
on_click=lambda _: self.app.page.run_task(self.navigate_to_parent)
63+
)
64+
if self.app.is_mobile:
65+
back_item = ft.ListTile(
66+
leading=ft.Icon(ft.icons.ARROW_BACK, color=ft.colors.BLUE),
67+
title=ft.Text(self._["go_back"]),
68+
on_click=lambda _: self.app.page.run_task(self.navigate_to_parent),
69+
)
70+
self.file_list.controls.append(back_item)
71+
else:
72+
self.file_list.controls.append(back_button)
73+
5874
exists, is_empty = await self.check_directory()
5975
if not exists or is_empty:
6076
self.show_empty_folder_message()
6177
self.file_list.update()
6278
return
6379

64-
if self.current_path != self.root_path:
65-
self.file_list.controls.append(
66-
ft.ElevatedButton(
67-
self._["go_back"],
68-
icon=ft.icons.ARROW_BACK,
69-
on_click=lambda _: self.app.page.run_task(self.navigate_to_parent)
70-
)
71-
)
72-
7380
await self.create_file_buttons()
7481

7582
except Exception as e:
@@ -107,28 +114,28 @@ def _get_items():
107114
buttons = []
108115
is_mobile = self.app.is_mobile
109116
for name, is_dir, full_path in items:
110-
if is_dir:
111-
btn = ft.ElevatedButton(
112-
f"📁 {name}",
113-
on_click=lambda e, path=full_path: self.app.page.run_task(self.navigate_to, path)
114-
)
115-
else:
116-
btn = ft.ElevatedButton(
117-
f"📄 {name}",
118-
on_click=lambda e, path=full_path: self.app.page.run_task(self.preview_file, path)
119-
)
120-
121117
if is_mobile:
122-
card = ft.Card(
123-
content=ft.Container(
124-
content=btn,
125-
padding=ft.padding.only(left=0, right=0, top=2, bottom=2),
118+
icon = ft.Icon(ft.icons.FOLDER, color=ft.colors.BLUE) if is_dir else ft.Icon(ft.icons.INSERT_DRIVE_FILE)
119+
item = ft.ListTile(
120+
leading=icon,
121+
title=ft.Text(name),
122+
on_click=lambda e, path=full_path, is_directory=is_dir: self.app.page.run_task(
123+
self.navigate_to if is_directory else self.preview_file,
124+
path
126125
),
127-
elevation=2,
128-
margin=ft.margin.only(bottom=5),
129126
)
130-
buttons.append(card)
127+
buttons.append(item)
131128
else:
129+
if is_dir:
130+
btn = ft.ElevatedButton(
131+
f"📁 {name}",
132+
on_click=lambda e, path=full_path: self.app.page.run_task(self.navigate_to, path)
133+
)
134+
else:
135+
btn = ft.ElevatedButton(
136+
f"📄 {name}",
137+
on_click=lambda e, path=full_path: self.app.page.run_task(self.preview_file, path)
138+
)
132139
buttons.append(btn)
133140

134141
self.file_list.controls.extend(buttons)

0 commit comments

Comments
 (0)