mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-21 20:39:22 +00:00
Can respond to membership requests from members screen
This commit is contained in:
parent
56f92173f2
commit
fae18f0abd
@ -19,7 +19,12 @@ import 'package:flutter/material.dart';
|
||||
///
|
||||
/// @author Pierre Hubert
|
||||
|
||||
enum _PopupMenuActions { PRIVATE_CONVERSATION, CANCEL_INVITATION }
|
||||
enum _PopupMenuActions {
|
||||
PRIVATE_CONVERSATION,
|
||||
CANCEL_INVITATION,
|
||||
ACCEPT_REQUEST,
|
||||
REJECT_REQUEST
|
||||
}
|
||||
|
||||
class ForezDirectoryScreen extends StatefulWidget {
|
||||
@override
|
||||
@ -65,6 +70,16 @@ class _ForezDirectoryScreenState extends State<ForezDirectoryScreen> {
|
||||
await GroupsHelper.cancelInvitation(forezGroup.id, user.id);
|
||||
_key.currentState.refresh();
|
||||
break;
|
||||
|
||||
case _PopupMenuActions.ACCEPT_REQUEST:
|
||||
await GroupsHelper.respondRequest(forezGroup.id, user.id, true);
|
||||
_key.currentState.refresh();
|
||||
break;
|
||||
|
||||
case _PopupMenuActions.REJECT_REQUEST:
|
||||
await GroupsHelper.respondRequest(forezGroup.id, user.id, false);
|
||||
_key.currentState.refresh();
|
||||
break;
|
||||
}
|
||||
} catch (e, s) {
|
||||
logError(e, s);
|
||||
@ -90,12 +105,40 @@ class _ForezMemberTile extends StatelessWidget {
|
||||
leading: AccountImageWidget(user: user),
|
||||
title: Text(user.fullName),
|
||||
subtitle: Text(member.membershipText),
|
||||
trailing: user.id == userID()
|
||||
? null
|
||||
: PopupMenuButton(
|
||||
itemBuilder: (c) => popupMenuItems,
|
||||
onSelected: (a) => selectedAction(a, user),
|
||||
),
|
||||
trailing: member.level == GroupMembershipLevel.PENDING
|
||||
? _buildRequestedButton()
|
||||
: _buildPopupMenuButton(),
|
||||
);
|
||||
|
||||
Widget _buildPopupMenuButton() => user.id == userID()
|
||||
? null
|
||||
: PopupMenuButton(
|
||||
itemBuilder: (c) => popupMenuItems,
|
||||
onSelected: (a) => selectedAction(a, user),
|
||||
);
|
||||
|
||||
Widget _buildRequestedButton() => IntrinsicWidth(
|
||||
child: Row(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
selectedAction(_PopupMenuActions.ACCEPT_REQUEST, user),
|
||||
child: Icon(Icons.check),
|
||||
style: ButtonStyle(
|
||||
visualDensity: VisualDensity.compact,
|
||||
backgroundColor: MaterialStateProperty.all(Colors.green)),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
OutlinedButton(
|
||||
onPressed: () =>
|
||||
selectedAction(_PopupMenuActions.REJECT_REQUEST, user),
|
||||
child: Icon(Icons.close),
|
||||
style: ButtonStyle(
|
||||
visualDensity: VisualDensity.compact,
|
||||
foregroundColor: MaterialStateProperty.all(Colors.redAccent)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
List<PopupMenuItem<_PopupMenuActions>> get popupMenuItems => [
|
||||
|
Loading…
Reference in New Issue
Block a user