diff --git a/lib/ui/widgets/tablet_mode/memberships_panel.dart b/lib/ui/widgets/tablet_mode/memberships_panel.dart index eae0231..010b9fc 100644 --- a/lib/ui/widgets/tablet_mode/memberships_panel.dart +++ b/lib/ui/widgets/tablet_mode/memberships_panel.dart @@ -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 { ); } - // 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 { 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 {