mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 17:42:45 +02:00
Display thread when row tapped
This commit is contained in:
@@ -65,6 +65,10 @@ extension ThreadListCoordinator: ThreadListViewModelCoordinatorDelegate {
|
||||
self.delegate?.threadListCoordinatorDidLoadThreads(self)
|
||||
}
|
||||
|
||||
func threadListViewModelDidSelectThread(_ viewModel: ThreadListViewModelProtocol, thread: MXThread) {
|
||||
self.delegate?.threadListCoordinatorDidSelectThread(self, thread: thread)
|
||||
}
|
||||
|
||||
func threadListViewModelDidCancel(_ viewModel: ThreadListViewModelProtocol) {
|
||||
self.delegate?.threadListCoordinatorDidCancel(self)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import Foundation
|
||||
|
||||
protocol ThreadListCoordinatorDelegate: AnyObject {
|
||||
func threadListCoordinatorDidLoadThreads(_ coordinator: ThreadListCoordinatorProtocol)
|
||||
func threadListCoordinatorDidSelectThread(_ coordinator: ThreadListCoordinatorProtocol, thread: MXThread)
|
||||
func threadListCoordinatorDidCancel(_ coordinator: ThreadListCoordinatorProtocol)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,9 @@ import Foundation
|
||||
/// ThreadListViewController view actions exposed to view model
|
||||
enum ThreadListViewAction {
|
||||
case loadData
|
||||
case complete
|
||||
case showFilterTypes
|
||||
case selectFilterType(_ type: ThreadListFilterType)
|
||||
case complete
|
||||
case selectThread(_ index: Int)
|
||||
case cancel
|
||||
}
|
||||
|
||||
@@ -114,7 +114,9 @@ final class ThreadListViewController: UIViewController {
|
||||
titleView.mode = .allThreads
|
||||
titleView.viewDelegate = self
|
||||
titleView.configure(withViewModel: viewModel.titleViewModel)
|
||||
navigationItem.titleView = titleView
|
||||
navigationItem.leftItemsSupplementBackButton = true
|
||||
navigationItem.backBarButtonItem = UIBarButtonItem(title: nil, style: .plain, target: nil, action: nil)
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: titleView)
|
||||
|
||||
self.threadsTableView.tableFooterView = UIView()
|
||||
self.threadsTableView.register(cellType: ThreadTableViewCell.self)
|
||||
@@ -231,6 +233,8 @@ extension ThreadListViewController: UITableViewDelegate {
|
||||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
|
||||
viewModel.process(viewAction: .selectThread(indexPath.row))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,13 +63,15 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
switch viewAction {
|
||||
case .loadData:
|
||||
loadData()
|
||||
case .complete:
|
||||
coordinatorDelegate?.threadListViewModelDidLoadThreads(self)
|
||||
case .showFilterTypes:
|
||||
viewState = .showingFilterTypes
|
||||
case .selectFilterType(let type):
|
||||
selectedFilterType = type
|
||||
loadData()
|
||||
case .complete:
|
||||
coordinatorDelegate?.threadListViewModelDidLoadThreads(self)
|
||||
case .selectThread(let index):
|
||||
selectThread(index)
|
||||
case .cancel:
|
||||
cancelOperations()
|
||||
coordinatorDelegate?.threadListViewModelDidCancel(self)
|
||||
@@ -226,6 +228,14 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func selectThread(_ index: Int) {
|
||||
guard index < threads.count else {
|
||||
return
|
||||
}
|
||||
let thread = threads[index]
|
||||
coordinatorDelegate?.threadListViewModelDidSelectThread(self, thread: thread)
|
||||
}
|
||||
|
||||
private func cancelOperations() {
|
||||
self.currentOperation?.cancel()
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ protocol ThreadListViewModelViewDelegate: AnyObject {
|
||||
|
||||
protocol ThreadListViewModelCoordinatorDelegate: AnyObject {
|
||||
func threadListViewModelDidLoadThreads(_ viewModel: ThreadListViewModelProtocol)
|
||||
func threadListViewModelDidSelectThread(_ viewModel: ThreadListViewModelProtocol, thread: MXThread)
|
||||
func threadListViewModelDidCancel(_ viewModel: ThreadListViewModelProtocol)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user