61 lines
1.3 KiB
Dart
61 lines
1.3 KiB
Dart
import 'package:fitnote/models/health.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_common/flutter_common.dart';
|
|
|
|
class HealthProvider with ChangeNotifier {
|
|
late HealthRecord formItem;
|
|
DateTime selectedDate = DateTime.now();
|
|
DateTime focusedDate = 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 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();
|
|
}
|
|
}
|