new intarfece
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
import flet as ft
|
||||
|
||||
# Глобальный масштаб интерфейса. 1.0 = 100%, 1.7 = 170%.
|
||||
# Меняйте только эту константу, чтобы масштабировать весь UI.
|
||||
SCALE: float = 1.7
|
||||
|
||||
|
||||
def s(v: int | float) -> int:
|
||||
"""Применяет SCALE к любому размеру: шрифтам, отступам, ицих."""
|
||||
return round(v * SCALE)
|
||||
|
||||
|
||||
class clolors:
|
||||
background = "#C8B1E4"
|
||||
laer1 = "#9B72CF"
|
||||
laer2 = "#532B88"
|
||||
laer3 = "#2F184B"
|
||||
ferst = "#F4EFFA"
|
||||
background = "#C0DE9E"
|
||||
laer1 = "#FFEAB7"
|
||||
laer2 = "#D9F1F4"
|
||||
laer3 = "#D2EA32"
|
||||
ferst = "#85C446"
|
||||
|
||||
class CastomText(ft.Text):
|
||||
def __init__(self, text, size=14, color=clolors.ferst, weight=ft.FontWeight.NORMAL):
|
||||
super().__init__(
|
||||
value=text,
|
||||
color=color,
|
||||
size=size,
|
||||
size=s(size),
|
||||
weight=weight,
|
||||
max_lines=99,
|
||||
)
|
||||
@@ -26,19 +36,22 @@ class CastomTextField_input(ft.TextField):
|
||||
filled=True, # заливка фона
|
||||
bgcolor=clolors.ferst, # цвет заливки
|
||||
border_color=clolors.laer2, # цвет границы
|
||||
border_radius=12, # скругление углов
|
||||
border_radius=s(12), # скругление углов
|
||||
label_style=ft.TextStyle(
|
||||
color=clolors.laer3,
|
||||
size=s(14),
|
||||
weight=ft.FontWeight.BOLD,
|
||||
),
|
||||
hint_style=ft.TextStyle(
|
||||
color=clolors.laer1,
|
||||
size=s(14),
|
||||
italic=True,
|
||||
),
|
||||
text_style=ft.TextStyle(
|
||||
color=clolors.laer3,
|
||||
size=16,
|
||||
size=s(16),
|
||||
),
|
||||
content_padding=ft.padding.symmetric(horizontal=s(12), vertical=s(14)),
|
||||
prefix_icon=prefix_icon,
|
||||
suffix_icon=suffix_icon,
|
||||
on_change=on_change,
|
||||
@@ -54,8 +67,9 @@ class CastomButton(ft.Button):
|
||||
color=clolors.ferst,
|
||||
bgcolor=clolors.laer1,
|
||||
text_style=ft.TextStyle(
|
||||
size=14
|
||||
)
|
||||
size=s(14)
|
||||
),
|
||||
padding=ft.padding.symmetric(horizontal=s(16), vertical=s(10)),
|
||||
),
|
||||
on_click=on_click
|
||||
)
|
||||
@@ -66,17 +80,18 @@ class CastomIconButton(ft.Button):
|
||||
def __init__(self, text, icon, on_click):
|
||||
super().__init__(
|
||||
content=ft.Row(
|
||||
spacing=8,
|
||||
spacing=s(8),
|
||||
tight=True,
|
||||
controls=[
|
||||
ft.Icon(icon, color=clolors.ferst, size=18),
|
||||
ft.Text(text, color=clolors.ferst, size=14),
|
||||
ft.Icon(icon, color=clolors.ferst, size=s(18)),
|
||||
ft.Text(text, color=clolors.ferst, size=s(14)),
|
||||
],
|
||||
),
|
||||
style=ft.ButtonStyle(
|
||||
color=clolors.ferst,
|
||||
bgcolor=clolors.laer2,
|
||||
text_style=ft.TextStyle(size=14),
|
||||
text_style=ft.TextStyle(size=s(14)),
|
||||
padding=ft.padding.symmetric(horizontal=s(16), vertical=s(10)),
|
||||
),
|
||||
on_click=on_click,
|
||||
)
|
||||
@@ -91,19 +106,21 @@ class CastomDropdown(ft.Dropdown):
|
||||
fill_color=clolors.laer3,
|
||||
color=clolors.ferst,
|
||||
border_color=clolors.laer2,
|
||||
border_radius=12,
|
||||
border_radius=s(12),
|
||||
focused_border_color=clolors.laer1,
|
||||
label_style=ft.TextStyle(
|
||||
color=clolors.ferst,
|
||||
size=s(14),
|
||||
weight=ft.FontWeight.BOLD,
|
||||
),
|
||||
hint_style=ft.TextStyle(
|
||||
color=clolors.laer1,
|
||||
size=s(14),
|
||||
italic=True,
|
||||
),
|
||||
text_style=ft.TextStyle(
|
||||
color=clolors.ferst,
|
||||
size=16,
|
||||
size=s(16),
|
||||
),
|
||||
menu_style=ft.MenuStyle(
|
||||
bgcolor=clolors.laer3,
|
||||
@@ -117,8 +134,7 @@ class CastomSwitch(ft.Switch):
|
||||
def __init__(self, label, on_change):
|
||||
super().__init__(
|
||||
label=label,
|
||||
width=400,
|
||||
label_text_style=ft.TextStyle(size=14, color=clolors.ferst),
|
||||
label_text_style=ft.TextStyle(size=s(12), color=clolors.ferst),
|
||||
active_color=clolors.ferst,
|
||||
active_track_color=clolors.laer1,
|
||||
inactive_thumb_color=clolors.laer2,
|
||||
@@ -128,7 +144,8 @@ class CastomSwitch(ft.Switch):
|
||||
|
||||
|
||||
class AlterDiaalogApproval(ft.AlertDialog):
|
||||
def __init__(self):
|
||||
def __init__(self, on_accept=None):
|
||||
self._on_accept = on_accept
|
||||
|
||||
self.switch_approval = CastomSwitch(
|
||||
label="Я согласен с условиями пользовательского соглашения",
|
||||
@@ -139,14 +156,23 @@ class AlterDiaalogApproval(ft.AlertDialog):
|
||||
text="Принять",
|
||||
on_click=self.accept
|
||||
)
|
||||
self.button_approval.disabled = True
|
||||
|
||||
super().__init__(
|
||||
title=ft.Text("Пользовательское соглашение"),
|
||||
content=ft.Column(
|
||||
width=400,
|
||||
height=600,
|
||||
scroll="auto",
|
||||
controls=[
|
||||
bgcolor=clolors.laer3,
|
||||
title=ft.Text(
|
||||
"Пользовательское соглашение",
|
||||
color=clolors.ferst,
|
||||
size=s(16),
|
||||
weight=ft.FontWeight.BOLD,
|
||||
),
|
||||
content=ft.Container(
|
||||
width=s(350),
|
||||
height=s(400),
|
||||
content=ft.Column(
|
||||
scroll=ft.ScrollMode.AUTO,
|
||||
expand=True,
|
||||
controls=[
|
||||
ft.Markdown(
|
||||
"""
|
||||
# ПОЛЬЗОВАТЕЛЬСКОЕ СОГЛАШЕНИЕ
|
||||
@@ -265,20 +291,31 @@ class AlterDiaalogApproval(ft.AlertDialog):
|
||||
|
||||
*Соглашение соответствует законодательству Российской Федерации, включая Федеральный закон «О защите персональных данных» и Федеральный закон «О защите прав потребителей».*
|
||||
""",
|
||||
width=400,
|
||||
expand=True,
|
||||
md_style_sheet=ft.MarkdownStyleSheet(
|
||||
p_text_style=ft.TextStyle(color=clolors.ferst, size=s(12)),
|
||||
h1_text_style=ft.TextStyle(color=clolors.ferst, size=s(18), weight=ft.FontWeight.BOLD),
|
||||
h2_text_style=ft.TextStyle(color=clolors.ferst, size=s(15), weight=ft.FontWeight.BOLD),
|
||||
h3_text_style=ft.TextStyle(color=clolors.laer1, size=s(13), weight=ft.FontWeight.BOLD),
|
||||
a_text_style=ft.TextStyle(color=clolors.laer1),
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
actions=[
|
||||
ft.Column(
|
||||
width=400,
|
||||
width=s(350),
|
||||
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
|
||||
controls=[
|
||||
ft.Row(
|
||||
expand=True,
|
||||
alignment=ft.MainAxisAlignment.START,
|
||||
controls=[
|
||||
self.switch_approval,
|
||||
ft.Container(
|
||||
width=s(330),
|
||||
content=self.switch_approval,
|
||||
),
|
||||
]
|
||||
),
|
||||
ft.Row(
|
||||
@@ -300,7 +337,9 @@ class AlterDiaalogApproval(ft.AlertDialog):
|
||||
self.update()
|
||||
|
||||
def accept(self, e):
|
||||
self.dialog_result = True
|
||||
self.open = False
|
||||
self.page.update()
|
||||
self.page.run_task(self.page.push_route, "/login")
|
||||
if self._on_accept:
|
||||
self._on_accept()
|
||||
else:
|
||||
self.page.run_task(self.page.push_route, "/reg")
|
||||
Reference in New Issue
Block a user