diff --git a/Riot/Modules/SideMenu/SideMenuCoordinator.swift b/Riot/Modules/SideMenu/SideMenuCoordinator.swift index 36857a3ae..d4f350c9a 100644 --- a/Riot/Modules/SideMenu/SideMenuCoordinator.swift +++ b/Riot/Modules/SideMenu/SideMenuCoordinator.swift @@ -243,14 +243,6 @@ final class SideMenuCoordinator: NSObject, SideMenuCoordinatorType { self.spaceMenuPresenter.present(forSpaceWithId: spaceId, from: self.sideMenuViewController, sourceView: sourceView, session: session, animated: true) } - func navigate(to item: SpaceExploreRoomListItemViewData, from sourceView: UIView?) { - if item.childInfo.roomType == .space { - self.exploreRoomCoordinator?.pushSpace(with: item) - } else if item.childInfo.roomType == .room { - self.exploreRoomCoordinator?.presentRoom(with: item, from: sourceView) - } - } - func navigate(to member: MXRoomMember, from sourceView: UIView?) { self.membersCoordinator?.presentMemberDetail(with: member, from: sourceView) } @@ -343,14 +335,10 @@ extension SideMenuCoordinator: SpaceMenuPresenterDelegate { // MARK: - ExploreRoomCoordinatorDelegate extension SideMenuCoordinator: ExploreRoomCoordinatorDelegate { - func exploreRoomCoordinatorDidComplete(_ coordinator: ExploreRoomCoordinatorType, withSelectedIem item: SpaceExploreRoomListItemViewData?, from sourceView: UIView?) { - guard let item = item else { - self.exploreRoomCoordinator?.toPresentable().dismiss(animated: true) { - self.exploreRoomCoordinator = nil - } - return + func exploreRoomCoordinatorDidComplete(_ coordinator: ExploreRoomCoordinatorType) { + self.exploreRoomCoordinator?.toPresentable().dismiss(animated: true) { + self.exploreRoomCoordinator = nil } - self.navigate(to: item, from: sourceView) } } diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift index dda85c53a..e90ea7160 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift @@ -66,7 +66,9 @@ final class ExploreRoomCoordinator: ExploreRoomCoordinatorType { return self.navigationRouter.toPresentable() } - func pushSpace(with item: SpaceExploreRoomListItemViewData) { + // MARK: - Private methods + + private func pushSpace(with item: SpaceExploreRoomListItemViewData) { let coordinator = self.createShowSpaceExploreRoomCoordinator(session: self.session, spaceId: item.childInfo.childRoomId, spaceName: item.childInfo.name) coordinator.start() self.add(childCoordinator: coordinator) @@ -75,7 +77,7 @@ final class ExploreRoomCoordinator: ExploreRoomCoordinatorType { } } - func presentRoom(with item: SpaceExploreRoomListItemViewData, from sourceView: UIView?) { + private func presentRoom(with item: SpaceExploreRoomListItemViewData, from sourceView: UIView?) { if let currentCoordinator = self.roomDetailCoordinator { self.remove(childCoordinator: currentCoordinator) } @@ -89,9 +91,7 @@ final class ExploreRoomCoordinator: ExploreRoomCoordinatorType { self.showRoomPreview(with: item, from: sourceView) } } - - // MARK: - Private methods - + private func showRoomPreview(with item: SpaceExploreRoomListItemViewData, from sourceView: UIView?) { let coordinator = self.createShowSpaceRoomDetailCoordinator(session: self.session, childInfo: item.childInfo) coordinator.start() @@ -144,11 +144,15 @@ final class ExploreRoomCoordinator: ExploreRoomCoordinatorType { // MARK: - ShowSpaceExploreRoomCoordinatorDelegate extension ExploreRoomCoordinator: SpaceExploreRoomCoordinatorDelegate { func spaceExploreRoomCoordinator(_ coordinator: SpaceExploreRoomCoordinatorType, didSelect item: SpaceExploreRoomListItemViewData, from sourceView: UIView?) { - self.delegate?.exploreRoomCoordinatorDidComplete(self, withSelectedIem: item, from: sourceView) + if item.childInfo.roomType == .space { + self.pushSpace(with: item) + } else if item.childInfo.roomType == .room { + self.presentRoom(with: item, from: sourceView) + } } - + func spaceExploreRoomCoordinatorDidCancel(_ coordinator: SpaceExploreRoomCoordinatorType) { - self.delegate?.exploreRoomCoordinatorDidComplete(self, withSelectedIem: nil, from: nil) + self.delegate?.exploreRoomCoordinatorDidComplete(self) } } diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift index 1bcf31aff..824801fb4 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorBridgePresenter.swift @@ -78,26 +78,12 @@ final class ExploreRoomCoordinatorBridgePresenter: NSObject { } } } - - // MARK: - Private - - func navigate(to item: SpaceExploreRoomListItemViewData, from sourceView: UIView?) { - if item.childInfo.roomType == .space { - self.coordinator?.pushSpace(with: item) - } else if item.childInfo.roomType == .room { - self.coordinator?.presentRoom(with: item, from: sourceView) - } - } } // MARK: - ExploreRoomCoordinatorDelegate extension ExploreRoomCoordinatorBridgePresenter: ExploreRoomCoordinatorDelegate { - func exploreRoomCoordinatorDidComplete(_ coordinator: ExploreRoomCoordinatorType, withSelectedIem item: SpaceExploreRoomListItemViewData?, from sourceView: UIView?) { - guard let item = item else { - self.delegate?.exploreRoomCoordinatorBridgePresenterDelegateDidComplete(self) - return - } - self.navigate(to: item, from: sourceView) + func exploreRoomCoordinatorDidComplete(_ coordinator: ExploreRoomCoordinatorType) { + self.delegate?.exploreRoomCoordinatorBridgePresenterDelegateDidComplete(self) } } diff --git a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorType.swift b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorType.swift index 5d806d080..20bf8c2f1 100644 --- a/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorType.swift +++ b/Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinatorType.swift @@ -19,7 +19,7 @@ import Foundation protocol ExploreRoomCoordinatorDelegate: AnyObject { - func exploreRoomCoordinatorDidComplete(_ coordinator: ExploreRoomCoordinatorType, withSelectedIem item: SpaceExploreRoomListItemViewData?, from sourceView: UIView?) + func exploreRoomCoordinatorDidComplete(_ coordinator: ExploreRoomCoordinatorType) } /// `ExploreRoomCoordinatorType` is a protocol describing a Coordinator that handle keybackup setup navigation flow.