377 lines
9.5 KiB
Dart
377 lines
9.5 KiB
Dart
enum PetGender { male, female }
|
|
|
|
enum WeatherCondition { sunny, cloudy, rainy, overcast, snow }
|
|
|
|
class LocationWeather {
|
|
const LocationWeather({
|
|
required this.city,
|
|
required this.district,
|
|
required this.temperature,
|
|
required this.condition,
|
|
required this.conditionText,
|
|
required this.highTemperature,
|
|
required this.lowTemperature,
|
|
required this.humidity,
|
|
});
|
|
|
|
final String city;
|
|
final String district;
|
|
final int temperature;
|
|
final WeatherCondition condition;
|
|
final String conditionText;
|
|
final int highTemperature;
|
|
final int lowTemperature;
|
|
final int humidity;
|
|
|
|
String get displayArea => district.isEmpty ? city : '$city · $district';
|
|
|
|
String get petAdvice {
|
|
if (condition == WeatherCondition.rainy) {
|
|
return '今天有雨,外出记得带雨具并及时擦干脚掌。';
|
|
}
|
|
if (condition == WeatherCondition.snow) {
|
|
return '天气寒冷,短毛宠物外出记得做好保暖。';
|
|
}
|
|
if (temperature >= 30) {
|
|
return '今天较热,建议清晨或傍晚带毛孩子出门。';
|
|
}
|
|
if (temperature <= 8) {
|
|
return '气温偏低,散步时间不宜过长,注意保暖。';
|
|
}
|
|
if (condition == WeatherCondition.sunny) {
|
|
return '天气不错,适合和毛孩子一起去户外散步。';
|
|
}
|
|
return '体感舒适,适合安排一次轻松的户外活动。';
|
|
}
|
|
|
|
factory LocationWeather.fromJson(Map<String, dynamic> json) {
|
|
return LocationWeather(
|
|
city: json['city'] as String,
|
|
district: json['district'] as String? ?? '',
|
|
temperature: json['temperature'] as int,
|
|
condition: WeatherCondition.values.firstWhere(
|
|
(value) => value.name == json['condition'],
|
|
orElse: () => WeatherCondition.sunny,
|
|
),
|
|
conditionText: json['conditionText'] as String,
|
|
highTemperature: json['highTemperature'] as int,
|
|
lowTemperature: json['lowTemperature'] as int,
|
|
humidity: json['humidity'] as int,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'city': city,
|
|
'district': district,
|
|
'temperature': temperature,
|
|
'condition': condition.name,
|
|
'conditionText': conditionText,
|
|
'highTemperature': highTemperature,
|
|
'lowTemperature': lowTemperature,
|
|
'humidity': humidity,
|
|
};
|
|
}
|
|
|
|
class PetProfile {
|
|
const PetProfile({
|
|
required this.name,
|
|
required this.breed,
|
|
required this.gender,
|
|
required this.birthday,
|
|
required this.weight,
|
|
required this.tags,
|
|
required this.avatarUrl,
|
|
});
|
|
|
|
final String name;
|
|
final String breed;
|
|
final PetGender gender;
|
|
final String birthday;
|
|
final double weight;
|
|
final List<String> tags;
|
|
final String avatarUrl;
|
|
|
|
PetProfile copyWith({
|
|
String? name,
|
|
String? breed,
|
|
PetGender? gender,
|
|
String? birthday,
|
|
double? weight,
|
|
List<String>? tags,
|
|
String? avatarUrl,
|
|
}) {
|
|
return PetProfile(
|
|
name: name ?? this.name,
|
|
breed: breed ?? this.breed,
|
|
gender: gender ?? this.gender,
|
|
birthday: birthday ?? this.birthday,
|
|
weight: weight ?? this.weight,
|
|
tags: tags ?? this.tags,
|
|
avatarUrl: avatarUrl ?? this.avatarUrl,
|
|
);
|
|
}
|
|
|
|
factory PetProfile.fromJson(Map<String, dynamic> json) {
|
|
return PetProfile(
|
|
name: json['name'] as String,
|
|
breed: json['breed'] as String,
|
|
gender: json['gender'] == 'female' ? PetGender.female : PetGender.male,
|
|
birthday: json['birthday'] as String,
|
|
weight: (json['weight'] as num).toDouble(),
|
|
tags: List<String>.from(json['tags'] as List),
|
|
avatarUrl: json['avatarUrl'] as String,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'name': name,
|
|
'breed': breed,
|
|
'gender': gender.name,
|
|
'birthday': birthday,
|
|
'weight': weight,
|
|
'tags': tags,
|
|
'avatarUrl': avatarUrl,
|
|
};
|
|
}
|
|
|
|
enum VaccineStatus { completed, pending }
|
|
|
|
class VaccineItem {
|
|
const VaccineItem({
|
|
required this.id,
|
|
required this.name,
|
|
required this.status,
|
|
required this.date,
|
|
});
|
|
|
|
final String id;
|
|
final String name;
|
|
final VaccineStatus status;
|
|
final String date;
|
|
|
|
VaccineItem copyWith({VaccineStatus? status, String? date}) {
|
|
return VaccineItem(
|
|
id: id,
|
|
name: name,
|
|
status: status ?? this.status,
|
|
date: date ?? this.date,
|
|
);
|
|
}
|
|
|
|
factory VaccineItem.fromJson(Map<String, dynamic> json) {
|
|
return VaccineItem(
|
|
id: json['id'] as String,
|
|
name: json['name'] as String,
|
|
status: json['status'] == 'completed'
|
|
? VaccineStatus.completed
|
|
: VaccineStatus.pending,
|
|
date: json['date'] as String,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'name': name,
|
|
'status': status.name,
|
|
'date': date,
|
|
};
|
|
}
|
|
|
|
class VaccineRecord {
|
|
const VaccineRecord({
|
|
required this.completedDoses,
|
|
required this.totalDoses,
|
|
required this.items,
|
|
required this.reminderVaccine,
|
|
required this.reminderDate,
|
|
});
|
|
|
|
final int completedDoses;
|
|
final int totalDoses;
|
|
final List<VaccineItem> items;
|
|
final String reminderVaccine;
|
|
final String reminderDate;
|
|
|
|
factory VaccineRecord.fromJson(Map<String, dynamic> json) {
|
|
return VaccineRecord(
|
|
completedDoses: json['completedDoses'] as int,
|
|
totalDoses: json['totalDoses'] as int,
|
|
items: (json['items'] as List)
|
|
.map((item) => VaccineItem.fromJson(item as Map<String, dynamic>))
|
|
.toList(),
|
|
reminderVaccine: json['reminderVaccine'] as String,
|
|
reminderDate: json['reminderDate'] as String,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'completedDoses': completedDoses,
|
|
'totalDoses': totalDoses,
|
|
'items': items.map((item) => item.toJson()).toList(),
|
|
'reminderVaccine': reminderVaccine,
|
|
'reminderDate': reminderDate,
|
|
};
|
|
}
|
|
|
|
class CommentModel {
|
|
const CommentModel({
|
|
required this.id,
|
|
required this.authorName,
|
|
required this.authorAvatar,
|
|
required this.content,
|
|
required this.time,
|
|
});
|
|
|
|
final String id;
|
|
final String authorName;
|
|
final String authorAvatar;
|
|
final String content;
|
|
final String time;
|
|
|
|
factory CommentModel.fromJson(Map<String, dynamic> json) {
|
|
return CommentModel(
|
|
id: json['id'] as String,
|
|
authorName: json['authorName'] as String,
|
|
authorAvatar: json['authorAvatar'] as String,
|
|
content: json['content'] as String,
|
|
time: json['time'] as String,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'authorName': authorName,
|
|
'authorAvatar': authorAvatar,
|
|
'content': content,
|
|
'time': time,
|
|
};
|
|
}
|
|
|
|
class PostModel {
|
|
const PostModel({
|
|
required this.id,
|
|
required this.authorName,
|
|
required this.authorAvatar,
|
|
required this.time,
|
|
required this.breedTag,
|
|
required this.content,
|
|
required this.mainImage,
|
|
required this.likes,
|
|
required this.tags,
|
|
required this.comments,
|
|
this.hasLiked = false,
|
|
this.hasBookmarked = false,
|
|
});
|
|
|
|
final String id;
|
|
final String authorName;
|
|
final String authorAvatar;
|
|
final String time;
|
|
final String breedTag;
|
|
final String content;
|
|
final String mainImage;
|
|
final int likes;
|
|
final List<String> tags;
|
|
final List<CommentModel> comments;
|
|
final bool hasLiked;
|
|
final bool hasBookmarked;
|
|
|
|
PostModel copyWith({
|
|
int? likes,
|
|
List<CommentModel>? comments,
|
|
bool? hasLiked,
|
|
bool? hasBookmarked,
|
|
}) {
|
|
return PostModel(
|
|
id: id,
|
|
authorName: authorName,
|
|
authorAvatar: authorAvatar,
|
|
time: time,
|
|
breedTag: breedTag,
|
|
content: content,
|
|
mainImage: mainImage,
|
|
likes: likes ?? this.likes,
|
|
tags: tags,
|
|
comments: comments ?? this.comments,
|
|
hasLiked: hasLiked ?? this.hasLiked,
|
|
hasBookmarked: hasBookmarked ?? this.hasBookmarked,
|
|
);
|
|
}
|
|
|
|
factory PostModel.fromJson(Map<String, dynamic> json) {
|
|
return PostModel(
|
|
id: json['id'] as String,
|
|
authorName: json['authorName'] as String,
|
|
authorAvatar: json['authorAvatar'] as String,
|
|
time: json['time'] as String,
|
|
breedTag: json['breedTag'] as String,
|
|
content: json['content'] as String,
|
|
mainImage: json['mainImage'] as String,
|
|
likes: json['likes'] as int,
|
|
tags: List<String>.from(json['tags'] as List),
|
|
comments: (json['comments'] as List)
|
|
.map((item) => CommentModel.fromJson(item as Map<String, dynamic>))
|
|
.toList(),
|
|
hasLiked: json['hasLiked'] as bool? ?? false,
|
|
hasBookmarked: json['hasBookmarked'] as bool? ?? false,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'authorName': authorName,
|
|
'authorAvatar': authorAvatar,
|
|
'time': time,
|
|
'breedTag': breedTag,
|
|
'content': content,
|
|
'mainImage': mainImage,
|
|
'likes': likes,
|
|
'tags': tags,
|
|
'comments': comments.map((comment) => comment.toJson()).toList(),
|
|
'hasLiked': hasLiked,
|
|
'hasBookmarked': hasBookmarked,
|
|
};
|
|
}
|
|
|
|
enum ProviderKind { hospital, grooming, personal }
|
|
|
|
class ServiceProviderModel {
|
|
const ServiceProviderModel({
|
|
required this.id,
|
|
required this.kind,
|
|
required this.name,
|
|
required this.distance,
|
|
required this.rating,
|
|
required this.description,
|
|
required this.tags,
|
|
required this.price,
|
|
required this.image,
|
|
this.verified = false,
|
|
});
|
|
|
|
final String id;
|
|
final ProviderKind kind;
|
|
final String name;
|
|
final String distance;
|
|
final double rating;
|
|
final String description;
|
|
final List<String> tags;
|
|
final int price;
|
|
final String image;
|
|
final bool verified;
|
|
}
|
|
|
|
class CreationStyle {
|
|
const CreationStyle({
|
|
required this.id,
|
|
required this.title,
|
|
required this.subtitle,
|
|
required this.image,
|
|
});
|
|
|
|
final String id;
|
|
final String title;
|
|
final String subtitle;
|
|
final String image;
|
|
}
|