Vaibhav Surve a0f1602f4e feat(directory): add contact profile and directory management features
- Implemented ContactProfileResponse and related models for handling contact details.
- Created ContactTagResponse and ContactTag models for managing contact tags.
- Added DirectoryCommentResponse and DirectoryComment models for comment management.
- Developed DirectoryFilterBottomSheet for filtering contacts.
- Introduced OrganizationListModel for organization data handling.
- Updated routes to include DirectoryMainScreen.
- Enhanced DashboardScreen to navigate to the new directory page.
- Created ContactDetailScreen for displaying detailed contact information.
- Developed DirectoryMainScreen for managing and displaying contacts.
- Added dependencies for font_awesome_flutter and flutter_html in pubspec.yaml.
2025-07-02 15:57:39 +05:30

67 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:marco/helpers/widgets/my_container.dart';
import 'package:marco/helpers/widgets/my_text.dart';
class Avatar extends StatelessWidget {
final String firstName;
final String lastName;
final double size;
final Color? backgroundColor;
final Color textColor;
const Avatar({
super.key,
required this.firstName,
required this.lastName,
this.size = 46.0,
this.backgroundColor,
this.textColor = Colors.white,
});
@override
Widget build(BuildContext context) {
String initials = "${firstName.isNotEmpty ? firstName[0] : ''}${lastName.isNotEmpty ? lastName[0] : ''}".toUpperCase();
final Color bgColor = backgroundColor ?? _getFlatColorFromName('$firstName$lastName');
return MyContainer.rounded(
height: size,
width: size,
paddingAll: 0,
color: bgColor,
child: Center(
child: MyText.labelSmall(
initials,
fontWeight: 600,
color: textColor,
),
),
);
}
// Use fixed flat color palette and pick based on hash
Color _getFlatColorFromName(String name) {
final colors = <Color>[
Color(0xFFE57373), // Red
Color(0xFFF06292), // Pink
Color(0xFFBA68C8), // Purple
Color(0xFF9575CD), // Deep Purple
Color(0xFF7986CB), // Indigo
Color(0xFF64B5F6), // Blue
Color(0xFF4FC3F7), // Light Blue
Color(0xFF4DD0E1), // Cyan
Color(0xFF4DB6AC), // Teal
Color(0xFF81C784), // Green
Color(0xFFAED581), // Light Green
Color(0xFFDCE775), // Lime
Color(0xFFFFD54F), // Amber
Color(0xFFFFB74D), // Orange
Color(0xFFA1887F), // Brown
Color(0xFF90A4AE), // Blue Grey
];
int index = name.hashCode.abs() % colors.length;
return colors[index];
}
}