1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Can respond to membership requests from members screen

This commit is contained in:
Pierre HUBERT 2021-04-25 17:34:20 +02:00
parent 56f92173f2
commit fae18f0abd

View File

@ -19,7 +19,12 @@ import 'package:flutter/material.dart';
/// ///
/// @author Pierre Hubert /// @author Pierre Hubert
enum _PopupMenuActions { PRIVATE_CONVERSATION, CANCEL_INVITATION } enum _PopupMenuActions {
PRIVATE_CONVERSATION,
CANCEL_INVITATION,
ACCEPT_REQUEST,
REJECT_REQUEST
}
class ForezDirectoryScreen extends StatefulWidget { class ForezDirectoryScreen extends StatefulWidget {
@override @override
@ -65,6 +70,16 @@ class _ForezDirectoryScreenState extends State<ForezDirectoryScreen> {
await GroupsHelper.cancelInvitation(forezGroup.id, user.id); await GroupsHelper.cancelInvitation(forezGroup.id, user.id);
_key.currentState.refresh(); _key.currentState.refresh();
break; 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) { } catch (e, s) {
logError(e, s); logError(e, s);
@ -90,11 +105,39 @@ class _ForezMemberTile extends StatelessWidget {
leading: AccountImageWidget(user: user), leading: AccountImageWidget(user: user),
title: Text(user.fullName), title: Text(user.fullName),
subtitle: Text(member.membershipText), subtitle: Text(member.membershipText),
trailing: user.id == userID() trailing: member.level == GroupMembershipLevel.PENDING
? _buildRequestedButton()
: _buildPopupMenuButton(),
);
Widget _buildPopupMenuButton() => user.id == userID()
? null ? null
: PopupMenuButton( : PopupMenuButton(
itemBuilder: (c) => popupMenuItems, itemBuilder: (c) => popupMenuItems,
onSelected: (a) => selectedAction(a, user), 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)),
),
],
), ),
); );