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")
|
||||
19
web/main.py
19
web/main.py
@@ -30,6 +30,25 @@ async def _radar_image(request):
|
||||
async def main(page: ft.Page):
|
||||
page.title = "COPP"
|
||||
page.bgcolor = ds.clolors.background
|
||||
# Масштабирование глобального text_theme синхронно с ds.SCALE:
|
||||
# покрывает ft.Text() без явного size (body_medium по умолчанию = 14)
|
||||
_ts = lambda base: ft.TextStyle(size=ds.s(base))
|
||||
page.theme = ft.Theme(
|
||||
text_theme=ft.TextTheme(
|
||||
body_large=_ts(16),
|
||||
body_medium=_ts(14),
|
||||
body_small=_ts(12),
|
||||
label_large=_ts(14),
|
||||
label_medium=_ts(12),
|
||||
label_small=_ts(11),
|
||||
title_large=_ts(22),
|
||||
title_medium=_ts(16),
|
||||
title_small=_ts(14),
|
||||
headline_medium=_ts(28),
|
||||
headline_small=_ts(24),
|
||||
display_small=_ts(36),
|
||||
),
|
||||
)
|
||||
setup_router(page)
|
||||
initial = page.route if page.route and page.route not in ("/", "") else "/login"
|
||||
await page.push_route(initial)
|
||||
|
||||
@@ -4,8 +4,8 @@ import designer as ds
|
||||
class MainPageUser(ft.Column):
|
||||
def __init__(self, page: ft.Page):
|
||||
self._page = page
|
||||
self.spacing_groop = 6
|
||||
self.border_radius = 15
|
||||
self.spacing_groop = ds.s(6)
|
||||
self.border_radius = ds.s(15)
|
||||
|
||||
super().__init__(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
@@ -20,8 +20,8 @@ class MainPageUser(ft.Column):
|
||||
controls=[
|
||||
ft.Container(
|
||||
border_radius=self.border_radius,
|
||||
height=160,
|
||||
width=160,
|
||||
height=ds.s(160),
|
||||
width=ds.s(160),
|
||||
alignment=ft.Alignment(0.0, 0.0),
|
||||
content=ft.Column(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
@@ -31,8 +31,8 @@ class MainPageUser(ft.Column):
|
||||
controls=[
|
||||
ft.Image(
|
||||
src="icons/clipboard-question_16542596.svg",
|
||||
width=100,
|
||||
height=100,
|
||||
width=ds.s(100),
|
||||
height=ds.s(100),
|
||||
)
|
||||
]
|
||||
),
|
||||
@@ -50,8 +50,8 @@ class MainPageUser(ft.Column):
|
||||
),
|
||||
ft.Container(
|
||||
border_radius=self.border_radius,
|
||||
height=160,
|
||||
width=160,
|
||||
height=ds.s(160),
|
||||
width=ds.s(160),
|
||||
alignment=ft.Alignment(0.0, 0.0),
|
||||
content=ft.Column(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
@@ -61,8 +61,8 @@ class MainPageUser(ft.Column):
|
||||
controls=[
|
||||
ft.Image(
|
||||
src="icons/leaderboard-trophy_14227576.svg",
|
||||
width=100,
|
||||
height=100,
|
||||
width=ds.s(100),
|
||||
height=ds.s(100),
|
||||
)
|
||||
]
|
||||
),
|
||||
|
||||
@@ -7,12 +7,12 @@ import api_client
|
||||
class MyTestsPage(ft.Column):
|
||||
def __init__(self, page: ft.Page):
|
||||
self._page = page
|
||||
self._loading = ft.ProgressRing(width=40, height=40, color=ds.clolors.laer1)
|
||||
self._loading = ft.ProgressRing(width=ds.s(40), height=ds.s(40), color=ds.clolors.laer1)
|
||||
|
||||
super().__init__(
|
||||
alignment=ft.MainAxisAlignment.START,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH,
|
||||
spacing=8,
|
||||
spacing=ds.s(8),
|
||||
controls=[
|
||||
ft.Row(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
@@ -56,14 +56,14 @@ class MyTestsPage(ft.Column):
|
||||
|
||||
cards.append(
|
||||
ft.Container(
|
||||
border_radius=12,
|
||||
padding=16,
|
||||
border_radius=ds.s(12),
|
||||
padding=ds.s(16),
|
||||
bgcolor=ds.clolors.laer2,
|
||||
content=ft.Row(
|
||||
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
|
||||
controls=[
|
||||
ft.Column(
|
||||
spacing=4,
|
||||
spacing=ds.s(4),
|
||||
expand=True,
|
||||
controls=[
|
||||
ds.CastomText(
|
||||
|
||||
@@ -20,7 +20,7 @@ class PollPage(ft.Column):
|
||||
controls=[
|
||||
ft.Row(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
controls=[ft.ProgressRing(width=40, height=40, color=ds.clolors.laer1)],
|
||||
controls=[ft.ProgressRing(width=ds.s(40), height=ds.s(40), color=ds.clolors.laer1)],
|
||||
)
|
||||
],
|
||||
)
|
||||
@@ -57,8 +57,8 @@ class PollPage(ft.Column):
|
||||
tight=True,
|
||||
spacing=6,
|
||||
controls=[
|
||||
ft.Icon(ft.Icons.STOP_CIRCLE_OUTLINED, color=ds.clolors.ferst, size=16),
|
||||
ft.Text("Прервать тест", color=ds.clolors.ferst, size=13),
|
||||
ft.Icon(ft.Icons.STOP_CIRCLE_OUTLINED, color=ds.clolors.ferst, size=ds.s(16)),
|
||||
ft.Text("Прервать тест", color=ds.clolors.ferst, size=ds.s(13)),
|
||||
],
|
||||
),
|
||||
style=ft.ButtonStyle(
|
||||
@@ -70,12 +70,12 @@ class PollPage(ft.Column):
|
||||
|
||||
counter_badge = ft.Container(
|
||||
bgcolor=ds.clolors.laer2,
|
||||
border_radius=10,
|
||||
padding=ft.padding.symmetric(horizontal=20, vertical=10),
|
||||
border_radius=ds.s(10),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(20), vertical=ds.s(10)),
|
||||
content=ft.Text(
|
||||
f"Вопрос {idx + 1} из {total}",
|
||||
color=ds.clolors.ferst,
|
||||
size=14,
|
||||
size=ds.s(14),
|
||||
weight=ft.FontWeight.BOLD,
|
||||
text_align=ft.TextAlign.CENTER,
|
||||
),
|
||||
@@ -90,14 +90,14 @@ class PollPage(ft.Column):
|
||||
# --- Блок вопроса (alignment на Container, не вложенный Column) ---
|
||||
question_box = ft.Container(
|
||||
expand=True,
|
||||
border_radius=14,
|
||||
padding=24,
|
||||
border_radius=ds.s(14),
|
||||
padding=ds.s(24),
|
||||
bgcolor=ds.clolors.laer2,
|
||||
alignment=ft.Alignment(0.0, 0.0),
|
||||
content=ft.Text(
|
||||
value=q.get("text", ""),
|
||||
color=ds.clolors.ferst,
|
||||
size=16,
|
||||
size=ds.s(16),
|
||||
weight=ft.FontWeight.BOLD,
|
||||
text_align=ft.TextAlign.CENTER,
|
||||
no_wrap=False,
|
||||
@@ -113,22 +113,22 @@ class PollPage(ft.Column):
|
||||
cid = c["id"]
|
||||
is_selected = cid == selected_choice
|
||||
return ft.Container(
|
||||
border_radius=8,
|
||||
padding=ft.padding.symmetric(horizontal=12, vertical=10),
|
||||
border_radius=ds.s(8),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(12), vertical=ds.s(10)),
|
||||
bgcolor=ds.clolors.laer1 if is_selected else ds.clolors.laer3,
|
||||
content=ft.Row(
|
||||
spacing=10,
|
||||
spacing=ds.s(10),
|
||||
vertical_alignment=ft.CrossAxisAlignment.CENTER,
|
||||
controls=[
|
||||
ft.Icon(
|
||||
ft.Icons.CHECK_CIRCLE if is_selected else ft.Icons.RADIO_BUTTON_UNCHECKED,
|
||||
color=ds.clolors.ferst,
|
||||
size=20,
|
||||
size=ds.s(20),
|
||||
),
|
||||
ft.Text(
|
||||
value=c["text"],
|
||||
color=ds.clolors.ferst,
|
||||
size=14,
|
||||
size=ds.s(14),
|
||||
expand=True,
|
||||
no_wrap=False,
|
||||
),
|
||||
@@ -143,12 +143,12 @@ class PollPage(ft.Column):
|
||||
tile.on_click = lambda e, _qid=q["id"]: self._select_answer(_qid, e.control.data)
|
||||
choice_tiles.append(tile)
|
||||
|
||||
choices_col = ft.Column(controls=choice_tiles, spacing=6)
|
||||
choices_col = ft.Column(controls=choice_tiles, spacing=ds.s(6))
|
||||
|
||||
self.controls = [
|
||||
ft.Column(
|
||||
expand=True,
|
||||
spacing=12,
|
||||
spacing=ds.s(12),
|
||||
controls=[
|
||||
nav_row,
|
||||
question_box,
|
||||
@@ -179,7 +179,7 @@ class PollPage(ft.Column):
|
||||
content=ft.Text(
|
||||
"Завершить тест →",
|
||||
color=ds.clolors.ferst,
|
||||
size=16,
|
||||
size=ds.s(16),
|
||||
weight=ft.FontWeight.BOLD,
|
||||
),
|
||||
data="__finish__",
|
||||
@@ -250,7 +250,7 @@ class PollPage(ft.Column):
|
||||
self.controls = [
|
||||
ft.Row(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
controls=[ft.ProgressRing(width=48, height=48, color=ds.clolors.laer1)],
|
||||
controls=[ft.ProgressRing(width=ds.s(48), height=ds.s(48), color=ds.clolors.laer1)],
|
||||
)
|
||||
]
|
||||
self.update()
|
||||
@@ -272,7 +272,7 @@ class PollPage(ft.Column):
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
|
||||
controls=[
|
||||
ft.Icon(ft.Icons.ERROR_OUTLINE, size=48, color=ds.clolors.laer1),
|
||||
ft.Icon(ft.Icons.ERROR_OUTLINE, size=ds.s(48), color=ds.clolors.laer1),
|
||||
ds.CastomText(text=error, size=14),
|
||||
ds.CastomButton(
|
||||
text="Попробовать снова",
|
||||
@@ -292,7 +292,7 @@ class PollPage(ft.Column):
|
||||
)
|
||||
|
||||
success_controls: list[ft.Control] = [
|
||||
ft.Icon(ft.Icons.CHECK_CIRCLE_OUTLINE, size=48, color=ds.clolors.laer1),
|
||||
ft.Icon(ft.Icons.CHECK_CIRCLE_OUTLINE, size=ds.s(48), color=ds.clolors.laer1),
|
||||
ds.CastomText(text="Тест пройден!", size=20, weight=ft.FontWeight.BOLD),
|
||||
]
|
||||
|
||||
@@ -307,7 +307,7 @@ class PollPage(ft.Column):
|
||||
content=ft.Image(
|
||||
src=data_uri,
|
||||
expand=True,
|
||||
height=380,
|
||||
height=ds.s(380),
|
||||
fit=ft.BoxFit.CONTAIN,
|
||||
),
|
||||
)
|
||||
@@ -338,14 +338,14 @@ class PollPage(ft.Column):
|
||||
|
||||
self.controls = [
|
||||
ft.Container(
|
||||
padding=20,
|
||||
padding=ds.s(20),
|
||||
bgcolor=ds.clolors.laer3,
|
||||
border_radius=16,
|
||||
border_radius=ds.s(16),
|
||||
expand=True,
|
||||
content=ft.Column(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
|
||||
spacing=16,
|
||||
spacing=ds.s(16),
|
||||
controls=success_controls,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -31,11 +31,11 @@ class ProfilePage(ft.Column):
|
||||
hint_text="Загрузка...",
|
||||
)
|
||||
|
||||
self._loading = ft.ProgressRing(visible=False, width=24, height=24)
|
||||
self._status = ft.Text(value="", size=14)
|
||||
self._loading = ft.ProgressRing(visible=False, width=ds.s(24), height=ds.s(24))
|
||||
self._status = ft.Text(value="", size=ds.s(14))
|
||||
|
||||
super().__init__(
|
||||
spacing=16,
|
||||
spacing=ds.s(16),
|
||||
controls=[
|
||||
ds.CastomText(
|
||||
text="Редактировать профиль",
|
||||
@@ -47,7 +47,7 @@ class ProfilePage(ft.Column):
|
||||
self._org_dropdown,
|
||||
self._group_dropdown,
|
||||
ft.Row(
|
||||
spacing=12,
|
||||
spacing=ds.s(12),
|
||||
controls=[
|
||||
ds.CastomButton(text="Сохранить", on_click=self._save),
|
||||
self._loading,
|
||||
|
||||
@@ -8,12 +8,12 @@ class ResponsePage(ft.Column):
|
||||
def __init__(self, page: ft.Page, response_id: str):
|
||||
self._page = page
|
||||
self._response_id = response_id
|
||||
self._loading = ft.ProgressRing(width=40, height=40, color=ds.clolors.laer1)
|
||||
self._loading = ft.ProgressRing(width=ds.s(40), height=ds.s(40), color=ds.clolors.laer1)
|
||||
|
||||
super().__init__(
|
||||
alignment=ft.MainAxisAlignment.START,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH,
|
||||
spacing=8,
|
||||
spacing=ds.s(8),
|
||||
controls=[
|
||||
ft.Row(alignment=ft.MainAxisAlignment.CENTER, controls=[self._loading])
|
||||
],
|
||||
@@ -43,8 +43,8 @@ class ResponsePage(ft.Column):
|
||||
|
||||
controls: list[ft.Control] = [
|
||||
ft.Container(
|
||||
padding=ft.padding.only(bottom=8),
|
||||
content=ft.Column(spacing=4, controls=[
|
||||
padding=ft.padding.only(bottom=ds.s(8)),
|
||||
content=ft.Column(spacing=ds.s(4), controls=[
|
||||
ds.CastomText(text=poll.get("title", ""), size=20, weight=ft.FontWeight.BOLD),
|
||||
ds.CastomText(text=f"Пройден: {submitted_at}", size=12),
|
||||
]),
|
||||
@@ -61,12 +61,12 @@ class ResponsePage(ft.Column):
|
||||
await self._page.launch_url(_url)
|
||||
|
||||
controls.append(ft.Container(
|
||||
border_radius=16,
|
||||
padding=12,
|
||||
border_radius=ds.s(16),
|
||||
padding=ds.s(12),
|
||||
bgcolor=ds.clolors.laer3,
|
||||
content=ft.Column(
|
||||
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
|
||||
spacing=10,
|
||||
spacing=ds.s(10),
|
||||
controls=[
|
||||
ds.CastomText(text="Результат", size=16, weight=ft.FontWeight.BOLD),
|
||||
ft.Container(
|
||||
@@ -74,7 +74,7 @@ class ResponsePage(ft.Column):
|
||||
content=ft.Image(
|
||||
src=data_uri,
|
||||
expand=True,
|
||||
height=380,
|
||||
height=ds.s(380),
|
||||
fit=ft.BoxFit.CONTAIN,
|
||||
),
|
||||
),
|
||||
@@ -103,23 +103,23 @@ class ResponsePage(ft.Column):
|
||||
for c in q.get("choices", []):
|
||||
is_selected = c["id"] == answer.get("choice_id")
|
||||
choice_rows.append(ft.Container(
|
||||
border_radius=8,
|
||||
padding=ft.padding.symmetric(horizontal=12, vertical=6),
|
||||
border_radius=ds.s(8),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(12), vertical=ds.s(6)),
|
||||
bgcolor=ds.clolors.laer1 if is_selected else ds.clolors.laer3,
|
||||
content=ft.Row(spacing=8, controls=[
|
||||
content=ft.Row(spacing=ds.s(8), controls=[
|
||||
ft.Icon(
|
||||
ft.Icons.CHECK_CIRCLE if is_selected else ft.Icons.RADIO_BUTTON_UNCHECKED,
|
||||
color=ds.clolors.ferst, size=16,
|
||||
color=ds.clolors.ferst, size=ds.s(16),
|
||||
),
|
||||
ft.Container(expand=True, content=ds.CastomText(text=c["text"], size=13)),
|
||||
]),
|
||||
))
|
||||
|
||||
answer_cards.append(ft.Container(
|
||||
border_radius=12,
|
||||
padding=16,
|
||||
border_radius=ds.s(12),
|
||||
padding=ds.s(16),
|
||||
bgcolor=ds.clolors.laer2,
|
||||
content=ft.Column(spacing=8, controls=[
|
||||
content=ft.Column(spacing=ds.s(8), controls=[
|
||||
ds.CastomText(text=q.get("text", ""), size=14, weight=ft.FontWeight.BOLD),
|
||||
*choice_rows,
|
||||
]),
|
||||
|
||||
@@ -6,7 +6,7 @@ import api_client
|
||||
class TakeTestPage(ft.Column):
|
||||
def __init__(self, page: ft.Page):
|
||||
self._page = page
|
||||
self._loading = ft.ProgressRing(width=40, height=40, color=ds.clolors.laer1)
|
||||
self._loading = ft.ProgressRing(width=ds.s(40), height=ds.s(40), color=ds.clolors.laer1)
|
||||
super().__init__(
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
|
||||
@@ -27,11 +27,11 @@ class TakeTestPage(ft.Column):
|
||||
def _render_polls(self, polls: list):
|
||||
self.controls = [
|
||||
ft.Container(
|
||||
border_radius=12,
|
||||
padding=16,
|
||||
border_radius=ds.s(12),
|
||||
padding=ds.s(16),
|
||||
bgcolor=ds.clolors.laer2,
|
||||
content=ft.Column(
|
||||
spacing=6,
|
||||
spacing=ds.s(6),
|
||||
controls=[
|
||||
ds.CastomText(
|
||||
text=poll.get("title", "—"),
|
||||
|
||||
@@ -6,6 +6,7 @@ from info import AuthService
|
||||
class LoginView(ft.View):
|
||||
def __init__(self, page: ft.Page):
|
||||
self._auth = AuthService(page)
|
||||
self.pageS = page
|
||||
|
||||
self._username = ds.CastomTextField_input(
|
||||
label="Логин",
|
||||
@@ -21,7 +22,7 @@ class LoginView(ft.View):
|
||||
can_reveal_password=True,
|
||||
)
|
||||
|
||||
self._error = ft.Text("", color=ft.Colors.RED_400, size=14, visible=False)
|
||||
self._error = ft.Text("", color=ft.Colors.RED_400, size=ds.s(14), visible=False)
|
||||
|
||||
self._btn = ds.CastomButton(
|
||||
text="Войти",
|
||||
@@ -29,9 +30,8 @@ class LoginView(ft.View):
|
||||
)
|
||||
|
||||
self._reg_link = ft.TextButton(
|
||||
content="Нет аккаунта? Зарегистрироваться",
|
||||
style=ft.ButtonStyle(color=ds.clolors.ferst),
|
||||
on_click=lambda e: page.run_task(page.push_route, "/reg"),
|
||||
content=ft.Text("Нет аккаунта? Зарегистрироваться", color=ds.clolors.ferst, size=ds.s(14)),
|
||||
on_click=self.open_dialog,
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
@@ -39,22 +39,23 @@ class LoginView(ft.View):
|
||||
bgcolor=ds.clolors.background,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH,
|
||||
vertical_alignment=ft.MainAxisAlignment.CENTER,
|
||||
padding=ft.padding.symmetric(horizontal=16, vertical=24),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(16), vertical=ds.s(24)),
|
||||
scroll=ft.ScrollMode.AUTO,
|
||||
)
|
||||
self.controls = [
|
||||
ft.Text("COPP", color=ds.clolors.ferst, size=30, weight=ft.FontWeight.BOLD,
|
||||
ft.Text("ЦОПП", color=ds.clolors.ferst, size=ds.s(30), weight=ft.FontWeight.BOLD,
|
||||
text_align=ft.TextAlign.CENTER),
|
||||
ft.Container(height=8),
|
||||
ft.Text("Вход в систему", color=ds.clolors.ferst, size=16,
|
||||
ft.Container(height=ds.s(8)),
|
||||
ft.Text("Это проект цопп по проведению иследовательских тестирований", color=ds.clolors.ferst, size=ds.s(16),
|
||||
text_align=ft.TextAlign.CENTER),
|
||||
ft.Container(height=24),
|
||||
ft.Container(height=ds.s(24)),
|
||||
ft.Container(
|
||||
padding=ft.padding.all(24),
|
||||
padding=ft.padding.all(ds.s(24)),
|
||||
bgcolor=ds.clolors.laer3,
|
||||
border_radius=16,
|
||||
border_radius=ds.s(16),
|
||||
alignment=ft.Alignment.CENTER,
|
||||
content=ft.Column(
|
||||
spacing=16,
|
||||
spacing=ds.s(16),
|
||||
controls=[
|
||||
self._username,
|
||||
self._password,
|
||||
@@ -65,7 +66,16 @@ class LoginView(ft.View):
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def open_dialog(self, e):
|
||||
self.dialog = ds.AlterDiaalogApproval(
|
||||
on_accept=lambda: self.pageS.run_task(self.pageS.push_route, "/reg")
|
||||
)
|
||||
self.dialog.open = True
|
||||
self.pageS.overlay.append(self.dialog)
|
||||
self.pageS.update()
|
||||
|
||||
|
||||
async def _do_login(self):
|
||||
username = self._username.value.strip()
|
||||
password = self._password.value
|
||||
|
||||
@@ -17,9 +17,9 @@ class MainView(ft.View):
|
||||
vertical_alignment=ft.MainAxisAlignment.CENTER,
|
||||
)
|
||||
self.controls = [
|
||||
ft.Text("COPP",color=ds.clolors.ferst, size=30),
|
||||
ft.Text("Это проект цопп по проведению иследовательских тестирований",color=ds.clolors.ferst, size=16),
|
||||
ft.Container(width=0, height=20),
|
||||
ft.Text("ЦОПП",color=ds.clolors.ferst, size=ds.s(30)),
|
||||
ft.Text("Это проект цопп по проведению иследовательских тестирований",color=ds.clolors.ferst, size=ds.s(16)),
|
||||
ft.Container(width=0, height=ds.s(20)),
|
||||
self.button_temp
|
||||
]
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class MyTestsView(ft.View):
|
||||
controls=[
|
||||
ft.Column(
|
||||
expand=True,
|
||||
spacing=10,
|
||||
spacing=ds.s(10),
|
||||
controls=[
|
||||
ft.Row(
|
||||
controls=[
|
||||
|
||||
@@ -18,13 +18,13 @@ class PollView(ft.View):
|
||||
super().__init__(
|
||||
route=f"/poll/{url_key}/{poll_id}",
|
||||
bgcolor=ds.clolors.background,
|
||||
padding=ft.padding.symmetric(horizontal=12, vertical=8),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(12), vertical=ds.s(8)),
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH,
|
||||
vertical_alignment=ft.MainAxisAlignment.START,
|
||||
controls=[
|
||||
ft.Column(
|
||||
expand=True,
|
||||
spacing=10,
|
||||
spacing=ds.s(10),
|
||||
controls=[
|
||||
ft.Row(
|
||||
controls=[
|
||||
|
||||
@@ -24,7 +24,7 @@ class ProfileView(ft.View):
|
||||
controls=[
|
||||
ft.Column(
|
||||
expand=True,
|
||||
spacing=10,
|
||||
spacing=ds.s(10),
|
||||
controls=[
|
||||
ft.Row(
|
||||
controls=[
|
||||
|
||||
@@ -46,7 +46,7 @@ class RegView(ft.View):
|
||||
hint_text="Загрузка...",
|
||||
)
|
||||
|
||||
self._error = ft.Text("", color=ft.Colors.RED_400, size=14, visible=False)
|
||||
self._error = ft.Text("", color=ft.Colors.RED_400, size=ds.s(14), visible=False)
|
||||
|
||||
self._btn = ds.CastomButton(
|
||||
text="Зарегистрироваться",
|
||||
@@ -63,22 +63,22 @@ class RegView(ft.View):
|
||||
bgcolor=ds.clolors.background,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH,
|
||||
vertical_alignment=ft.MainAxisAlignment.CENTER,
|
||||
padding=ft.padding.symmetric(horizontal=16, vertical=24),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(16), vertical=ds.s(24)),
|
||||
scroll=ft.ScrollMode.AUTO,
|
||||
)
|
||||
self.controls = [
|
||||
ft.Text("COPP", color=ds.clolors.ferst, size=30, weight=ft.FontWeight.BOLD,
|
||||
ft.Text("COPP", color=ds.clolors.ferst, size=ds.s(30), weight=ft.FontWeight.BOLD,
|
||||
text_align=ft.TextAlign.CENTER),
|
||||
ft.Container(height=8),
|
||||
ft.Text("Регистрация в системе", color=ds.clolors.ferst, size=16,
|
||||
ft.Container(height=ds.s(8)),
|
||||
ft.Text("Регистрация в системе", color=ds.clolors.ferst, size=ds.s(16),
|
||||
text_align=ft.TextAlign.CENTER),
|
||||
ft.Container(height=24),
|
||||
ft.Container(height=ds.s(24)),
|
||||
ft.Container(
|
||||
padding=ft.padding.all(24),
|
||||
padding=ft.padding.all(ds.s(24)),
|
||||
bgcolor=ds.clolors.laer3,
|
||||
border_radius=16,
|
||||
border_radius=ds.s(16),
|
||||
content=ft.Column(
|
||||
spacing=16,
|
||||
spacing=ds.s(16),
|
||||
controls=[
|
||||
self._first_name,
|
||||
self._last_name,
|
||||
@@ -89,8 +89,8 @@ class RegView(ft.View):
|
||||
self._error,
|
||||
ft.Row(
|
||||
wrap=True,
|
||||
spacing=8,
|
||||
run_spacing=8,
|
||||
spacing=ds.s(8),
|
||||
run_spacing=ds.s(8),
|
||||
controls=[
|
||||
self._btn_cansel,
|
||||
self._btn,
|
||||
|
||||
@@ -18,14 +18,14 @@ class ResponseView(ft.View):
|
||||
super().__init__(
|
||||
route=f"/response/{url_key}/{response_id}",
|
||||
bgcolor=ds.clolors.background,
|
||||
padding=ft.padding.symmetric(horizontal=12, vertical=8),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(12), vertical=ds.s(8)),
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH,
|
||||
vertical_alignment=ft.MainAxisAlignment.START,
|
||||
scroll=ft.ScrollMode.AUTO,
|
||||
controls=[
|
||||
ft.Column(
|
||||
expand=True,
|
||||
spacing=10,
|
||||
spacing=ds.s(10),
|
||||
controls=[
|
||||
ft.Row(
|
||||
controls=[
|
||||
|
||||
@@ -18,7 +18,7 @@ class TakeTestView(ft.View):
|
||||
super().__init__(
|
||||
route=f"/take_test/{url_key}",
|
||||
bgcolor=ds.clolors.background,
|
||||
padding=ft.padding.symmetric(horizontal=12, vertical=8),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(12), vertical=ds.s(8)),
|
||||
horizontal_alignment=ft.CrossAxisAlignment.START,
|
||||
vertical_alignment=ft.MainAxisAlignment.START,
|
||||
controls=[
|
||||
|
||||
@@ -12,7 +12,7 @@ class UserView(ft.View):
|
||||
profile_btn = ft.IconButton(
|
||||
icon=ft.Icons.ACCOUNT_CIRCLE,
|
||||
icon_color=ds.clolors.ferst,
|
||||
icon_size=30,
|
||||
icon_size=ds.s(30),
|
||||
tooltip="Профиль",
|
||||
on_click=lambda _: page.go(f"/profile/{url_key}"),
|
||||
)
|
||||
@@ -22,7 +22,7 @@ class UserView(ft.View):
|
||||
bgcolor=ds.clolors.background,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH,
|
||||
vertical_alignment=ft.MainAxisAlignment.START,
|
||||
padding=ft.padding.symmetric(horizontal=12, vertical=8),
|
||||
padding=ft.padding.symmetric(horizontal=ds.s(12), vertical=ds.s(8)),
|
||||
)
|
||||
self.controls = [
|
||||
ft.Column(
|
||||
@@ -35,7 +35,7 @@ class UserView(ft.View):
|
||||
ft.Text(
|
||||
"Добро пожаловать в COPP!",
|
||||
color=ds.clolors.ferst,
|
||||
size=20,
|
||||
size=ds.s(20),
|
||||
weight=ft.FontWeight.BOLD,
|
||||
expand=True,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user