mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +00:00
Handles groups membership request in memberships panel
This commit is contained in:
parent
eabb27495c
commit
968321b12c
@ -10,6 +10,7 @@ import 'package:comunic/models/friend.dart';
|
|||||||
import 'package:comunic/models/membership.dart';
|
import 'package:comunic/models/membership.dart';
|
||||||
import 'package:comunic/ui/widgets/account_image_widget.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_icon_widget.dart';
|
||||||
|
import 'package:comunic/ui/widgets/group_membership_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||||
import 'package:comunic/utils/date_utils.dart';
|
import 'package:comunic/utils/date_utils.dart';
|
||||||
import 'package:comunic/utils/intl_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) {
|
Widget _buildGroupMembership(Membership membership) {
|
||||||
final group = _groupsList.getGroup(membership.groupID);
|
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(
|
return ListTile(
|
||||||
leading: GroupIcon(
|
leading: GroupIcon(
|
||||||
group: group,
|
group: group,
|
||||||
width: _MembershipIconsWidth,
|
width: _MembershipIconsWidth,
|
||||||
),
|
),
|
||||||
title: Text(group.displayName),
|
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!"));
|
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 {
|
class _RespondFriendshipRequestButton extends StatelessWidget {
|
||||||
|
Loading…
Reference in New Issue
Block a user