update mobile design
This commit is contained in:
@@ -2,164 +2,183 @@ import 'package:real_estate_mobile/features/agents/data/models/agent_type.dart';
|
||||
|
||||
class AgentProfile {
|
||||
final String id;
|
||||
final String? userId;
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
final String slug;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String? headline;
|
||||
final String? bio;
|
||||
final String? avatar;
|
||||
final String? licenseNumber;
|
||||
final int? experience;
|
||||
final List<String> specializations;
|
||||
final List<String> languages;
|
||||
final List<String> serviceAreas;
|
||||
final String? companyName;
|
||||
final String? phone;
|
||||
final String? website;
|
||||
final String? city;
|
||||
final String? state;
|
||||
final String? country;
|
||||
final double? rating;
|
||||
final int reviewCount;
|
||||
final double? averageRating;
|
||||
final int totalReviews;
|
||||
final bool isVerified;
|
||||
final bool isFeatured;
|
||||
final bool isAvailable;
|
||||
final String? agentTypeId;
|
||||
final bool isActive;
|
||||
final AgentType? agentType;
|
||||
final AgentUser? user;
|
||||
final List<AgentFieldValue> fieldValues;
|
||||
|
||||
const AgentProfile({
|
||||
required this.id,
|
||||
this.userId,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.slug,
|
||||
this.email,
|
||||
this.phone,
|
||||
this.headline,
|
||||
this.bio,
|
||||
this.avatar,
|
||||
this.licenseNumber,
|
||||
this.experience,
|
||||
this.specializations = const [],
|
||||
this.languages = const [],
|
||||
this.serviceAreas = const [],
|
||||
this.companyName,
|
||||
this.phone,
|
||||
this.website,
|
||||
this.city,
|
||||
this.state,
|
||||
this.country,
|
||||
this.rating,
|
||||
this.reviewCount = 0,
|
||||
this.averageRating,
|
||||
this.totalReviews = 0,
|
||||
this.isVerified = false,
|
||||
this.isFeatured = false,
|
||||
this.isAvailable = false,
|
||||
this.agentTypeId,
|
||||
this.isActive = true,
|
||||
this.agentType,
|
||||
this.user,
|
||||
this.fieldValues = const [],
|
||||
});
|
||||
|
||||
String get fullName => '$firstName $lastName'.trim();
|
||||
|
||||
/// Get avatar URL — check agent avatar first, then user avatar
|
||||
String? get avatarUrl => avatar ?? user?.avatar;
|
||||
|
||||
String get location {
|
||||
if (city != null && state != null) return '$city, $state';
|
||||
if (city != null) return city!;
|
||||
if (state != null) return state!;
|
||||
if (serviceAreas.isNotEmpty) return serviceAreas.first;
|
||||
return '';
|
||||
}
|
||||
|
||||
/// Get experience from field values
|
||||
String get experienceText {
|
||||
if (experience == null) return '';
|
||||
return '$experience+ years in the real estate industry.';
|
||||
for (final fv in fieldValues) {
|
||||
if (fv.fieldSlug.contains('experience') ||
|
||||
fv.fieldName.toLowerCase().contains('experience')) {
|
||||
if (fv.textValue != null) return fv.textValue!;
|
||||
if (fv.numberValue != null) {
|
||||
return '${fv.numberValue!.toInt()}+ years in the real estate industry.';
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/// Get specializations from field values
|
||||
List<String> get specializations {
|
||||
for (final fv in fieldValues) {
|
||||
final slug = fv.fieldSlug.toLowerCase();
|
||||
if (slug.contains('specialization') ||
|
||||
slug.contains('property_type') ||
|
||||
slug.contains('loan_type')) {
|
||||
if (fv.jsonValue is List) {
|
||||
return (fv.jsonValue as List).map((e) => e.toString()).toList();
|
||||
}
|
||||
if (fv.textValue != null) {
|
||||
return fv.textValue!.split(',').map((s) => s.trim()).toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
factory AgentProfile.fromJson(Map<String, dynamic> json) {
|
||||
return AgentProfile(
|
||||
id: json['id'] as String,
|
||||
userId: json['userId'] as String?,
|
||||
firstName: json['firstName'] as String? ?? '',
|
||||
lastName: json['lastName'] as String? ?? '',
|
||||
slug: json['slug'] as String? ?? '',
|
||||
email: json['email'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
headline: json['headline'] as String?,
|
||||
bio: json['bio'] as String?,
|
||||
avatar: json['avatar'] as String?,
|
||||
licenseNumber: json['licenseNumber'] as String?,
|
||||
experience: json['experience'] as int?,
|
||||
specializations: _parseStringList(json['specializations']),
|
||||
languages: _parseStringList(json['languages']),
|
||||
serviceAreas: _parseStringList(json['serviceAreas']),
|
||||
companyName: json['companyName'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
website: json['website'] as String?,
|
||||
city: json['city'] as String?,
|
||||
state: json['state'] as String?,
|
||||
country: json['country'] as String?,
|
||||
rating: (json['rating'] as num?)?.toDouble(),
|
||||
reviewCount: json['reviewCount'] as int? ?? 0,
|
||||
averageRating: (json['averageRating'] as num?)?.toDouble(),
|
||||
totalReviews: json['totalReviews'] as int? ?? 0,
|
||||
isVerified: json['isVerified'] as bool? ?? false,
|
||||
isFeatured: json['isFeatured'] as bool? ?? false,
|
||||
isAvailable: json['isAvailable'] as bool? ?? false,
|
||||
agentTypeId: json['agentTypeId'] as String?,
|
||||
isActive: json['isActive'] as bool? ?? true,
|
||||
agentType: json['agentType'] != null
|
||||
? AgentType.fromJson(json['agentType'] as Map<String, dynamic>)
|
||||
: null,
|
||||
user: json['user'] != null
|
||||
? AgentUser.fromJson(json['user'] as Map<String, dynamic>)
|
||||
: null,
|
||||
fieldValues: (json['fieldValues'] as List<dynamic>?)
|
||||
?.map((e) => AgentFieldValue.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static List<String> _parseStringList(dynamic value) {
|
||||
if (value == null) return const [];
|
||||
if (value is List) return value.map((e) => e.toString()).toList();
|
||||
return const [];
|
||||
class AgentUser {
|
||||
final String id;
|
||||
final String email;
|
||||
final String? avatar;
|
||||
|
||||
const AgentUser({
|
||||
required this.id,
|
||||
required this.email,
|
||||
this.avatar,
|
||||
});
|
||||
|
||||
factory AgentUser.fromJson(Map<String, dynamic> json) {
|
||||
return AgentUser(
|
||||
id: json['id'] as String,
|
||||
email: json['email'] as String? ?? '',
|
||||
avatar: json['avatar'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AgentFieldValue {
|
||||
final String id;
|
||||
final String fieldId;
|
||||
final String fieldSlug;
|
||||
final String fieldName;
|
||||
final String fieldType;
|
||||
final String? textValue;
|
||||
final num? numberValue;
|
||||
final bool? booleanValue;
|
||||
final dynamic jsonValue;
|
||||
final String? dateValue;
|
||||
final AgentField field;
|
||||
|
||||
const AgentFieldValue({
|
||||
required this.id,
|
||||
required this.fieldId,
|
||||
required this.fieldSlug,
|
||||
required this.fieldName,
|
||||
required this.fieldType,
|
||||
this.textValue,
|
||||
this.numberValue,
|
||||
this.booleanValue,
|
||||
this.jsonValue,
|
||||
this.dateValue,
|
||||
required this.field,
|
||||
});
|
||||
|
||||
factory AgentFieldValue.fromJson(Map<String, dynamic> json) {
|
||||
return AgentFieldValue(
|
||||
id: json['id'] as String,
|
||||
fieldId: json['fieldId'] as String,
|
||||
id: json['id'] as String? ?? '',
|
||||
fieldSlug: json['fieldSlug'] as String? ?? '',
|
||||
fieldName: json['fieldName'] as String? ?? '',
|
||||
fieldType: json['fieldType'] as String? ?? '',
|
||||
textValue: json['textValue'] as String?,
|
||||
numberValue: json['numberValue'] as num?,
|
||||
booleanValue: json['booleanValue'] as bool?,
|
||||
jsonValue: json['jsonValue'],
|
||||
dateValue: json['dateValue'] as String?,
|
||||
field: AgentField.fromJson(json['field'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AgentField {
|
||||
final String slug;
|
||||
final String name;
|
||||
final String fieldType;
|
||||
|
||||
const AgentField({
|
||||
required this.slug,
|
||||
required this.name,
|
||||
required this.fieldType,
|
||||
});
|
||||
|
||||
factory AgentField.fromJson(Map<String, dynamic> json) {
|
||||
return AgentField(
|
||||
slug: json['slug'] as String,
|
||||
name: json['name'] as String,
|
||||
fieldType: json['fieldType'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,29 @@
|
||||
class AgentType {
|
||||
final String id;
|
||||
final String name;
|
||||
final String slug;
|
||||
final String? description;
|
||||
final bool isActive;
|
||||
final int sortOrder;
|
||||
final int agentCount;
|
||||
|
||||
const AgentType({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.slug,
|
||||
this.description,
|
||||
this.isActive = true,
|
||||
this.sortOrder = 0,
|
||||
this.agentCount = 0,
|
||||
});
|
||||
|
||||
factory AgentType.fromJson(Map<String, dynamic> json) {
|
||||
final count = json['_count'] as Map<String, dynamic>?;
|
||||
return AgentType(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
slug: json['slug'] as String,
|
||||
description: json['description'] as String?,
|
||||
isActive: json['isActive'] as bool? ?? true,
|
||||
sortOrder: json['sortOrder'] as int? ?? 0,
|
||||
agentCount: count?['agents'] as int? ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user