diff --git a/src/ez_lan_manager/components/AnimatedText.py b/src/ez_lan_manager/components/AnimatedText.py index 2bd69d9..e62f7af 100644 --- a/src/ez_lan_manager/components/AnimatedText.py +++ b/src/ez_lan_manager/components/AnimatedText.py @@ -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 diff --git a/src/ez_lan_manager/pages/ContactPage.py b/src/ez_lan_manager/pages/ContactPage.py index e694887..24b454d 100644 --- a/src/ez_lan_manager/pages/ContactPage.py +++ b/src/ez_lan_manager/pages/ContactPage.py @@ -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