BlurMe/blurme/pages/settings.py

111 lines
5.6 KiB
Python
Raw Normal View History

"""The settings page."""
2023-12-12 21:27:48 +01:00
import asyncio
from blurme.templates import template
2023-12-12 21:27:48 +01:00
from blurme.state import State
import reflex as rx
2023-12-12 21:27:48 +01:00
color = "rgb(107,99,246)"
2023-11-22 15:54:26 +01:00
@template(route="/settings", title="Zdjęcie", image = "/image-icon.png")
def settings() -> rx.Component:
2024-01-10 14:16:32 +01:00
icon_style = {"width": "20px", "height": "30px", "margin-right": "10px"}
2024-01-16 14:12:10 +01:00
2023-12-19 13:39:26 +01:00
return rx.vstack(
2024-01-10 14:16:32 +01:00
rx.wrap(
rx.hstack(
2024-01-16 02:39:24 +01:00
rx.vstack(
rx.image(src="/brush-logo.png", height="5.2em", margin_bottom="15px"),
rx.heading("Anonimizuj już teraz!", font_size="2em", margin_bottom="15px",
background_image="linear-gradient(271.68deg, #7566fe 0.75%, #f96caf 88.52%)",
background_clip="text", padding="5px"),
rx.text("Dodaj zdjęcie, wybierz obszar i ukryj tożsamość: Anonimizacja zdjęć w mgnieniu oka szybko, łatwo, bezpłatnie!",
2024-01-16 14:12:10 +01:00
font_size="1.2em", text_align="center"), width="50%", margin_left="50px", margin_right="30px"),
2024-01-16 02:39:24 +01:00
rx.vstack(
rx.upload(
rx.vstack(
rx.image(src="/upload-icon.png", height="5em"),
rx.text("Przeciągnij, aby wybrać pliki", font_size="1em"),
rx.text("albo", font_size="0.8em"),
rx.button("Kliknij", font_size="1em", color="rgba(117,102,254,255)"),
rx.text(" "),
rx.text("Dostępne rozszerzenia plików: png, jpg, webp, tiff", font_size="0.8em"),
),
border=f"1px dotted {color}",
padding="1em",
2024-01-16 14:12:10 +01:00
width="120%",
2024-01-16 02:39:24 +01:00
multiple=True,
2024-01-16 14:12:10 +01:00
#accept={
# "image/png": [".png"],
# "image/jpeg": [".jpg", ".jpeg"],
# "image/webp": [".webp"],
# "image/tiff": [".tif", ".tiff"],
#},
2024-01-16 02:39:24 +01:00
margin_top="50px",
style={"align-self": "center"},
spacing="2em",
),
rx.foreach(rx.selected_files, rx.text),
rx.box(
rx.button("Załaduj zdjęcie",
on_click=lambda: State.handle_upload(rx.upload_files()),
2024-01-16 14:12:10 +01:00
color="rgba(47, 187, 74,255)"),
2024-01-16 02:39:24 +01:00
rx.alert_dialog(
rx.alert_dialog_overlay(
rx.alert_dialog_content(
rx.alert_dialog_header("Przekroczono limit plików"),
rx.alert_dialog_body("Nie można przesłać więcej niż 5 plików."),
rx.alert_dialog_footer(
rx.button("Zamknij", color="rgba(255, 75, 42,255)",
on_click=State.toggle_show(),
2024-01-16 14:12:10 +01:00
)
2024-01-16 02:39:24 +01:00
),
),
),
is_open=State.show,
),
2024-01-16 14:12:10 +01:00
rx.alert_dialog(
rx.alert_dialog_overlay(
rx.alert_dialog_content(
rx.alert_dialog_header("Nieprawidłowe rozszerzenie pliku"),
rx.alert_dialog_body("Dozwolone rozszerzenia plików to: png, jpg, webp, tiff."),
rx.alert_dialog_footer(
rx.button("Zamknij", color="rgba(255, 75, 42,255)",
on_click=State.toggle_extension_alert(),
)
),
),
),
is_open=State.show_extension_alert,
),
2024-01-16 02:39:24 +01:00
),
),
2024-01-08 18:59:34 +01:00
),
2024-01-16 02:39:24 +01:00
),
2024-01-08 18:59:34 +01:00
rx.responsive_grid(
rx.foreach(
State.img,
lambda img: rx.vstack(
2024-01-16 02:39:24 +01:00
rx.image(src=f'/{img}', max_height="450px"),
rx.text(img, font_size="15px"),
rx.hstack(
rx.button(rx.icon(tag="delete", margin_right="8px"), " Usuń",
on_click=lambda img_name=img: State.delete_image(img_name),
color="rgba(255, 75, 42,255)", width="100px"),
rx.button(rx.icon(tag="check", margin_right="8px"), " Analizuj",
on_click=lambda img_name=img: State.image_analysis(img_name),
width="130px"),
rx.button(rx.icon(tag="edit", margin_right="8px"), " Anonimizuj",
on_click=lambda img_name=img: State.image_anonymization(img_name),
width="130px"),
rx.button(rx.icon(tag="download", margin_right="8px"), " Pobierz",
on_click=lambda img_name=img: State.download_image(img_name),
width="100px"),
padding="1em"
),
),
2023-12-19 13:39:26 +01:00
),
2024-01-16 02:39:24 +01:00
columns=[1],
2024-01-08 18:59:34 +01:00
spacing="5px",
2024-01-16 02:39:24 +01:00
),
)