feat:增加睡眠记录
This commit is contained in:
@@ -25,9 +25,6 @@ class HealthRecord extends HiveObject {
|
||||
@HiveField(5)
|
||||
String sleepEndTime;
|
||||
|
||||
@HiveField(6)
|
||||
num sleepDuration;
|
||||
|
||||
@HiveField(7)
|
||||
String date;
|
||||
|
||||
@@ -38,11 +35,10 @@ class HealthRecord extends HiveObject {
|
||||
required this.weight,
|
||||
required this.sleepStartTime,
|
||||
required this.sleepEndTime,
|
||||
required this.sleepDuration,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
static HealthRecord getEmpty() {
|
||||
static HealthRecord getEmpty(String date) {
|
||||
return HealthRecord(
|
||||
id: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
sportProject: '',
|
||||
@@ -50,21 +46,27 @@ class HealthRecord extends HiveObject {
|
||||
weight: 0,
|
||||
sleepStartTime: '',
|
||||
sleepEndTime: '',
|
||||
sleepDuration: 0,
|
||||
date: '',
|
||||
date: date,
|
||||
);
|
||||
}
|
||||
|
||||
static HealthRecord getDefault() {
|
||||
HealthRecord copyWith({
|
||||
int? id,
|
||||
num? weight,
|
||||
String? sportProject,
|
||||
num? sportDuration,
|
||||
String? sleepStartTime,
|
||||
String? sleepEndTime,
|
||||
String? date,
|
||||
}) {
|
||||
return HealthRecord(
|
||||
id: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
sportProject: '跑步',
|
||||
sportDuration: 30,
|
||||
weight: 70,
|
||||
sleepStartTime: '',
|
||||
sleepEndTime: '',
|
||||
sleepDuration: 0,
|
||||
date: '',
|
||||
id: id ?? this.id,
|
||||
date: date ?? this.date,
|
||||
weight: weight ?? this.weight,
|
||||
sportProject: sportProject ?? this.sportProject,
|
||||
sportDuration: sportDuration ?? this.sportDuration,
|
||||
sleepStartTime: sleepStartTime ?? this.sleepStartTime,
|
||||
sleepEndTime: sleepEndTime ?? this.sleepEndTime
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user