1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Can respond to group membership invitations

This commit is contained in:
2020-04-15 14:31:45 +02:00
parent cd677deec0
commit 8d49a80e79
3 changed files with 59 additions and 5 deletions

View File

@ -43,8 +43,8 @@ class _GroupMembershipWidgetState extends SafeState<GroupMembershipWidget> {
return Text(tr("Member"));
case GroupMembershipLevel.INVITED:
// TODO: Handle this case.
break;
return _buildInvitedState();
case GroupMembershipLevel.PENDING:
return _buildPendingState();
@ -53,6 +53,49 @@ class _GroupMembershipWidgetState extends SafeState<GroupMembershipWidget> {
}
}
/// Build invited state
Widget _buildInvitedState() {
return RichText(
text: TextSpan(children: [
WidgetSpan(
child: Icon(Icons.info_outline, size: 12),
alignment: PlaceholderAlignment.middle),
TextSpan(text: " " + tr("Invited") + " "),
TextSpan(
text: tr("Accept"),
style: TextStyle(color: Colors.green),
recognizer: TapGestureRecognizer()
..onTap = () => _respondInvitation(true)),
TextSpan(text: " "),
TextSpan(
text: tr("Reject"),
style: TextStyle(color: Colors.red),
recognizer: TapGestureRecognizer()
..onTap = () => _respondInvitation(false)),
]),
);
}
/// Respond to an invitation
void _respondInvitation(bool accept) async {
if (!accept &&
!await showConfirmDialog(
context: context,
message: tr("Do you really want to reject this invitation?")))
return;
if (!await GroupsHelper().respondInvitation(_id, accept))
showSimpleSnack(context, tr("Could not respond to your invitation!"));
else {
// Refresh state
group.membershipLevel =
accept ? GroupMembershipLevel.MEMBER : GroupMembershipLevel.VISITOR;
this.setState(() {});
if (this.widget.onUpdated != null) this.widget.onUpdated();
}
}
/// Build pending state
Widget _buildPendingState() {
return RichText(