2019-05-01 15:52:41 +00:00
|
|
|
import 'package:comunic/models/friend.dart';
|
|
|
|
import 'package:comunic/models/user.dart';
|
|
|
|
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
|
|
|
import 'package:comunic/utils/intl_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Pending friend tile
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
|
|
|
typedef RespondFriendshipRequestCallback = void Function(Friend, bool);
|
|
|
|
|
|
|
|
class PendingFriendTile extends StatelessWidget {
|
|
|
|
final Friend friend;
|
|
|
|
final User user;
|
|
|
|
final RespondFriendshipRequestCallback onRespond;
|
|
|
|
|
|
|
|
const PendingFriendTile(
|
|
|
|
{Key key,
|
|
|
|
@required this.friend,
|
|
|
|
@required this.user,
|
|
|
|
@required this.onRespond})
|
|
|
|
: assert(friend != null),
|
|
|
|
assert(user != null),
|
|
|
|
assert(onRespond != null),
|
|
|
|
super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListTile(
|
|
|
|
leading: AccountImageWidget(
|
|
|
|
user: user,
|
|
|
|
),
|
|
|
|
isThreeLine: true,
|
|
|
|
title: Text(user.fullName),
|
|
|
|
subtitle: Container(
|
|
|
|
height: 30.0,
|
|
|
|
margin: EdgeInsets.only(top: 8.0),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: <Widget>[
|
2021-03-13 14:28:34 +00:00
|
|
|
ElevatedButton(
|
2019-05-01 15:52:41 +00:00
|
|
|
child: Text(
|
|
|
|
tr("Accept").toUpperCase(),
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
),
|
2021-03-13 14:28:34 +00:00
|
|
|
style: ButtonStyle(
|
|
|
|
backgroundColor: MaterialStateProperty.all(Colors.green)),
|
2019-05-01 15:52:41 +00:00
|
|
|
onPressed: () => onRespond(friend, true),
|
|
|
|
),
|
2021-03-13 14:28:34 +00:00
|
|
|
Container(
|
|
|
|
width: 8.0,
|
|
|
|
),
|
|
|
|
ElevatedButton(
|
2019-05-01 15:52:41 +00:00
|
|
|
child: Text(
|
|
|
|
tr("Reject").toUpperCase(),
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
),
|
2021-03-13 14:28:34 +00:00
|
|
|
style: ButtonStyle(
|
|
|
|
backgroundColor: MaterialStateProperty.all(Colors.red)),
|
2019-05-01 15:52:41 +00:00
|
|
|
onPressed: () => onRespond(friend, false),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|