mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Can set to follow a friend
This commit is contained in:
@ -9,23 +9,27 @@ import 'package:flutter/material.dart';
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
enum _FriendMenuChoices { REMOVE }
|
||||
enum _FriendMenuChoices { REMOVE, TOGGLE_FOLLOWING }
|
||||
|
||||
typedef OnRequestDeleteFriend = void Function(Friend);
|
||||
typedef OnSetFollowing = void Function(Friend, bool);
|
||||
|
||||
class AcceptedFriendTile extends StatelessWidget {
|
||||
final Friend friend;
|
||||
final User user;
|
||||
final OnRequestDeleteFriend onRequestDelete;
|
||||
final OnSetFollowing onSetFollowing;
|
||||
|
||||
const AcceptedFriendTile(
|
||||
{Key key,
|
||||
@required this.friend,
|
||||
@required this.user,
|
||||
@required this.onRequestDelete})
|
||||
: assert(friend != null),
|
||||
const AcceptedFriendTile({
|
||||
Key key,
|
||||
@required this.friend,
|
||||
@required this.user,
|
||||
@required this.onRequestDelete,
|
||||
@required this.onSetFollowing,
|
||||
}) : assert(friend != null),
|
||||
assert(user != null),
|
||||
assert(onRequestDelete != null),
|
||||
assert(onSetFollowing != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@ -45,10 +49,22 @@ class AcceptedFriendTile extends StatelessWidget {
|
||||
),
|
||||
trailing: PopupMenuButton<_FriendMenuChoices>(
|
||||
itemBuilder: (c) => [
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(friend.following
|
||||
? Icons.check_box
|
||||
: Icons.check_box_outline_blank),
|
||||
Container(width: 10.0),
|
||||
Text(friend.following ? tr("Following") : tr("Follow")),
|
||||
],
|
||||
),
|
||||
value: _FriendMenuChoices.TOGGLE_FOLLOWING,
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Remove")),
|
||||
value: _FriendMenuChoices.REMOVE,
|
||||
)
|
||||
),
|
||||
],
|
||||
onSelected: _selectedMenuOption,
|
||||
),
|
||||
@ -59,6 +75,11 @@ class AcceptedFriendTile extends StatelessWidget {
|
||||
if (value == null) return;
|
||||
|
||||
switch (value) {
|
||||
//Toggle following status
|
||||
case _FriendMenuChoices.TOGGLE_FOLLOWING:
|
||||
onSetFollowing(friend, !friend.following);
|
||||
break;
|
||||
|
||||
//Delete friend
|
||||
case _FriendMenuChoices.REMOVE:
|
||||
onRequestDelete(friend);
|
||||
|
Reference in New Issue
Block a user