Add unreads back
This commit is contained in:
parent
b63c225ea5
commit
76b81ab8c4
4 changed files with 36 additions and 47 deletions
|
|
@ -1,16 +1,19 @@
|
|||
import "package:color_hash/color_hash.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter/widgets.dart";
|
||||
|
||||
class AvatarOrHash extends StatelessWidget {
|
||||
final Uri? avatar;
|
||||
final String title;
|
||||
final Widget? fallback;
|
||||
final bool hasBadge;
|
||||
final double height;
|
||||
final Map<String, String> headers;
|
||||
const AvatarOrHash(
|
||||
this.avatar,
|
||||
this.title, {
|
||||
this.fallback,
|
||||
this.hasBadge = false,
|
||||
this.height = 24,
|
||||
required this.headers,
|
||||
super.key,
|
||||
|
|
@ -22,18 +25,24 @@ class AvatarOrHash extends StatelessWidget {
|
|||
color: ColorHash(title).color,
|
||||
child: Center(child: Text(title[0])),
|
||||
);
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(4)),
|
||||
child: SizedBox(
|
||||
height: height,
|
||||
width: height,
|
||||
child: avatar == null
|
||||
? fallback ?? box
|
||||
: Image.network(
|
||||
avatar.toString(),
|
||||
headers: headers,
|
||||
errorBuilder: (_, _, _) => box,
|
||||
),
|
||||
return Center(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(4)),
|
||||
child: Badge(
|
||||
isLabelVisible: hasBadge,
|
||||
smallSize: 10,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
child: avatar == null
|
||||
? fallback ?? box
|
||||
: Image.network(
|
||||
avatar.toString(),
|
||||
headers: headers,
|
||||
width: height,
|
||||
height: height,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (_, _, _) => box,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue