fix: Avatar noPic detection

This commit is contained in:
Christian Pauly 2021-07-31 20:12:18 +02:00
parent 8d752164a7
commit 1a23e5fa23
2 changed files with 8 additions and 12 deletions

View File

@ -6,7 +6,7 @@ extension StringColor on String {
for (var i = 0; i < length; i++) {
number += codeUnitAt(i);
}
number = (number % 10) * 25.5;
number = (number % 12) * 25.5;
return HSLColor.fromAHSL(1, number, 1, 0.35).toColor();
}
@ -15,7 +15,7 @@ extension StringColor on String {
for (var i = 0; i < length; i++) {
number += codeUnitAt(i);
}
number = (number % 10) * 25.5;
number = (number % 12) * 25.5;
return HSLColor.fromAHSL(1, number, 1, 0.2).toColor();
}
@ -24,7 +24,7 @@ extension StringColor on String {
for (var i = 0; i < length; i++) {
number += codeUnitAt(i);
}
number = (number % 10) * 25.5;
number = (number % 12) * 25.5;
return HSLColor.fromAHSL(1, number, 1, 0.8).toColor();
}
}

View File

@ -40,14 +40,14 @@ class Avatar extends StatelessWidget {
child: Text(
fallbackLetters,
style: TextStyle(
color: Theme.of(context).brightness == Brightness.light
? name?.darkColor
: name?.lightColor ?? Colors.white,
color: Colors.white,
fontSize: 18,
),
),
);
final noPic = mxContent == null || mxContent.toString().isEmpty;
final noPic = mxContent == null ||
mxContent.toString().isEmpty ||
mxContent.toString() == 'null';
final borderRadius = BorderRadius.circular(size / 2);
return InkWell(
onTap: onTap,
@ -57,11 +57,7 @@ class Avatar extends StatelessWidget {
child: Container(
width: size,
height: size,
color: noPic
? Theme.of(context).brightness == Brightness.light
? name?.lightColor
: name?.darkColor ?? Theme.of(context).secondaryHeaderColor
: Theme.of(context).secondaryHeaderColor,
color: name?.color,
child: noPic
? textWidget
: CachedNetworkImage(