Change status indicator to not show cpp badge when user is offline

This commit is contained in:
Nutcake 2023-05-29 16:14:07 +02:00
parent 533e4d4297
commit d9de622995
2 changed files with 44 additions and 29 deletions

View file

@ -22,17 +22,27 @@ class FriendListTile extends StatelessWidget {
final imageUri = Aux.neosDbToHttp(friend.userProfile.iconUrl);
final theme = Theme.of(context);
return ListTile(
leading: GenericAvatar(imageUri: imageUri,),
leading: GenericAvatar(
imageUri: imageUri,
),
trailing: unreads != 0
? Text("+$unreads", style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.primary),)
? Text(
"+$unreads",
style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.primary),
)
: null,
title: Row(
children: [
Text(friend.username),
if (friend.isHeadless) Padding(
padding: const EdgeInsets.only(left: 8),
child: Icon(Icons.dns, size: 12, color: theme.colorScheme.onSecondaryContainer.withAlpha(150),),
),
if (friend.isHeadless)
Padding(
padding: const EdgeInsets.only(left: 8),
child: Icon(
Icons.dns,
size: 12,
color: theme.colorScheme.onSecondaryContainer.withAlpha(150),
),
),
],
),
subtitle: Row(
@ -40,13 +50,19 @@ class FriendListTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FriendOnlineStatusIndicator(userStatus: friend.userStatus),
const SizedBox(width: 4,),
const SizedBox(
width: 4,
),
Text(toBeginningOfSentenceCase(friend.userStatus.onlineStatus.name) ?? "Unknown"),
if (!friend.userStatus.currentSession.isNone)
...[
const Text(" in "),
Expanded(child: FormattedText(friend.userStatus.currentSession.formattedName, overflow: TextOverflow.ellipsis, maxLines: 1,))
]
if (!friend.userStatus.currentSession.isNone) ...[
const Text(" in "),
Expanded(
child: FormattedText(
friend.userStatus.currentSession.formattedName,
overflow: TextOverflow.ellipsis,
maxLines: 1,
))
]
],
),
onTap: () async {
@ -65,8 +81,7 @@ class FriendListTile extends StatelessWidget {
mClient.selectedFriend = friend;
await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
ChangeNotifierProvider<MessagingClient>.value(
builder: (context) => ChangeNotifierProvider<MessagingClient>.value(
value: mClient,
child: MessagesList(friend: friend),
),

View file

@ -1,4 +1,3 @@
import 'package:contacts_plus_plus/models/friend.dart';
import 'package:flutter/material.dart';
@ -9,18 +8,19 @@ class FriendOnlineStatusIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return
userStatus.neosVersion.contains("Contacts++") ? SizedBox.square(
dimension: 10,
child: Image.asset(
"assets/images/logo-white.png",
alignment: Alignment.center,
color: userStatus.onlineStatus.color(context),
),
) : Icon(
userStatus.onlineStatus == OnlineStatus.offline ? Icons.circle_outlined : Icons.circle,
color: userStatus.onlineStatus.color(context),
size: 10,
);
return userStatus.neosVersion.contains("Contacts++") && userStatus.onlineStatus != OnlineStatus.offline
? SizedBox.square(
dimension: 10,
child: Image.asset(
"assets/images/logo-white.png",
alignment: Alignment.center,
color: userStatus.onlineStatus.color(context),
),
)
: Icon(
userStatus.onlineStatus == OnlineStatus.offline ? Icons.circle_outlined : Icons.circle,
color: userStatus.onlineStatus.color(context),
size: 10,
);
}
}
}