minor improvements

This commit is contained in:
David Rodenkirchen 2024-08-27 15:34:04 +02:00
parent 259786a1d3
commit 691602a727
2 changed files with 14 additions and 18 deletions

View File

@ -8,7 +8,7 @@ class AnimatedText(Component):
self._display_printing: list[bool] = [False]
self.text_comp = Text("")
async def display_text(self, success: bool, text: str, speed: float = 0.08) -> None:
async def display_text(self, success: bool, text: str, speed: float = 0.06, font_size: float = 0.9) -> None:
if self._display_printing[0]:
return
else:
@ -17,7 +17,7 @@ class AnimatedText(Component):
if success:
self.text_comp.style = TextStyle(
fill=self.session.theme.success_color,
font_size=0.9
font_size=font_size
)
for c in text:
self.text_comp.text = self.text_comp.text + c
@ -26,7 +26,7 @@ class AnimatedText(Component):
else:
self.text_comp.style = TextStyle(
fill=self.session.theme.danger_color,
font_size=0.9
font_size=font_size
)
for c in text:
self.text_comp.text = self.text_comp.text + c

View File

@ -20,26 +20,22 @@ class ContactPage(Component):
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Kontakt")
async def on_send_pressed(self) -> None:
error_msg = ""
self.submit_button.is_loading = True
await self.submit_button.force_refresh()
now = datetime.now()
if not self.email_input.text:
self.is_send_button_loading = False
await self.animated_text.display_text(False, "E-Mail darf nicht leer sein!")
return
error_msg = "E-Mail darf nicht leer sein!"
elif not self.subject_input.text:
error_msg = "Betreff darf nicht leer sein!"
elif not self.message_input.text:
error_msg = "Nachricht darf nicht leer sein!"
elif (now - self.last_message_sent[0]) < timedelta(minutes=1):
error_msg = "Immer mit der Ruhe!"
if not self.subject_input.text:
self.is_send_button_loading = False
await self.animated_text.display_text(False, "Betreff darf nicht leer sein!")
return
if not self.message_input.text:
self.is_send_button_loading = False
await self.animated_text.display_text(False, "Nachricht darf nicht leer sein!")
return
if (now - self.last_message_sent[0]) < timedelta(minutes=1):
await self.animated_text.display_text(False, "Immer mit der Ruhe!")
if error_msg:
self.submit_button.is_loading = False
await self.animated_text.display_text(False, error_msg)
return
mail_recipient = self.session[ConfigurationService].get_lan_info().organizer_mail