mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-04 23:17:43 +02:00
Display thread when row tapped
This commit is contained in:
@@ -26,6 +26,7 @@ final class ThreadsCoordinator: NSObject, ThreadsCoordinatorProtocol {
|
||||
// MARK: Private
|
||||
|
||||
private let parameters: ThreadsCoordinatorParameters
|
||||
private var selectedThreadCoordinator: RoomCoordinator?
|
||||
|
||||
private var navigationRouter: NavigationRouterType {
|
||||
return self.parameters.navigationRouter
|
||||
@@ -42,6 +43,11 @@ final class ThreadsCoordinator: NSObject, ThreadsCoordinatorProtocol {
|
||||
|
||||
init(parameters: ThreadsCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
super.init()
|
||||
NotificationCenter.default.addObserver(self,
|
||||
selector: #selector(didPopModule(_:)),
|
||||
name: NavigationRouter.didPopModule,
|
||||
object: nil)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -73,6 +79,21 @@ final class ThreadsCoordinator: NSObject, ThreadsCoordinatorProtocol {
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@objc
|
||||
private func didPopModule(_ notification: Notification) {
|
||||
guard let userInfo = notification.userInfo,
|
||||
let module = userInfo[NavigationRouter.NotificationUserInfoKey.module] as? Presentable,
|
||||
let selectedThreadCoordinator = selectedThreadCoordinator else {
|
||||
return
|
||||
}
|
||||
|
||||
if module.toPresentable() == selectedThreadCoordinator.toPresentable() {
|
||||
selectedThreadCoordinator.delegate = nil
|
||||
remove(childCoordinator: selectedThreadCoordinator)
|
||||
self.selectedThreadCoordinator = nil
|
||||
}
|
||||
}
|
||||
|
||||
private func createThreadListCoordinator() -> ThreadListCoordinator {
|
||||
let coordinatorParameters = ThreadListCoordinatorParameters(session: self.parameters.session,
|
||||
@@ -81,6 +102,19 @@ final class ThreadsCoordinator: NSObject, ThreadsCoordinatorProtocol {
|
||||
coordinator.delegate = self
|
||||
return coordinator
|
||||
}
|
||||
|
||||
private func createThreadCoordinator(forThread thread: MXThread) -> RoomCoordinator {
|
||||
let parameters = RoomCoordinatorParameters(navigationRouter: navigationRouter,
|
||||
navigationRouterStore: nil,
|
||||
session: parameters.session,
|
||||
roomId: parameters.roomId,
|
||||
eventId: nil,
|
||||
threadId: thread.identifier,
|
||||
displayConfiguration: .forThreads)
|
||||
let coordinator = RoomCoordinator(parameters: parameters)
|
||||
coordinator.delegate = self
|
||||
return coordinator
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UIAdaptivePresentationControllerDelegate
|
||||
@@ -97,7 +131,36 @@ extension ThreadsCoordinator: ThreadListCoordinatorDelegate {
|
||||
self.delegate?.threadsCoordinatorDidComplete(self)
|
||||
}
|
||||
|
||||
func threadListCoordinatorDidSelectThread(_ coordinator: ThreadListCoordinatorProtocol, thread: MXThread) {
|
||||
let roomCoordinator = createThreadCoordinator(forThread: thread)
|
||||
selectedThreadCoordinator = roomCoordinator
|
||||
roomCoordinator.start()
|
||||
self.add(childCoordinator: roomCoordinator)
|
||||
}
|
||||
|
||||
func threadListCoordinatorDidCancel(_ coordinator: ThreadListCoordinatorProtocol) {
|
||||
self.delegate?.threadsCoordinatorDidComplete(self)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - RoomCoordinatorDelegate
|
||||
|
||||
extension ThreadsCoordinator: RoomCoordinatorDelegate {
|
||||
|
||||
func roomCoordinatorDidLeaveRoom(_ coordinator: RoomCoordinatorProtocol) {
|
||||
|
||||
}
|
||||
|
||||
func roomCoordinatorDidCancelRoomPreview(_ coordinator: RoomCoordinatorProtocol) {
|
||||
|
||||
}
|
||||
|
||||
func roomCoordinator(_ coordinator: RoomCoordinatorProtocol, didSelectRoomWithId roomId: String, eventId: String?) {
|
||||
|
||||
}
|
||||
|
||||
func roomCoordinatorDidDismissInteractively(_ coordinator: RoomCoordinatorProtocol) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user