70 lines
1.5 KiB
Dart
70 lines
1.5 KiB
Dart
import 'package:fitnote/models/health.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class HealthProvider with ChangeNotifier {
|
|
HealthRecord formItem = HealthRecord.getEmpty(DateTime.now());
|
|
HealthRecord currentRecord = HealthRecord.getEmpty(DateTime.now());
|
|
DateTime selectedDate = DateTime.now();
|
|
RecordType type = RecordType.weight;
|
|
bool isEditing = false;
|
|
|
|
num latestWeight = 0;
|
|
num totalSpot = 0;
|
|
num avgSleep = 0;
|
|
|
|
void initForm(HealthRecord record) {
|
|
formItem = record;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateRecord(HealthRecord record) {
|
|
currentRecord = record;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateSelectDate(DateTime date) {
|
|
selectedDate = date;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateWeight(num weight) {
|
|
formItem.weight = weight;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateSportProject(String sportProject) {
|
|
formItem.sportProject = sportProject;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateSportDuration(num sportDuration) {
|
|
formItem.sportDuration = sportDuration;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateSleepStartTime(String sleepStartTime) {
|
|
formItem.sleepStartTime = sleepStartTime;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateSleepEndTime(String sleepEndTime) {
|
|
formItem.sleepEndTime = sleepEndTime;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateLatestWeight(num weight) {
|
|
latestWeight = weight;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateTotalSpot(num duration) {
|
|
totalSpot = duration;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateAvgSleep(num duration) {
|
|
avgSleep = duration;
|
|
notifyListeners();
|
|
}
|
|
}
|