mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Can cancel membership request
This commit is contained in:
parent
eaeb07db69
commit
2c9dc5199c
@ -114,6 +114,10 @@ class GroupsHelper {
|
||||
Future<bool> cancelRequest(int groupID) async =>
|
||||
_simpleMembershipRequest(groupID, "groups/cancel_request");
|
||||
|
||||
/// Send a new membership request
|
||||
Future<bool> sendRequest(int groupID) async =>
|
||||
_simpleMembershipRequest(groupID, "groups/send_request");
|
||||
|
||||
/// Turn an API entry into a group object
|
||||
Group _getGroupFromAPI(Map<String, dynamic> map) {
|
||||
return Group(
|
||||
|
@ -49,8 +49,7 @@ class _GroupMembershipWidgetState extends SafeState<GroupMembershipWidget> {
|
||||
return _buildPendingState();
|
||||
|
||||
case GroupMembershipLevel.VISITOR:
|
||||
// TODO: Handle this case.
|
||||
break;
|
||||
return _buildVisitorState();
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,4 +78,28 @@ class _GroupMembershipWidgetState extends SafeState<GroupMembershipWidget> {
|
||||
if (this.widget.onUpdated != null) this.widget.onUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
/// Build visitor state
|
||||
Widget _buildVisitorState() {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
text: tr("Request membership"),
|
||||
style: TextStyle(color: Colors.blue),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () => _requestMembership()),
|
||||
);
|
||||
}
|
||||
|
||||
/// Create new membership request
|
||||
void _requestMembership() async {
|
||||
if (!await GroupsHelper().sendRequest(_id))
|
||||
showSimpleSnack(context, tr("Could not send your membership request!"));
|
||||
else {
|
||||
// Refresh state
|
||||
group.membershipLevel = GroupMembershipLevel.PENDING;
|
||||
this.setState(() {});
|
||||
|
||||
if (this.widget.onUpdated != null) this.widget.onUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user