Changed the modal size and also modified the edit_entry_screen.py to conform with the wireframe, also changed all the texts to be english

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-06-25 00:27:49 -03:00
parent f9ab6da116
commit a999a0a437
8 changed files with 128 additions and 116 deletions
+10 -11
View File
@@ -6,29 +6,28 @@ from textual.widgets import Label, Input, Button
class EditDiaryModal(ModalScreen[tuple[int,str]]):
BINDINGS = [
("escape", "cancel", "Cancelar"),
("escape", "cancel", "Cancel"),
]
def __init__(self, diary_id: int):
super().__init__()
self.diary_id = diary_id
self.current_diary_name = self.app.service_manager.get_travel_diary_service().read_by_id(self.diary_id).name
self.name_input = Input(value=self.current_diary_name, id="edit_diary_name_input",classes="EditDiaryModal-NameInput")
self.name_input = Input(value=self.current_diary_name, id="edit_diary_name_input", classes="EditDiaryModal-NameInput")
def compose(self) -> ComposeResult:
with Vertical(id="edit_diary_dialog", classes="EditDiaryModal-Dialog"):
yield Label(f"Editar Diário: {self.current_diary_name}", classes="EditDiaryModal-Title")
yield Label("Novo Nome do Diário:")
yield Label("Edit Diary", classes="EditDiaryModal-Title")
yield Label("New Diary Name:")
yield self.name_input
with Horizontal(classes="dialog-buttons"):
yield Button("Salvar", variant="primary", id="save_diary_button")
yield Button("Cancelar", variant="default", id="cancel_button")
with Horizontal(classes="EditDiaryModal-ButtonsContainer"):
yield Button("Save", variant="primary", id="save_diary_button", classes="EditDiaryModal-SaveButton")
yield Button("Cancel", variant="default", id="cancel_button", classes="EditDiaryModal-CancelButton")
def on_mount(self) -> None:
"""Foca no campo de entrada e move o cursor para o final do texto."""
"""Focuses on the input field and moves cursor to the end of text."""
self.name_input.focus()
self.name_input.cursor_position = len(self.name_input.value)
# REMOVIDA A LINHA QUE CAUSA O ERRO: self.name_input.select_text()
def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "save_diary_button":
@@ -36,10 +35,10 @@ class EditDiaryModal(ModalScreen[tuple[int,str]]):
if new_diary_name and new_diary_name != self.current_diary_name:
self.dismiss((self.diary_id, new_diary_name))
elif new_diary_name == self.current_diary_name:
self.notify("Nenhuma alteração feita.", severity="warning")
self.notify("No changes made.", severity="warning")
self.dismiss(None)
else:
self.notify("O nome do diário não pode estar vazio.", severity="warning")
self.notify("Diary name cannot be empty.", severity="warning")
self.name_input.focus()
elif event.button.id == "cancel_button":
self.dismiss(None)