Add colored user status and client indicator

This commit is contained in:
Nutcake 2023-05-07 13:38:45 +02:00
parent 1ffc171028
commit 0d04bcdd1c
4 changed files with 50 additions and 5 deletions

View file

@ -83,7 +83,7 @@ enum OnlineStatus {
online;
static final List<Color> _colors = [
Colors.black54,
Colors.white54,
Colors.white54,
Colors.yellow,
Colors.red,
@ -116,7 +116,7 @@ class UserStatus {
final List<Session> activeSessions;
final String neosVersion;
UserStatus({required this.onlineStatus, required this.lastStatusChange, required this.activeSessions,
const UserStatus({required this.onlineStatus, required this.lastStatusChange, required this.activeSessions,
required this.neosVersion,
});

View file

@ -2,10 +2,12 @@ import 'package:contacts_plus_plus/auxiliary.dart';
import 'package:contacts_plus_plus/clients/messaging_client.dart';
import 'package:contacts_plus_plus/models/friend.dart';
import 'package:contacts_plus_plus/models/message.dart';
import 'package:contacts_plus_plus/widgets/friends/friend_online_status_indicator.dart';
import 'package:contacts_plus_plus/widgets/generic_avatar.dart';
import 'package:contacts_plus_plus/widgets/messages/messages_list.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
class FriendListTile extends StatelessWidget {
@ -25,7 +27,15 @@ class FriendListTile extends StatelessWidget {
? Text("+$unreads", style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.primary),)
: null,
title: Text(friend.username),
subtitle: Text(toBeginningOfSentenceCase(friend.userStatus.onlineStatus.name) ?? "Unknown"),
subtitle: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FriendOnlineStatusIndicator(userStatus: friend.userStatus),
const SizedBox(width: 4,),
Text(toBeginningOfSentenceCase(friend.userStatus.onlineStatus.name) ?? "Unknown"),
],
),
onTap: () async {
onTap?.call();
final mClient = Provider.of<MessagingClient>(context, listen: false);
@ -53,4 +63,4 @@ class FriendListTile extends StatelessWidget {
},
);
}
}
}

View file

@ -0,0 +1,26 @@
import 'package:contacts_plus_plus/models/friend.dart';
import 'package:flutter/material.dart';
class FriendOnlineStatusIndicator extends StatelessWidget {
const FriendOnlineStatusIndicator({required this.userStatus, super.key});
final UserStatus userStatus;
@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,
),
) : Icon(
userStatus.onlineStatus == OnlineStatus.offline ? Icons.circle_outlined : Icons.circle,
color: userStatus.onlineStatus.color,
size: 10,
);
}
}

View file

@ -2,6 +2,7 @@ import 'package:contacts_plus_plus/client_holder.dart';
import 'package:contacts_plus_plus/clients/messaging_client.dart';
import 'package:contacts_plus_plus/models/friend.dart';
import 'package:contacts_plus_plus/models/message.dart';
import 'package:contacts_plus_plus/widgets/friends/friend_online_status_indicator.dart';
import 'package:contacts_plus_plus/widgets/messages/messages_session_header.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@ -65,7 +66,15 @@ class _MessagesListState extends State<MessagesList> {
.surfaceVariant;
return Scaffold(
appBar: AppBar(
title: Text(widget.friend.username),
title: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FriendOnlineStatusIndicator(userStatus: widget.friend.userStatus),
const SizedBox(width: 8,),
Text(widget.friend.username),
],
),
scrolledUnderElevation: 0.0,
backgroundColor: appBarColor,
),