Skip to content

Commit

Permalink
[Spaces] M10.8 Browsing users in a space #4682
Browse files Browse the repository at this point in the history
- Added navigation to member detail page
  • Loading branch information
gileluard committed Aug 22, 2021
1 parent 02c3d5f commit 91d9169
Show file tree
Hide file tree
Showing 24 changed files with 710 additions and 210 deletions.
2 changes: 2 additions & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,8 @@ Tap the + to start adding people.";
"spaces_no_member_found_detail" = "Looking for someone not in space name? 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
5 changes: 0 additions & 5 deletions Riot/Generated/Storyboards.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@ internal enum StoryboardScene {

internal static let initialScene = InitialSceneType<Riot.ShowSpaceExploreRoomViewController>(storyboard: ShowSpaceExploreRoomViewController.self)
}
internal enum ShowSpaceMemberListViewController: StoryboardType {
internal static let storyboardName = "ShowSpaceMemberListViewController"

internal static let initialScene = InitialSceneType<Riot.ShowSpaceMemberListViewController>(storyboard: ShowSpaceMemberListViewController.self)
}
internal enum SideMenuViewController: StoryboardType {
internal static let storyboardName = "SideMenuViewController"

Expand Down
8 changes: 8 additions & 0 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
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
37 changes: 25 additions & 12 deletions Riot/Modules/Room/Members/RoomParticipantsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,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 +344,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 +878,19 @@ - (void)pushViewController:(UIViewController*)viewController
}
}

- (void)showDetailFor:(MXRoomMember* _Nonnull)member from:(UIView* _Nullable)sourceView {
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 @@ -1185,16 +1206,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// File created from ScreenTemplate
// $ createScreen.sh Spaces/SpaceMembers/MemberDetail ShowSpaceMemberDetail
/*
Copyright 2021 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import Foundation
import UIKit

final class ShowSpaceMemberDetailCoordinator: NSObject, ShowSpaceMemberDetailCoordinatorType {

// MARK: - Properties

// MARK: Private

private let session: MXSession
private let member: MXRoomMember
private let spaceId: String

private var showSpaceMemberDetailViewModel: ShowSpaceMemberDetailViewModelType
private let showSpaceMemberDetailViewController: ShowSpaceMemberDetailViewController

// MARK: Public

// Must be used only internally
var childCoordinators: [Coordinator] = []

weak var delegate: ShowSpaceMemberDetailCoordinatorDelegate?

// MARK: - Setup

init(session: MXSession, member: MXRoomMember, spaceId: String) {
self.session = session
self.member = member
self.spaceId = spaceId

let showSpaceMemberDetailViewModel = ShowSpaceMemberDetailViewModel(session: self.session, member: self.member)
let showSpaceMemberDetailViewController = ShowSpaceMemberDetailViewController.instantiate(with: showSpaceMemberDetailViewModel)
showSpaceMemberDetailViewController.enableMention = true
showSpaceMemberDetailViewController.enableVoipCall = false
showSpaceMemberDetailViewController.enableLeave = false

self.showSpaceMemberDetailViewModel = showSpaceMemberDetailViewModel
self.showSpaceMemberDetailViewController = showSpaceMemberDetailViewController
}

// MARK: - Public methods

func start() {
self.showSpaceMemberDetailViewModel.coordinatorDelegate = self
if let space = self.session.spaceService.getSpace(withId: spaceId) {
// Set delegate to handle action on member (start chat, mention)
self.showSpaceMemberDetailViewController.delegate = self
self.showSpaceMemberDetailViewController.display(self.member, withMatrixRoom: space.room)
}
}

func toPresentable() -> UIViewController {
return self.showSpaceMemberDetailViewController
}
}

// MARK: - ShowSpaceMemberDetailViewModelCoordinatorDelegate
extension ShowSpaceMemberDetailCoordinator: ShowSpaceMemberDetailViewModelCoordinatorDelegate {

func showSpaceMemberDetailViewModel(_ viewModel: ShowSpaceMemberDetailViewModelType, showRoomWithId roomId: String) {
self.delegate?.showSpaceMemberDetailCoordinator(self, showRoomWithId: roomId)
}

func showSpaceMemberDetailViewModelDidCancel(_ viewModel: ShowSpaceMemberDetailViewModelType) {
self.delegate?.showSpaceMemberDetailCoordinatorDidCancel(self)
}

}

// MARK: - MXKRoomMemberDetailsViewControllerDelegate
extension ShowSpaceMemberDetailCoordinator: MXKRoomMemberDetailsViewControllerDelegate {

func roomMemberDetailsViewController(_ roomMemberDetailsViewController: MXKRoomMemberDetailsViewController!, startChatWithMemberId memberId: String!, completion: (() -> Void)!) {
completion()
self.showSpaceMemberDetailViewModel.process(viewAction: .createRoom(memberId))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// File created from ScreenTemplate
// $ createScreen.sh Spaces/SpaceMembers/MemberDetail ShowSpaceMemberDetail
/*
Copyright 2021 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import Foundation

protocol ShowSpaceMemberDetailCoordinatorDelegate: AnyObject {
func showSpaceMemberDetailCoordinator(_ coordinator: ShowSpaceMemberDetailCoordinatorType, showRoomWithId roomId: String)
func showSpaceMemberDetailCoordinatorDidCancel(_ coordinator: ShowSpaceMemberDetailCoordinatorType)
}

/// `ShowSpaceMemberDetailCoordinatorType` is a protocol describing a Coordinator that handle key backup setup passphrase navigation flow.
protocol ShowSpaceMemberDetailCoordinatorType: Coordinator, Presentable {
var delegate: ShowSpaceMemberDetailCoordinatorDelegate? { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// File created from ScreenTemplate
// $ createScreen.sh Spaces/SpaceMembers/MemberDetail ShowSpaceMemberDetail
/*
Copyright 2021 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import Foundation

/// ShowSpaceMemberDetailViewController view actions exposed to view model
enum ShowSpaceMemberDetailViewAction {
case openRoom(_ roomId: String)
case createRoom(_ memberId: String)
case cancel
}
Loading

0 comments on commit 91d9169

Please sign in to comment.