41 lines
1.0 KiB
Dart
41 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:badges/badges.dart' as badges;
|
|
import 'package:together_mobile/common/constants.dart';
|
|
|
|
class BadgeAvatar extends StatelessWidget {
|
|
const BadgeAvatar({
|
|
super.key,
|
|
required this.unreadCount,
|
|
required this.radius,
|
|
required this.backgroundImage,
|
|
});
|
|
|
|
final int unreadCount;
|
|
final double radius;
|
|
final ImageProvider<Object> backgroundImage;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return badges.Badge(
|
|
showBadge: unreadCount > 0,
|
|
badgeStyle: const badges.BadgeStyle(
|
|
badgeColor: kErrorColor,
|
|
elevation: 12,
|
|
),
|
|
badgeContent: Text(
|
|
unreadCount > 99 ? '$unreadCount+' : '$unreadCount',
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
color: Theme.of(context).colorScheme.inversePrimary,
|
|
),
|
|
),
|
|
badgeAnimation: const badges.BadgeAnimation.scale(),
|
|
position: badges.BadgePosition.topEnd(top: -12, end: -16),
|
|
child: CircleAvatar(
|
|
backgroundImage: backgroundImage,
|
|
),
|
|
);
|
|
}
|
|
}
|