2024-06-04 20:12:12 +02:00
|
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../constants.dart';
|
|
|
|
|
|
|
|
class UserTileLikes extends StatelessWidget {
|
|
|
|
final DocumentSnapshot user;
|
|
|
|
final bool hasMatch;
|
|
|
|
final VoidCallback onUnlike;
|
2024-06-15 01:25:09 +02:00
|
|
|
final VoidCallback onShowChat;
|
2024-06-04 20:12:12 +02:00
|
|
|
final VoidCallback onViewInfo;
|
|
|
|
|
|
|
|
const UserTileLikes({
|
|
|
|
super.key,
|
|
|
|
required this.user,
|
|
|
|
required this.hasMatch,
|
|
|
|
required this.onUnlike,
|
2024-06-15 01:25:09 +02:00
|
|
|
required this.onShowChat,
|
2024-06-04 20:12:12 +02:00
|
|
|
required this.onViewInfo,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Map<String, dynamic> userMap = user.data() as Map<String, dynamic>;
|
|
|
|
bool hasPictureUrl = userMap.containsKey(Constants.dbFieldUsersProfilePic);
|
|
|
|
bool hasName = userMap.containsKey(Constants.dbFieldUsersName);
|
|
|
|
bool hasBio = userMap.containsKey(Constants.dbFieldUsersBio);
|
|
|
|
|
|
|
|
return Card(
|
|
|
|
margin: const EdgeInsets.all(8.0),
|
|
|
|
child: ListTile(
|
|
|
|
leading: hasPictureUrl == true &&
|
|
|
|
user[Constants.dbFieldUsersProfilePic] != null
|
|
|
|
? CircleAvatar(
|
|
|
|
backgroundImage: NetworkImage(
|
|
|
|
user[Constants.dbFieldUsersProfilePic],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: const CircleAvatar(
|
|
|
|
child: Icon(Icons.person),
|
|
|
|
),
|
|
|
|
title: hasName
|
|
|
|
? Text(
|
|
|
|
'${user[Constants.dbFieldUsersName]}',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 1,
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
subtitle: hasBio
|
|
|
|
? Text(
|
|
|
|
user[Constants.dbFieldUsersBio],
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 3,
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
trailing: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.contact_page_outlined),
|
|
|
|
onPressed: onViewInfo,
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
icon: hasMatch
|
2024-06-15 01:25:09 +02:00
|
|
|
? const Icon(Icons.chat_outlined)
|
2024-06-04 20:12:12 +02:00
|
|
|
: const Icon(Icons.delete_outline, color: Colors.red),
|
2024-06-15 01:25:09 +02:00
|
|
|
onPressed: hasMatch ? onShowChat : onUnlike,
|
2024-06-04 20:12:12 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|