1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-26 12:58:51 +00:00

Handles groups membership request in memberships panel

This commit is contained in:
Pierre HUBERT 2020-05-06 17:48:02 +02:00
parent eabb27495c
commit 968321b12c

View File

@ -10,6 +10,7 @@ import 'package:comunic/models/friend.dart';
import 'package:comunic/models/membership.dart';
import 'package:comunic/ui/widgets/account_image_widget.dart';
import 'package:comunic/ui/widgets/group_icon_widget.dart';
import 'package:comunic/ui/widgets/group_membership_widget.dart';
import 'package:comunic/ui/widgets/safe_state.dart';
import 'package:comunic/utils/date_utils.dart';
import 'package:comunic/utils/intl_utils.dart';
@ -130,16 +131,28 @@ class _MembershipsPanelState extends SafeState<MembershipsPanel> {
);
}
// TODO : add support for pending groups memberships
Widget _buildGroupMembership(Membership membership) {
final group = _groupsList.getGroup(membership.groupID);
Widget subtitle;
if (!group.isAtLeastMember) {
subtitle = GroupMembershipWidget(
group: group,
onUpdated: () => _refreshKey.currentState.show(),
onError: _onGroupMembershipUpdateError,
);
} else {
subtitle = Text(diffTimeFromNowToStr(membership.lastActive));
}
return ListTile(
leading: GroupIcon(
group: group,
width: _MembershipIconsWidth,
),
title: Text(group.displayName),
subtitle: Text(diffTimeFromNowToStr(membership.lastActive)),
subtitle: subtitle,
);
}
@ -178,6 +191,12 @@ class _MembershipsPanelState extends SafeState<MembershipsPanel> {
showSimpleSnack(context, tr("Could not respond to friendship request!"));
}
}
/// Handles the case of failure in group membership update
void _onGroupMembershipUpdateError() {
showSimpleSnack(context, tr("Could not update group membership!"));
_refreshKey.currentState.show();
}
}
class _RespondFriendshipRequestButton extends StatelessWidget {