diff --git a/lib/widgets/mood_form.dart b/lib/widgets/mood_form.dart index ca9858e..205e4d6 100644 --- a/lib/widgets/mood_form.dart +++ b/lib/widgets/mood_form.dart @@ -22,8 +22,8 @@ class _MoodFormState extends State { void submitForm() { if (_moodFormKey.currentState!.validate()) { _moodFormKey.currentState?.save(); //call every onSave Method - Mood mood = Mood(slider.getSliderValue(), _textInput, DateTime.now()); - print(mood.toCSV()); + Mood mood = + Mood(slider.getSliderValue().toInt(), _textInput, DateTime.now()); DatabaseService.instance.addMood(mood); _moodFormKey.currentState?.reset(); } diff --git a/lib/widgets/sleep_form.dart b/lib/widgets/sleep_form.dart index 52eefe8..5564c7d 100644 --- a/lib/widgets/sleep_form.dart +++ b/lib/widgets/sleep_form.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:smoke_cess_app/models/sleep.dart'; +import 'package:smoke_cess_app/service/database_service.dart'; import 'package:smoke_cess_app/widgets/elevated_card.dart'; import 'package:smoke_cess_app/widgets/slider.dart'; import 'package:smoke_cess_app/widgets/submit_form_button.dart'; @@ -26,10 +28,13 @@ class _SleepFormState extends State { void submitForm() { if (_sleepFormKey.currentState!.validate()) { _sleepFormKey.currentState?.save(); //call every onSave Method - //TODO Businesslogik aufrufen! - print(_textInput); - print(slider.getSliderValue()); - print('Eingeschlafen um: ${sleepTimePicker.getCurrentTime}'); + Sleep sleep = Sleep( + slider.getSliderValue().toInt(), + _textInput, + DateTime.now(), + sleepTimePicker.getCurrentTime, + wakeUpTimePicker.getCurrentTime); + DatabaseService.instance.addSleep(sleep); _sleepFormKey.currentState?.reset(); } }