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

View file

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