diff --git a/README.md b/README.md index e609991..1598e46 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ -# Nahrung Analysierung +# Nahrungstracker -An example of a minimal Flet app. - -To run the app: +Tracke deine verbrauchte kcal pro Tag! +![Preview](preview.jpg) +## Build ``` -flet run [app_directory] -``` \ No newline at end of file +flet build apk +``` +_use flet 0.21.2!_ + +## Todo +[x] History +[ ] Eigene Tags für Essen +[ ] Settings und Tag Tab \ No newline at end of file diff --git a/assets/icon.png b/assets/icon.png index 6c1142e..4e91dfe 100644 Binary files a/assets/icon.png and b/assets/icon.png differ diff --git a/main.py b/main.py index 4a5015c..15128ac 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ from random import choice def get_time(): t = datetime.now() return [t.year, t.month, t.day, t.hour, t.minute, t.second] + def random_emoji(): return choice("🍎🍐🍊🍋🍌🍉🍇🍓🍈🍒🍑🍍🥝🥭🥑🍅🍆🥒🥕🥬🌽🥔🍠🌰🥜🍯🥐🍞🥖🥨🥯🧀🥚🍳🥓🧄🧅🥞🧇🍤🍗🍖🍕🌭🍔🍟🥙🌮🌯🥗🥘🍝🍜🦪🍲🍥🍣🍱🍛🍚🧆🍙🍘🍢🍡🍧🍨🍦🍰🎂🍮🍭🍬🍫🍿🍩🍪🥮🧁🥛🧈🍼☕🍵🍶🍺🍻🥂🍷🥃🍸🍹🍾🧉🧃🧊🧂🥄🍴") @@ -16,8 +17,7 @@ class Nahrung(ft.UserControl): self.kjtext = ft.Text("0", size=25) self.kcaltext = ft.Text("0", size=30) - self.kcaltextfield = ft.TextField(keyboard_type="NUMBER",expand=True,autofocus=True,on_change=self.reseterrorinkcaltextfield,on_submit=self.editkcal) - + self.kcaltextfield = ft.TextField(keyboard_type="NUMBER", expand=True, autofocus=True, on_change=self.reseterrorinkcaltextfield, on_submit=self.editkcal) # Initialize history list self.historylist = [] @@ -63,7 +63,8 @@ class Nahrung(ft.UserControl): self.controls = [self.main_container, self.history_container] self.load_todays_kcal() - def reseterrorinkcaltextfield(self): + + def reseterrorinkcaltextfield(self, e=None): self.kcaltextfield.error_text = "" def build(self): @@ -73,21 +74,18 @@ class Nahrung(ft.UserControl): def editkcal(self, e): try: emoji = random_emoji() - print(emoji,ord(emoji)) new_kcal = int(self.kcaltext.value) + int(self.kcaltextfield.value) self.kcaltext.value = str(new_kcal) self.kjtext.value = str(round(new_kcal * 4.184, 0)) self.history.append([emoji, self.kcaltextfield.value, get_time()]) - file_handler.save(self.settings, self.history) # Save the updated kcal value + file_handler.save(self.settings, self.history) self.update_history() self.reseterrorinkcaltextfield() self.kcaltextfield.value = "" - self.update() # Update the controls to reflect changes + self.update() except ValueError: - print("error") self.kcaltextfield.error_text = "\\(*O*)/ nicht verschreiben!!" self.update() - #pass # Handle invalid input gracefully def create_appbar(self): return ft.AppBar( diff --git a/requirements.txt b/requirements.txt index d54c7ec..7a82fda 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -flet==0.22.* \ No newline at end of file +flet==0.21.* \ No newline at end of file