app/modules/home.py

125 lines
4.5 KiB
Python
Raw Normal View History

2024-04-19 16:59:43 +00:00
import flet as ft
from utils import AppView, Title
from modules.settings import config
2024-04-20 03:43:58 +00:00
from datetime import datetime
def greet(time: datetime):
if 5 <= time.hour < 12:
2024-04-20 08:00:17 +00:00
return 'Goodmorning,'
2024-04-20 03:43:58 +00:00
elif 12 <= time.hour < 18:
2024-04-20 08:00:17 +00:00
return 'Goodafternoon,'
2024-04-20 03:43:58 +00:00
else:
2024-04-20 08:00:17 +00:00
return 'Goodevening,'
2024-04-19 16:59:43 +00:00
2024-04-19 20:02:44 +00:00
2024-04-20 16:59:36 +00:00
AppRow = ft.ResponsiveRow(
alignment=ft.MainAxisAlignment.CENTER,
)
2024-04-19 16:59:43 +00:00
def Home(page: ft.Page):
2024-04-20 03:43:58 +00:00
contentColumn = ft.Container(
padding=10,
content=ft.Column(
controls=[
ft.Text(
greet(datetime.now()),
size=50,
2024-04-20 16:59:36 +00:00
weight=ft.FontWeight.W_500,
2024-04-20 03:43:58 +00:00
),
ft.Text(
2024-04-20 08:00:17 +00:00
config.get('general', 'name').split(' ')[0],
2024-04-20 03:43:58 +00:00
size=40,
2024-04-20 16:59:36 +00:00
weight=ft.FontWeight.W_300,
2024-04-20 03:43:58 +00:00
),
ft.Divider(),
2024-04-20 16:59:36 +00:00
AppRow,
2024-04-20 03:43:58 +00:00
ft.Divider(),
ft.Container(
margin=10,
padding=10,
bgcolor=ft.colors.with_opacity(0.1, '#000000'),
border_radius=10,
content=ft.Row(
[
ft.Container(
2024-04-20 16:59:36 +00:00
content=ft.Icon(
ft.icons.APPS, color=ft.colors.WHITE,
),
2024-04-20 03:43:58 +00:00
margin=10,
padding=10,
alignment=ft.alignment.center,
bgcolor=ft.colors.GREY_700,
width=60,
height=60,
border_radius=10,
2024-04-20 16:59:36 +00:00
ink=True,
on_click=lambda _: page.go('/apps'),
2024-04-20 03:43:58 +00:00
),
ft.Container(
2024-04-20 16:59:36 +00:00
content=ft.Icon(
ft.icons.HISTORY, color=ft.colors.WHITE,
),
2024-04-20 03:43:58 +00:00
margin=10,
padding=10,
alignment=ft.alignment.center,
bgcolor=ft.colors.GREY_700,
width=60,
height=60,
border_radius=10,
on_click=None,
),
ft.Container(
2024-04-20 16:59:36 +00:00
content=ft.Icon(
ft.icons.SETTINGS, color=ft.colors.WHITE,
),
2024-04-20 03:43:58 +00:00
margin=10,
padding=10,
alignment=ft.alignment.center,
bgcolor=ft.colors.GREY_700,
width=60,
height=60,
border_radius=10,
ink=True,
2024-04-20 08:00:17 +00:00
on_click=lambda _: page.go('/settings'),
2024-04-20 03:43:58 +00:00
),
ft.Container(
2024-04-20 16:59:36 +00:00
content=ft.Icon(
ft.icons.LIST, color=ft.colors.WHITE,
),
2024-04-20 03:43:58 +00:00
margin=10,
padding=10,
alignment=ft.alignment.center,
bgcolor=ft.colors.GREY_700,
width=60,
height=60,
border_radius=10,
ink=True,
2024-04-20 08:00:17 +00:00
on_click=lambda e: print(
'Clickable with Ink clicked!',
),
2024-04-20 03:43:58 +00:00
),
],
alignment=ft.MainAxisAlignment.CENTER,
),
),
],
),
)
2024-04-19 16:59:43 +00:00
return AppView(
2024-04-19 20:02:44 +00:00
'/',
2024-04-19 16:59:43 +00:00
[
ft.AppBar(
title=ft.Text(Title(__file__)),
2024-04-20 03:43:58 +00:00
# actions=[
# ft.IconButton(
# icon=ft.icons.SETTINGS,
# on_click=lambda _: page.go('/settings'),
# ),
# ],
2024-04-19 16:59:43 +00:00
),
2024-04-20 03:43:58 +00:00
contentColumn,
2024-04-19 16:59:43 +00:00
],
)