I asked ChatGPT if I wanted to develop a personal journal-style application using MIT App Inventor.
And he suggested this code for each page.
I was able to create the RegisterScreen, LoginScreen, and AddNoteScreen pages, but I'm having trouble with the rest because I don't understand where to find certain blocks to execute the instructions ChatGPT gave me.
Editing a note doesn't work.
Neither does searching for notes.
In short, the rest is problematic.
That's why I'm asking for your help.
Here is the complete code:
Here's the complete code:
- RegisterScreen
when RegisterButton.Click
if PhoneInput.Text ≠ "" and PasswordInput.Text ≠ "" then
call TinyDB1.StoreValue("phone", PhoneInput.Text)
call TinyDB1.StoreValue("password", PasswordInput.Text)
call Notifier1.ShowAlert("Account created successfully!")
open another screen, "LoginScreen"
else
call Notifier1.ShowAlert("Fill in all fields!")
- LoginScreen
when LoginButton.Click
if PhoneLogin.Text = TinyDB1.GetValue("phone") and PasswordLogin.Text = TinyDB1.GetValue("password") then
open another screen "HomeScreen"
else
call Notifier1.ShowAlert("Numéro ou mot de passe incorrect.")
- HomeScreen
when HomeScreen.Initialize
set NotesList to TinyDB1.GetValue("notes", create empty list)
set NotesListView.Elements to NotesList
when AddNoteButton.Click
open another screen "AddNoteScreen"
when NotesListView.AfterPicking
call TinyDB1.StoreValue("selectedNote", NotesListView.Selection)
open another screen "EditNoteScreen"
- AddNoteScreen
initialize global NotesList to create empty list
when AddNoteScreen.Initialize
set global NotesList to TinyDB1.GetValue("notes", create empty list)
when SaveButton.Click
if TitleInput.Text ≠ "" and ContentInput.Text ≠ "" then
// Créer un timestamp lisible
set CurrentDateTime to call Clock1.Now
set Timestamp to call Clock1.FormatDateTime with pattern "dd MMM yyyy HH:mm"
// Créer la note
set NewNote to join (TitleInput.Text + ":" + ContentInput.Text + ":" + Timestamp)
// Ajouter à la liste
add item to list global NotesList NewNote
// Sauvegarder dans TinyDB
call TinyDB1.StoreValue("notes", global NotesList)
call Notifier1.ShowAlert("Note enregistrée avec succès !")
open another screen "HomeScreen"
else
call Notifier1.ShowAlert("Remplis tous les champs !")
- EditNoteScreen
initialize global NotesList to create empty list
when EditNoteScreen.Initialize
set global NotesList to TinyDB1.GetValue("notes", create empty list)
set SelectedNote to TinyDB1.GetValue("selectedNote", "")
set TitlePart to segment SelectedNote from 1 to position of ":" in SelectedNote - 1
set ContentPart to segment SelectedNote from position of ":" in SelectedNote + 1
set ContentPart to segment ContentPart from 1 to position of ":" in ContentPart - 1
set EditTitleInput.Text to TitlePart
set EditContentInput.Text to ContentPart
when SaveChangesButton.Click
if EditTitleInput.Text ≠ "" and EditContentInput.Text ≠ "" then
set NewTimestamp to call Clock1.FormatDateTime (Clock1.Now, "dd MMM yyyy HH:mm")
set UpdatedNote to join(EditTitleInput.Text + ":" + EditContentInput.Text + ":" + NewTimestamp)
// Supprimer l’ancienne note
remove item TinyDB1.GetValue("selectedNote") from global NotesList
// Ajouter la note modifiée
add item to list global NotesList UpdatedNote
// Sauvegarder
call TinyDB1.StoreValue("notes", global NotesList)
call Notifier1.ShowAlert("Note modifiée avec succès !")
open another screen "HomeScreen"
else
call Notifier1.ShowAlert("Remplis tous les champs !")
when DeleteNoteButton.Click
remove item TinyDB1.GetValue("selectedNote") from global NotesList
call TinyDB1.StoreValue("notes", global NotesList)
call Notifier1.ShowAlert("Note supprimée")
open another screen "HomeScreen"
- SettingsScreen
when ChangePasswordButton.Click
if NewPasswordInput.Text ≠ "" then
call TinyDB1.StoreValue("password", NewPasswordInput.Text)
call Notifier1.ShowAlert("Mot de passe mis à jour !")
set NewPasswordInput.Text to ""
else
call Notifier1.ShowAlert("Champ vide !")
when ExportButton.Click
set NotesList to TinyDB1.GetValue("notes", create empty list)
if length of list NotesList = 0 then
call Notifier1.ShowAlert("Aucune note à exporter.")
else
set CsvContent to "Titre,Contenu,Date\n"
for each item in NotesList
set parts to split item at ":"
set CsvContent to join CsvContent + parts[1] + "," + parts[2] + "," + parts[3] + "\n"
call File1.SaveFile(CsvContent, "/Download/mes_notes.csv")
call Notifier1.ShowAlert("Fichier enregistré dans /Download/mes_notes.csv")
when ClearNotesButton.Click
call TinyDB1.StoreValue("notes", create empty list)
call Notifier1.ShowAlert("Toutes les notes ont été supprimées.")
when LogoutButton.Click
open another screen "LoginScreen"