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 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 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 tags; final String avatarUrl; PetProfile copyWith({ String? name, String? breed, PetGender? gender, String? birthday, double? weight, List? 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 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.from(json['tags'] as List), avatarUrl: json['avatarUrl'] as String, ); } Map toJson() => { 'name': name, 'breed': breed, 'gender': gender.name, 'birthday': birthday, 'weight': weight, 'tags': tags, 'avatarUrl': avatarUrl, }; } 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 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 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 tags; final List comments; final bool hasLiked; final bool hasBookmarked; PostModel copyWith({ int? likes, List? 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 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.from(json['tags'] as List), comments: (json['comments'] as List) .map((item) => CommentModel.fromJson(item as Map)) .toList(), hasLiked: json['hasLiked'] as bool? ?? false, hasBookmarked: json['hasBookmarked'] as bool? ?? false, ); } Map 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 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; }