mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Can remove a friend from the list of friends
This commit is contained in:
@ -9,14 +9,23 @@ import 'package:flutter/material.dart';
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
enum _FriendMenuChoices { REMOVE }
|
||||
|
||||
typedef OnRequestDeleteFriend = void Function(Friend);
|
||||
|
||||
class AcceptedFriendTile extends StatelessWidget {
|
||||
final Friend friend;
|
||||
final User user;
|
||||
final OnRequestDeleteFriend onRequestDelete;
|
||||
|
||||
const AcceptedFriendTile(
|
||||
{Key key, @required this.friend, @required this.user})
|
||||
{Key key,
|
||||
@required this.friend,
|
||||
@required this.user,
|
||||
@required this.onRequestDelete})
|
||||
: assert(friend != null),
|
||||
assert(user != null),
|
||||
assert(onRequestDelete != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@ -32,8 +41,28 @@ class AcceptedFriendTile extends StatelessWidget {
|
||||
style: TextStyle(color: Colors.green),
|
||||
)
|
||||
: Text(
|
||||
diffTimeFromNowToStr(friend.lastActive),
|
||||
diffTimeFromNowToStr(friend.lastActive),
|
||||
),
|
||||
trailing: PopupMenuButton<_FriendMenuChoices>(
|
||||
itemBuilder: (c) => [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Remove")),
|
||||
value: _FriendMenuChoices.REMOVE,
|
||||
)
|
||||
],
|
||||
onSelected: _selectedMenuOption,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _selectedMenuOption(_FriendMenuChoices value) {
|
||||
if (value == null) return;
|
||||
|
||||
switch (value) {
|
||||
//Delete friend
|
||||
case _FriendMenuChoices.REMOVE:
|
||||
onRequestDelete(friend);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user