cofounderella/lib/components/user_tile_likes.dart

75 lines
2.2 KiB
Dart

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;
final VoidCallback onShowMatchMessage;
final VoidCallback onViewInfo;
const UserTileLikes({
super.key,
required this.user,
required this.hasMatch,
required this.onUnlike,
required this.onShowMatchMessage,
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
? const Icon(Icons.lock_outline)
: const Icon(Icons.delete_outline, color: Colors.red),
onPressed: hasMatch ? onShowMatchMessage : onUnlike,
),
],
),
),
);
}
}