2023-11-17 14:22:28 +01:00
|
|
|
"""Base state for the app."""
|
|
|
|
|
|
|
|
import reflex as rx
|
2023-12-12 21:27:48 +01:00
|
|
|
from blurme import styles
|
|
|
|
import asyncio
|
2023-11-17 14:22:28 +01:00
|
|
|
|
|
|
|
|
2023-12-12 21:27:48 +01:00
|
|
|
#class State(rx.State):
|
|
|
|
# def __init__(self):
|
|
|
|
# super().__init__()
|
|
|
|
# self.dark_mode_state: bool = False
|
|
|
|
# def __str__(self):
|
|
|
|
# self.dark_mode_state
|
|
|
|
# def toggle_dark_mode(self) -> None:
|
|
|
|
# self.dark_mode_state = not self.dark_mode_state
|
|
|
|
# text_color = styles.text_color_light if self.dark_mode_state == True else styles.text_color_dark
|
|
|
|
# styles.text_color = text_color
|
|
|
|
# print(f"Dark Mode State: {self.dark_mode_state}")
|
|
|
|
# print(f"Current Text Color: {text_color}")
|
|
|
|
# pass
|
|
|
|
|
2023-11-17 14:22:28 +01:00
|
|
|
class State(rx.State):
|
2023-12-12 21:27:48 +01:00
|
|
|
"""The app state."""
|
|
|
|
|
|
|
|
# The images to show.
|
|
|
|
img: list[str] = []
|
|
|
|
|
|
|
|
async def handle_upload(self, files: list[rx.UploadFile]):
|
|
|
|
"""Handle the upload of file(s).
|
|
|
|
|
|
|
|
Args:
|
|
|
|
files: The uploaded files.
|
|
|
|
"""
|
|
|
|
for file in files:
|
|
|
|
upload_data = await file.read()
|
|
|
|
outfile = rx.get_asset_path(file.filename)
|
|
|
|
|
|
|
|
# Save the file.
|
|
|
|
with open(outfile, "wb") as file_object:
|
|
|
|
file_object.write(upload_data)
|
|
|
|
|
|
|
|
# Update the img var.
|
|
|
|
self.img.append(file.filename)
|
|
|
|
self.img = self.img
|
|
|
|
print(f"Current Text Color: {self.img[0]}")
|
|
|
|
|
2023-11-17 14:22:28 +01:00
|
|
|
|
|
|
|
|