Skip to content
Snippets Groups Projects
Commit a5d4b680 authored by Bruno Muniz's avatar Bruno Muniz
Browse files

Tapping on a contact goes straight to chat

parent 0a08072d
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,7 @@ public final class ContactListController: UIViewController {
private func setupBindings() {
tableController.didTap
.receive(on: DispatchQueue.main)
.sink { [unowned self] in coordinator.toContact($0, from: self) }
.sink { [unowned self] in coordinator.toSingleChat(with: $0, from: self) }
.store(in: &cancellables)
screenView.requestsButton
......
......@@ -84,7 +84,7 @@ final class ContactListTableController: UITableViewController {
}
override func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
tapRelay.send(contacts[indexPath.row])
tapRelay.send(sections[indexPath.section].items[indexPath.row])
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
......
......@@ -11,12 +11,9 @@ public protocol ContactListCoordinating {
func toSearch(from: UIViewController)
func toRequests(from: UIViewController)
func toNewGroup(from: UIViewController)
func toContact(_: Contact, from: UIViewController)
func toGroupChat(
with: GroupChatInfo,
from: UIViewController
)
func toSingleChat(with: Contact, from: UIViewController)
func toGroupChat(with: GroupChatInfo, from: UIViewController)
func toGroupPopup(
with: Int,
......@@ -52,8 +49,8 @@ public struct ContactListCoordinator: ContactListCoordinating {
var newGroupFactory: () -> UIViewController
var requestsFactory: () -> UIViewController
var contactFactory: (Contact) -> UIViewController
= ContactController.init(_:)
var singleChatFactory: (Contact) -> UIViewController
= SingleChatController.init(_:)
var groupChatFactory: (GroupChatInfo) -> UIViewController
= GroupChatController.init(_:)
......@@ -63,6 +60,14 @@ public struct ContactListCoordinator: ContactListCoordinating {
}
public extension ContactListCoordinator {
func toSingleChat(
with contact: Contact,
from parent: UIViewController
) {
let screen = singleChatFactory(contact)
replacer.present(screen, from: parent)
}
func toRequests(from parent: UIViewController) {
let screen = requestsFactory()
pusher.present(screen, from: parent)
......@@ -78,11 +83,6 @@ public extension ContactListCoordinator {
pusher.present(screen, from: parent)
}
func toContact(_ contact: Contact, from parent: UIViewController) {
let screen = contactFactory(contact)
pusher.present(screen, from: parent)
}
func toNewGroup(from parent: UIViewController) {
let screen = newGroupFactory()
pusher.present(screen, from: parent)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment