Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions python/apps/reorderablelistview/01_reorderablelistview_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import flet as ft

name = """Reorderable List View example"""

def example():
def handle_reorder(e: ft.OnReorderEvent):
print(f"Reordered from {e.old_index} to {e.new_index}")

get_color = lambda i: ft.Colors.ERROR if i % 2 == 0 else ft.Colors.ON_ERROR_CONTAINER

# horizontal
h = ft.ReorderableListView(
expand=True,
horizontal=True,
on_reorder=handle_reorder,
controls=[
ft.Container(
content=ft.Text(f"Item {i}", color=ft.Colors.BLACK),
bgcolor=get_color(i),
margin=ft.margin.symmetric(horizontal=5, vertical=10),
width=100,
alignment=ft.alignment.center,
)
for i in range(10)
],
)

# vertical
v = ft.ReorderableListView(
expand=True,
on_reorder=handle_reorder,
controls=[
ft.ListTile(
title=ft.Text(f"Item {i}", color=ft.Colors.BLACK),
leading=ft.Icon(ft.Icons.CHECK, color=ft.Colors.RED),
bgcolor=get_color(i),
)
for i in range(10)
],
)

return ft.Column([h, v])
2 changes: 2 additions & 0 deletions python/apps/reorderablelistview/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "ReorderableListView"
description = """A control that allows the user to reorder its children by dragging a handle."""