# client/pages/login_page.py
import flet as ft
from pages.login_page import Login

class Auth:
    def __init__(self, page: ft.Page):
        self.page = page
        self.email = ft.TextField(label="Email")
        self.passwd = ft.TextField(label="Password", password=True, can_reveal_password=True)
        self.error_message = ft.Text("")
        self.welcome_message = ft.Text(
            "",
            weight=ft.FontWeight.BOLD,
            size=50,
            color= ft.Colors.WHITE
            )
        
        # if self.page.client_storage.get("logo_filename"):
        #     logo_path = f'images/{self.page.client_storage.get("logo_filename")}'  
        # else:
        #     print(f'filename: {self.page.client_storage.get("logo_filename")}')
        logo_path = "images/truck_logo.png"

        self.logo = ft.Image(
            src=logo_path,
            width=400,
            border_radius=20
        )
        self.subtitle = ft.Text(
            "From Order to Action, Instantly.",
            size=20,
            color=ft.Colors.WHITE70
        )
        login = Login(self.page, self)
        self.placeholder = ft.Container(
            content=login.build(), 
            padding=10,
            border_radius=10,
            alignment=ft.alignment.center,
            expand=5
        )

    def build(self):
        return ft.Container(
            content=ft.Row(
                [
                    ft.Container(
                        content = ft.Column(
                            [
                                self.logo,
                                self.subtitle
                            ],
                            horizontal_alignment=ft.CrossAxisAlignment.CENTER,
                            alignment=ft.MainAxisAlignment.CENTER
                        ),
                        expand=5,
                        gradient=ft.RadialGradient(
                            center=ft.Alignment(-0.50, -0.50),
                            radius=1.0,
                            colors=[ft.Colors.BLUE_300, ft.Colors.BLUE_900],
                            tile_mode=ft.GradientTileMode.CLAMP
                        ),
                        shape=ft.BoxShape.CIRCLE,
                        margin=ft.margin.only(left=-180, top=-180)
                    ),
                    self.placeholder,
                ]
            ),
            alignment=ft.alignment.center,
            expand=True,
            padding=0,
            margin=0,
        )