Co-authored-by: eddgranados12 <eddgranados12@users.noreply.github.com>
Co-authored-by: MENDOZA BALLARDO GAEL RICARDO <gael-meb123@users.noreply.github.com> Co-authored-by: Azareth-Tr <Azareth-Tr@users.noreply.github.com> modificacion de vistas panel admin, login, animaciones y implementacion de mascota
This commit is contained in:
34
recolecta_app/lib/features/admin/models/admin_user.dart
Normal file
34
recolecta_app/lib/features/admin/models/admin_user.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
class AdminUserModel {
|
||||
final String id;
|
||||
final String? name;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String role;
|
||||
|
||||
const AdminUserModel({
|
||||
required this.id,
|
||||
this.name,
|
||||
this.email,
|
||||
this.phone,
|
||||
this.role = 'citizen',
|
||||
});
|
||||
|
||||
String get displayName =>
|
||||
(name == null || name!.trim().isEmpty) ? (email ?? phone ?? id) : name!;
|
||||
|
||||
String get initials {
|
||||
final source = displayName.trim();
|
||||
if (source.isEmpty) return '?';
|
||||
final parts = source.split(RegExp(r'\s+'));
|
||||
if (parts.length == 1) return parts.first.substring(0, 1).toUpperCase();
|
||||
return (parts[0].substring(0, 1) + parts[1].substring(0, 1)).toUpperCase();
|
||||
}
|
||||
|
||||
factory AdminUserModel.fromJson(Map<String, dynamic> json) => AdminUserModel(
|
||||
id: json['id'].toString(),
|
||||
name: json['name'] as String?,
|
||||
email: json['email'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
role: (json['role'] as String?) ?? 'citizen',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user