feat/ChatListItem: small changes
- extract hasNotifications to a variable this is more clear and potentially faster as we don't compute `notifications > 0` multiple times - make a text style const
This commit is contained in:
parent
9f8653f7b4
commit
789d91a763
1 changed files with 9 additions and 10 deletions
|
|
@ -154,6 +154,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
? 20.0
|
? 20.0
|
||||||
: 14.0
|
: 14.0
|
||||||
: 0.0;
|
: 0.0;
|
||||||
|
final hasNotifications = room.notificationCount > 0;
|
||||||
final displayname = room.getLocalizedDisplayname(
|
final displayname = room.getLocalizedDisplayname(
|
||||||
MatrixLocals(L10n.of(context)!),
|
MatrixLocals(L10n.of(context)!),
|
||||||
);
|
);
|
||||||
|
|
@ -197,9 +198,9 @@ class ChatListItem extends StatelessWidget {
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
style: TextStyle(
|
style: unread
|
||||||
fontWeight: unread ? FontWeight.bold : null,
|
? const TextStyle(fontWeight: FontWeight.bold)
|
||||||
),
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (isMuted)
|
if (isMuted)
|
||||||
|
|
@ -213,7 +214,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
if (room.isFavourite || room.membership == Membership.invite)
|
if (room.isFavourite || room.membership == Membership.invite)
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
right: room.notificationCount > 0 ? 4.0 : 0.0,
|
right: hasNotifications ? 4.0 : 0.0,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.push_pin,
|
Icons.push_pin,
|
||||||
|
|
@ -325,9 +326,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
curve: FluffyThemes.animationCurve,
|
curve: FluffyThemes.animationCurve,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||||
height: unreadBubbleSize,
|
height: unreadBubbleSize,
|
||||||
width: room.notificationCount == 0 &&
|
width: !hasNotifications && !unread && !room.hasNewMessages
|
||||||
!unread &&
|
|
||||||
!room.hasNewMessages
|
|
||||||
? 0
|
? 0
|
||||||
: (unreadBubbleSize - 9) *
|
: (unreadBubbleSize - 9) *
|
||||||
room.notificationCount.toString().length +
|
room.notificationCount.toString().length +
|
||||||
|
|
@ -336,19 +335,19 @@ class ChatListItem extends StatelessWidget {
|
||||||
color: room.highlightCount > 0 ||
|
color: room.highlightCount > 0 ||
|
||||||
room.membership == Membership.invite
|
room.membership == Membership.invite
|
||||||
? Colors.red
|
? Colors.red
|
||||||
: room.notificationCount > 0 || room.markedUnread
|
: hasNotifications || room.markedUnread
|
||||||
? Theme.of(context).colorScheme.primary
|
? Theme.of(context).colorScheme.primary
|
||||||
: Theme.of(context).colorScheme.primaryContainer,
|
: Theme.of(context).colorScheme.primaryContainer,
|
||||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: room.notificationCount > 0
|
child: hasNotifications
|
||||||
? Text(
|
? Text(
|
||||||
room.notificationCount.toString(),
|
room.notificationCount.toString(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: room.highlightCount > 0
|
color: room.highlightCount > 0
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: room.notificationCount > 0
|
: hasNotifications
|
||||||
? Theme.of(context).colorScheme.onPrimary
|
? Theme.of(context).colorScheme.onPrimary
|
||||||
: Theme.of(context)
|
: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue