import 'package:flutter/cupertino.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:json_annotation/json_annotation.dart'; @JsonSerializable() class HealthRecord { @JsonKey(name: 'id') int? id; @JsonKey(name: 'sportProject') String? sportProject; @JsonKey(name: 'sportDuration') num? sportDuration; @JsonKey(name: 'weight') num? weight; @JsonKey(name: 'sleepStartTime') String? sleepStartTime; @JsonKey(name: 'sleepEndTime') String? sleepEndTime; @JsonKey(name: 'sleepDuration') num? sleepDuration; @JsonKey(name: 'date') String date; HealthRecord({ this.id, this.sportProject, this.sportDuration, this.weight, this.sleepStartTime, this.sleepEndTime, this.sleepDuration, required this.date, }); // factory Health.fromJson(Map json) => _$HealthFromJson(json); // // Map toJson() => _$HealthToJson(this); } enum RecordType { weight('体重', FontAwesomeIcons.weightScale, Color(0xFFF59E0B)), sport('运动', FontAwesomeIcons.personRunning, Color(0xFF38BDF8)), sleep('睡眠', FontAwesomeIcons.moon, Color(0xFF10B981)); final String title; final IconData icon; final Color color; const RecordType(this.title, this.icon, this.color); }