Add notes display functionality to BehaviourPage
This commit is contained in:
parent
caf499180e
commit
84283894f8
1 changed files with 48 additions and 2 deletions
|
@ -1,11 +1,57 @@
|
||||||
import flet as ft
|
import flet as ft
|
||||||
from i18n import _
|
from i18n import _
|
||||||
|
from sqlitehandlernr import fetch_all_notes
|
||||||
|
|
||||||
|
|
||||||
def BehaviourPage():
|
def BehaviourPage():
|
||||||
|
notes = fetch_all_notes()
|
||||||
|
|
||||||
|
if not notes:
|
||||||
|
return ft.Container(
|
||||||
|
content=ft.Row([ft.Text(_("No notes yet"), size=20, color=ft.Colors.WHITE)]),
|
||||||
|
expand=True,
|
||||||
|
alignment=ft.alignment.center, # Correct alignment
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
notes_cards = []
|
||||||
|
|
||||||
|
for note in notes:
|
||||||
|
notes_cards.append(
|
||||||
|
ft.Card(
|
||||||
|
content=ft.Container(
|
||||||
|
content=
|
||||||
|
ft.Column([
|
||||||
|
ft.Row([
|
||||||
|
ft.Text(note.name, size=20, color=ft.Colors.WHITE),
|
||||||
|
ft.Chip(label=ft.Text(note.points))
|
||||||
|
], alignment=ft.MainAxisAlignment.SPACE_BETWEEN),
|
||||||
|
ft.Row([
|
||||||
|
ft.Text(note.content, size=14, color=ft.Colors.WHITE70, overflow=ft.TextOverflow.FADE, width=800),
|
||||||
|
], expand=True),
|
||||||
|
ft.Row([
|
||||||
|
ft.Text(note.created_at.strftime("%Y/%m/%d"), size=14, color=ft.Colors.WHITE70),
|
||||||
|
ft.Text(note.creator, size=14, color=ft.Colors.WHITE70),
|
||||||
|
], alignment=ft.MainAxisAlignment.SPACE_BETWEEN)
|
||||||
|
]),
|
||||||
|
padding=10,
|
||||||
|
expand=True,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return ft.Column([
|
return ft.Column([
|
||||||
ft.Text((_("Behaviour")), size=30, weight="bold"),
|
ft.ListView(
|
||||||
ft.Placeholder()
|
controls=[
|
||||||
|
ft.Column(
|
||||||
|
notes_cards[::-1]
|
||||||
|
)
|
||||||
|
],
|
||||||
|
expand=True,
|
||||||
|
spacing=10,
|
||||||
|
padding=10,
|
||||||
|
auto_scroll=False
|
||||||
|
),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue