v1.0
This commit is contained in:
parent
ba3e29d955
commit
5e5ea4f112
4 changed files with 19 additions and 15 deletions
16
README.md
16
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]
|
||||
flet build apk
|
||||
```
|
||||
_use flet 0.21.2!_
|
||||
|
||||
## Todo
|
||||
[x] History
|
||||
[ ] Eigene Tags für Essen
|
||||
[ ] Settings und Tag Tab
|
BIN
assets/icon.png
BIN
assets/icon.png
Binary file not shown.
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.8 KiB |
14
main.py
14
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(
|
||||
|
|
|
@ -1 +1 @@
|
|||
flet==0.22.*
|
||||
flet==0.21.*
|
Loading…
Reference in a new issue