Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spaces] M10.8 Browsing users in a space #4682 #4742

Merged
merged 15 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1682,9 +1682,11 @@ Tap the + to start adding people.";
"spaces_empty_space_detail" = "Some rooms may be hidden because they’re private and you need an invite.";
"spaces_no_result_found_title" = "No results found";
"spaces_no_room_found_detail" = "Some results may be hidden because they’re private and you need an invite to join them.";
"spaces_no_member_found_detail" = "Looking for someone not in space name? For now, you can invite them on web or desktop.";
"spaces_no_member_found_detail" = "Looking for someone not in %@? For now, you can invite them on web or desktop.";
"spaces_coming_soon_title" = "Coming soon";
"spaces_coming_soon_detail" = "This feature hasn’t been implemented here, but it’s on the way. For now, you can do that with Element on your computer.";
"space_participants_action_remove" = "Remove from this space";
"space_participants_action_ban" = "Ban from this space";

// Mark: Avatar

Expand Down
14 changes: 11 additions & 3 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4722,6 +4722,14 @@ internal enum VectorL10n {
internal static var spaceFeatureUnavailableTitle: String {
return VectorL10n.tr("Vector", "space_feature_unavailable_title")
}
/// Ban from this space
internal static var spaceParticipantsActionBan: String {
return VectorL10n.tr("Vector", "space_participants_action_ban")
}
/// Remove from this space
internal static var spaceParticipantsActionRemove: String {
return VectorL10n.tr("Vector", "space_participants_action_remove")
}
/// space
internal static var spaceTag: String {
return VectorL10n.tr("Vector", "space_tag")
Expand Down Expand Up @@ -4754,9 +4762,9 @@ internal enum VectorL10n {
internal static var spacesLeftPanelTitle: String {
return VectorL10n.tr("Vector", "spaces_left_panel_title")
}
/// Looking for someone not in space name? For now, you can invite them on web or desktop.
internal static var spacesNoMemberFoundDetail: String {
return VectorL10n.tr("Vector", "spaces_no_member_found_detail")
/// Looking for someone not in %@? For now, you can invite them on web or desktop.
internal static func spacesNoMemberFoundDetail(_ p1: String) -> String {
return VectorL10n.tr("Vector", "spaces_no_member_found_detail", p1)
}
/// No results found
internal static var spacesNoResultFoundTitle: String {
Expand Down
4 changes: 4 additions & 0 deletions Riot/Managers/UserSessions/UserSessionsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ extension UserSessionsService {
@objcMembers
class UserSessionsService: NSObject {

// MARK: - Singleton

static public let shared: UserSessionsService = UserSessionsService()

// MARK: - Properties

// MARK: Private
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
init(router: RootRouterType, window: UIWindow) {
self.rootRouter = router
self.customSchemeURLParser = CustomSchemeURLParser()
self.userSessionsService = UserSessionsService()
self.userSessionsService = UserSessionsService.shared

super.init()

Expand Down
11 changes: 1 addition & 10 deletions Riot/Modules/Contacts/Views/ContactTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,7 @@ - (void)setShowCustomAccessoryView:(BOOL)show
{
_showCustomAccessoryView = show;

if (show)
{
self.customAccessViewWidthConstraint.constant = 25;
self.customAccessoryViewLeadingConstraint.constant = 13;
}
else
{
self.customAccessViewWidthConstraint.constant = 0;
self.customAccessoryViewLeadingConstraint.constant = 0;
}
self.customAccessViewWidthConstraint.constant = show ? 25 : 0;
}

- (void)setShowMatrixIdInDisplayName:(BOOL)showMatrixIdInDisplayName
Expand Down
24 changes: 22 additions & 2 deletions Riot/Modules/People/PeopleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@

#import "Riot-Swift.h"

@interface PeopleViewController ()
@interface PeopleViewController () <SpaceMembersCoordinatorBridgePresenterDelegate>
{
NSInteger directRoomsSectionNumber;
RecentsDataSource *recentsDataSource;
}

@property(nonatomic) SpaceMembersCoordinatorBridgePresenter *spaceMembersCoordinatorBridgePresenter;

@end

@implementation PeopleViewController
Expand Down Expand Up @@ -119,7 +121,16 @@ - (void)refreshCurrentSelectedCell:(BOOL)forceVisible

- (void)onPlusButtonPressed
{
[self performSegueWithIdentifier:@"presentStartChat" sender:self];
if (self.dataSource.currentSpace != nil)
{
self.spaceMembersCoordinatorBridgePresenter = [[SpaceMembersCoordinatorBridgePresenter alloc] initWithUserSessionsService:[UserSessionsService shared] session:self.mainSession spaceId:self.dataSource.currentSpace.spaceId];
self.spaceMembersCoordinatorBridgePresenter.delegate = self;
[self.spaceMembersCoordinatorBridgePresenter presentFrom:self animated:YES];
}
else
{
[self performSegueWithIdentifier:@"presentStartChat" sender:self];
}
}

#pragma mark -
Expand Down Expand Up @@ -172,4 +183,13 @@ - (NSUInteger)totalItemCounts
+ recentsDataSource.conversationCellDataArray.count;
}

#pragma mark - SpaceMembersCoordinatorBridgePresenterDelegate

- (void)spaceMembersCoordinatorBridgePresenterDelegateDidComplete:(SpaceMembersCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
[coordinatorBridgePresenter dismissWithAnimated:YES completion:^{
self.spaceMembersCoordinatorBridgePresenter = nil;
}];
}

@end
30 changes: 26 additions & 4 deletions Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ - (void)presentCompleteSecurity
[[AppDelegate theDelegate] presentCompleteSecurityForSession:self.mainSession];
}

- (void)showRoomWithId:(NSString*)roomId
{
[[AppDelegate theDelegate] showRoom:roomId andEventId:nil withMatrixSession:self.mainSession];
}

#pragma mark - Hide/Show navigation bar border

- (void)hideNavigationBarBorder:(BOOL)isHidden
Expand Down Expand Up @@ -518,7 +523,10 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
isOneself = YES;

[otherActionsArray addObject:@(MXKRoomMemberDetailsActionLeave)];
if (self.enableLeave)
{
[otherActionsArray addObject:@(MXKRoomMemberDetailsActionLeave)];
}

if (oneSelfPowerLevel >= [powerLevels minimumPowerLevelForSendingEventAsStateEvent:kMXEventTypeStringRoomPowerLevels])
{
Expand Down Expand Up @@ -754,10 +762,24 @@ - (NSString*)actionButtonTitle:(MXKRoomMemberDetailsAction)action
title = NSLocalizedStringFromTable(@"room_participants_action_leave", @"Vector", nil);
break;
case MXKRoomMemberDetailsActionKick:
title = NSLocalizedStringFromTable(@"room_participants_action_remove", @"Vector", nil);
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
title = NSLocalizedStringFromTable(@"space_participants_action_remove", @"Vector", nil);
}
else
{
title = NSLocalizedStringFromTable(@"room_participants_action_remove", @"Vector", nil);
}
break;
case MXKRoomMemberDetailsActionBan:
title = NSLocalizedStringFromTable(@"room_participants_action_ban", @"Vector", nil);
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
title = NSLocalizedStringFromTable(@"space_participants_action_ban", @"Vector", nil);
}
else
{
title = NSLocalizedStringFromTable(@"room_participants_action_ban", @"Vector", nil);
}
break;
case MXKRoomMemberDetailsActionUnban:
title = NSLocalizedStringFromTable(@"room_participants_action_unban", @"Vector", nil);
Expand Down Expand Up @@ -1047,7 +1069,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIn
if (indexPath.row < directChatsArray.count)
{
// Open this room
[[AppDelegate theDelegate] showRoom:directChatsArray[indexPath.row] andEventId:nil withMatrixSession:self.mainSession];
[self showRoomWithId:directChatsArray[indexPath.row]];
}
else
{
Expand Down
1 change: 1 addition & 0 deletions Riot/Modules/Room/Members/RoomParticipantsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
@property (nonatomic) BOOL enableMention;

@property (nonatomic) BOOL showCancelBarButtonItem;
@property (nonatomic) BOOL showParticipantCustomAccessoryView;

/**
The delegate for the view controller.
Expand Down
39 changes: 27 additions & 12 deletions Riot/Modules/Room/Members/RoomParticipantsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ - (void)finalizeInit
// Setup `MXKViewControllerHandling` properties
self.enableBarTintColorStatusChange = NO;
self.rageShakeManager = [RageShakeManager sharedManager];
self.showParticipantCustomAccessoryView = YES;
}

- (void)viewDidLoad
Expand Down Expand Up @@ -113,7 +114,11 @@ - (void)viewDidLoad

self.navigationItem.title = NSLocalizedStringFromTable(@"room_participants_title", @"Vector", nil);

if (self.mxRoom.isDirect)
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
_searchBarView.placeholder = NSLocalizedStringFromTable(@"search_default_placeholder", @"Vector", nil);
}
else if (self.mxRoom.isDirect)
{
_searchBarView.placeholder = NSLocalizedStringFromTable(@"room_participants_filter_room_members_for_dm", @"Vector", nil);
}
Expand Down Expand Up @@ -340,7 +345,11 @@ - (void)setMxRoom:(MXRoom *)mxRoom
{
self.searchBarHeader.hidden = NO;

if (self.mxRoom.isDirect)
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
self.searchBarView.placeholder = NSLocalizedStringFromTable(@"search_default_placeholder", @"Vector", nil);
}
else if (self.mxRoom.isDirect)
{
self.searchBarView.placeholder = NSLocalizedStringFromTable(@"room_participants_filter_room_members_for_dm", @"Vector", nil);
}
Expand Down Expand Up @@ -870,6 +879,19 @@ - (void)pushViewController:(UIViewController*)viewController
}
}

- (void)showDetailFor:(MXRoomMember* _Nonnull)member from:(UIView* _Nullable)sourceView {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceView parameter seems to be not used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not used here indeed but it's used by SpaceMemberListViewController that inherits from RoomParticipantsViewController

memberDetailsViewController = [RoomMemberDetailsViewController roomMemberDetailsViewController];

// Set delegate to handle action on member (start chat, mention)
memberDetailsViewController.delegate = self;
memberDetailsViewController.enableMention = _enableMention;
memberDetailsViewController.enableVoipCall = NO;

[memberDetailsViewController displayRoomMember:member withMatrixRoom:self.mxRoom];

[self pushViewController:memberDetailsViewController];
}

#pragma mark - UITableView data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
Expand Down Expand Up @@ -948,6 +970,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
{
ContactTableViewCell* participantCell = [tableView dequeueReusableCellWithIdentifier:@"ParticipantTableViewCellId" forIndexPath:indexPath];
participantCell.selectionStyle = UITableViewCellSelectionStyleNone;
participantCell.showCustomAccessoryView = self.showParticipantCustomAccessoryView;

participantCell.mxRoom = self.mxRoom;

Expand Down Expand Up @@ -1185,16 +1208,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

if (contact.mxMember)
{
memberDetailsViewController = [RoomMemberDetailsViewController roomMemberDetailsViewController];

// Set delegate to handle action on member (start chat, mention)
memberDetailsViewController.delegate = self;
memberDetailsViewController.enableMention = _enableMention;
memberDetailsViewController.enableVoipCall = NO;

[memberDetailsViewController displayRoomMember:contact.mxMember withMatrixRoom:self.mxRoom];

[self pushViewController:memberDetailsViewController];
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
[self showDetailFor:contact.mxMember from:selectedCell];
}

[tableView deselectRowAtIndexPath:indexPath animated:YES];
Expand Down
33 changes: 26 additions & 7 deletions Riot/Modules/SideMenu/SideMenuCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ final class SideMenuCoordinator: NSObject, SideMenuCoordinatorType {
let spaceMenuPresenter = SpaceMenuPresenter()

private var exploreRoomCoordinator: ExploreRoomCoordinator?
private var membersCoordinator: SpaceMembersCoordinator?

// MARK: Public

Expand Down Expand Up @@ -215,6 +216,18 @@ final class SideMenuCoordinator: NSObject, SideMenuCoordinatorType {

self.exploreRoomCoordinator = exploreRoomCoordinator
}

private func showMembers(spaceId: String, session: MXSession) {
let parameters = SpaceMembersCoordinatorParameters(userSessionsService: self.parameters.userSessionsService, session: session, spaceId: spaceId)
let spaceMembersCoordinator = SpaceMembersCoordinator(parameters: parameters)
spaceMembersCoordinator.delegate = self
let presentable = spaceMembersCoordinator.toPresentable()
presentable.presentationController?.delegate = self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it's fine to let it here I think it can be interesting to put presentable.presentationController?.delegate = self inside SpaceMembersCoordinator. We will add this to the file template. And add a delegate method for this case. It will centralise this edge case and avoid to forget it for other screens.

self.sideMenuViewController.present(presentable, animated: true, completion: nil)
spaceMembersCoordinator.start()

self.membersCoordinator = spaceMembersCoordinator
}

private func showInviteFriends(from sourceView: UIView?) {
let myUserId = self.parameters.userSessionsService.mainUserSession?.userId ?? ""
Expand Down Expand Up @@ -311,8 +324,7 @@ extension SideMenuCoordinator: SpaceMenuPresenterDelegate {
case .exploreRooms:
self.showExploreRooms(spaceId: spaceId, session: session)
case .exploreMembers:
// TODO present members list
break
self.showMembers(spaceId: spaceId, session: session)
}
}
}
Expand All @@ -327,13 +339,20 @@ extension SideMenuCoordinator: ExploreRoomCoordinatorDelegate {
}
}

// MARK: - SpaceMembersCoordinatorDelegate
extension SideMenuCoordinator: SpaceMembersCoordinatorDelegate {
func spaceMembersCoordinatorDidCancel(_ coordinator: SpaceMembersCoordinatorType) {
self.membersCoordinator?.toPresentable().dismiss(animated: true) {
self.membersCoordinator = nil
}
}
}

// MARK: - UIAdaptivePresentationControllerDelegate
extension SideMenuCoordinator: UIAdaptivePresentationControllerDelegate {

func exploreRoomCoordinatorDidComplete(_ presentationController: UIPresentationController) {
self.exploreRoomCoordinator?.toPresentable().dismiss(animated: true) {
self.exploreRoomCoordinator = nil
}
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
self.exploreRoomCoordinator = nil
self.membersCoordinator = nil
}

}
Loading