- Implement DailyTaskController for managing daily tasks and fetching projects. - Create TaskModel to represent task data structure. - Develop DailyTaskScreen for displaying tasks with filtering options. - Update routes to include Daily Task navigation. - Enhance DashboardScreen to link to Daily Task. - Add Daily Task option in the left navigation bar.
51 lines
1.4 KiB
Dart
51 lines
1.4 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; // Optional: allows override
|
|
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 ?? _generateColorFromName('$firstName$lastName');
|
|
|
|
return MyContainer.rounded(
|
|
height: size,
|
|
width: size,
|
|
paddingAll: 0,
|
|
color: bgColor,
|
|
child: Center(
|
|
child: MyText.labelSmall(
|
|
initials,
|
|
fontWeight: 600,
|
|
color: textColor,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// Generate a consistent "random-like" color from the name
|
|
Color _generateColorFromName(String name) {
|
|
final hash = name.hashCode;
|
|
final r = (hash & 0xFF0000) >> 16;
|
|
final g = (hash & 0x00FF00) >> 8;
|
|
final b = (hash & 0x0000FF);
|
|
return Color.fromARGB(255, r, g, b).withOpacity(1.0);
|
|
}
|
|
}
|