diff --git a/lib/data_storage/daily_status_repository.dart b/lib/data_storage/daily_status_repository.dart new file mode 100644 index 0000000..ebe5c53 --- /dev/null +++ b/lib/data_storage/daily_status_repository.dart @@ -0,0 +1,51 @@ +import 'models/daily_entry_model.dart'; + +class DailyStatusRepository { + DailyEntry? currentDay; + + DailyStatusRepository(); + + void logFeelingMigrainy(bool status) { + if (currentDay == null) { + currentDay = DailyEntry( + date: getCurrentDate(), + feelingMigrainy: status, + tookZomig: false, + hadMigraine: false, + tookPainMeds: false); + } else { + currentDay = DailyEntry( + date: getCurrentDate(), + feelingMigrainy: status, + tookZomig: currentDay!.tookZomig, + hadMigraine: currentDay!.hadMigraine, + tookPainMeds: currentDay!.tookPainMeds + ); + } + } + + void logTookZomig(bool status) { + if (currentDay == null) { + currentDay = DailyEntry( + date: getCurrentDate(), + feelingMigrainy: false, + tookZomig: status, + hadMigraine: false, + tookPainMeds: false); + } else { + currentDay = DailyEntry( + date: getCurrentDate(), + feelingMigrainy: currentDay!.tookZomig, + tookZomig: status, + hadMigraine: currentDay!.hadMigraine, + tookPainMeds: currentDay!.tookPainMeds + ); + } + } + + DateTime getCurrentDate() { + DateTime now = DateTime.now(); + DateTime date = DateTime(now.year, now.month, now.day); + return date; + } +} \ No newline at end of file diff --git a/lib/data_storage/models/daily_entry_model.dart b/lib/data_storage/models/daily_entry_model.dart new file mode 100644 index 0000000..a3ab84a --- /dev/null +++ b/lib/data_storage/models/daily_entry_model.dart @@ -0,0 +1,15 @@ + +class DailyEntry { + final DateTime date; + final bool feelingMigrainy; + final bool tookZomig; + final bool hadMigraine; + final bool tookPainMeds; + + const DailyEntry({ + required this.date, + required this.feelingMigrainy, + required this.tookZomig, + required this.hadMigraine, + required this.tookPainMeds}); +} \ No newline at end of file