74 lines
2.5 KiB
Python
74 lines
2.5 KiB
Python
import flet as ft
|
|
from pages.home.applications import Applications
|
|
|
|
class Dashboard:
|
|
def __init__(self, page: ft.Page):
|
|
self.page = page
|
|
self.applications = Applications(self.page, self)
|
|
self.placeholder = ft.Container(
|
|
content=self.applications.build(),
|
|
expand=True
|
|
)
|
|
self.rail = ft.NavigationRail(
|
|
selected_index=0,
|
|
min_width=100,
|
|
min_extended_width=400,
|
|
group_alignment=-0.9,
|
|
leading=ft.Text("Logo"),
|
|
destinations=[
|
|
ft.NavigationRailDestination(
|
|
icon=ft.Icons.LIST_ALT_OUTLINED,
|
|
selected_icon=ft.Icons.LIST_ALT,
|
|
label="Applications",
|
|
),
|
|
ft.NavigationRailDestination(
|
|
icon=ft.Icons.SETTINGS_OUTLINED,
|
|
selected_icon=ft.Icon(ft.Icons.SETTINGS),
|
|
label_content=ft.Text("Settings"),
|
|
),
|
|
ft.NavigationRailDestination(
|
|
icon=ft.Icon(ft.Icons.LOGOUT_OUTLINED),
|
|
selected_icon=ft.Icon(ft.Icons.LOGOUT),
|
|
label="Logout",
|
|
),
|
|
],
|
|
on_change=lambda e: self.navigate(e)
|
|
)
|
|
|
|
def navigate(self, e):
|
|
print(e.data)
|
|
if e.data == '0':
|
|
applications = Applications(self.page, self)
|
|
self.placeholder.content.clean()
|
|
self.placeholder.content = applications.build()
|
|
self.placeholder.update()
|
|
if e.data == '2':
|
|
self.page.client_storage.remove("is_authenticated")
|
|
self.page.go('/auth')
|
|
|
|
def build(self):
|
|
return ft.Container(
|
|
content=ft.Column(
|
|
[
|
|
ft.Row(
|
|
[
|
|
self.rail,
|
|
ft.VerticalDivider(width=1),
|
|
ft.Column(
|
|
[
|
|
self.placeholder
|
|
],
|
|
alignment=ft.MainAxisAlignment.START,
|
|
expand=True
|
|
),
|
|
],
|
|
expand=True,
|
|
alignment=ft.MainAxisAlignment.START,
|
|
vertical_alignment=ft.CrossAxisAlignment.START
|
|
)
|
|
],
|
|
expand=True
|
|
),
|
|
expand=True,
|
|
padding=10
|
|
) |