2023-05-01 13:13:40 -04:00
|
|
|
import 'package:contacts_plus_plus/auxiliary.dart';
|
|
|
|
import 'package:contacts_plus_plus/models/friend.dart';
|
|
|
|
import 'package:contacts_plus_plus/widgets/generic_avatar.dart';
|
2023-05-03 15:55:34 -04:00
|
|
|
import 'package:contacts_plus_plus/widgets/messages_list.dart';
|
2023-04-30 09:43:59 -04:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class FriendListTile extends StatelessWidget {
|
2023-05-03 14:03:46 -04:00
|
|
|
const FriendListTile({required this.friend, this.unreads, this.onTap, super.key});
|
2023-04-30 09:43:59 -04:00
|
|
|
|
|
|
|
final Friend friend;
|
2023-05-03 14:03:46 -04:00
|
|
|
final int? unreads;
|
|
|
|
final Function? onTap;
|
2023-04-30 09:43:59 -04:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-04-30 17:14:29 -04:00
|
|
|
final imageUri = Aux.neosDbToHttp(friend.userProfile.iconUrl);
|
2023-05-03 14:03:46 -04:00
|
|
|
final theme = Theme.of(context);
|
2023-04-30 09:43:59 -04:00
|
|
|
return ListTile(
|
2023-04-30 17:14:29 -04:00
|
|
|
leading: GenericAvatar(imageUri: imageUri,),
|
2023-05-03 14:03:46 -04:00
|
|
|
trailing: unreads != null && unreads != 0
|
|
|
|
? Text("+$unreads", style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.primary),)
|
|
|
|
: null,
|
2023-04-30 09:43:59 -04:00
|
|
|
title: Text(friend.username),
|
|
|
|
subtitle: Text(friend.userStatus.onlineStatus.name),
|
2023-05-03 14:03:46 -04:00
|
|
|
onTap: () async {
|
2023-05-03 15:55:34 -04:00
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (context) => MessagesList(friend: friend)));
|
2023-05-03 14:03:46 -04:00
|
|
|
await onTap?.call();
|
2023-04-30 09:43:59 -04:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|