mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
[Spaces] M10.6 Space preview bottom sheet #4497
This commit is contained in:
@@ -41,6 +41,7 @@ final class SpaceListViewController: UIViewController {
|
||||
private var activityPresenter: ActivityIndicatorPresenter!
|
||||
|
||||
private var sections: [SpaceListSection] = []
|
||||
private var homeIndexPath: IndexPath = IndexPath(row: 0, section: 0)
|
||||
private var selectedIndexPath: IndexPath = IndexPath(row: 0, section: 0)
|
||||
|
||||
// MARK: - Setup
|
||||
@@ -103,6 +104,7 @@ final class SpaceListViewController: UIViewController {
|
||||
}
|
||||
|
||||
private func setupTableView() {
|
||||
self.selectedIndexPath = self.homeIndexPath
|
||||
self.tableView.separatorStyle = .none
|
||||
self.tableView.rowHeight = UITableView.automaticDimension
|
||||
self.tableView.estimatedRowHeight = Constants.estimatedRowHeight
|
||||
@@ -115,8 +117,8 @@ final class SpaceListViewController: UIViewController {
|
||||
switch viewState {
|
||||
case .loading:
|
||||
self.renderLoading()
|
||||
case .loaded(let sections):
|
||||
self.renderLoaded(sections: sections)
|
||||
case .loaded(let sections, let homeIndexPath):
|
||||
self.renderLoaded(sections: sections, homeIndexPath: homeIndexPath)
|
||||
case .error(let error):
|
||||
self.render(error: error)
|
||||
}
|
||||
@@ -129,10 +131,15 @@ final class SpaceListViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
private func renderLoaded(sections: [SpaceListSection]) {
|
||||
private func renderLoaded(sections: [SpaceListSection], homeIndexPath: IndexPath) {
|
||||
let isHomeSelected = self.selectedIndexPath.section == self.homeIndexPath.section
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
self.sections = sections
|
||||
self.tableView.reloadData()
|
||||
self.homeIndexPath = homeIndexPath
|
||||
if isHomeSelected {
|
||||
self.selectedIndexPath = self.homeIndexPath
|
||||
}
|
||||
self.tableView.selectRow(at: selectedIndexPath, animated: true, scrollPosition: .none)
|
||||
}
|
||||
|
||||
@@ -153,6 +160,10 @@ extension SpaceListViewController: SpaceListViewModelViewDelegate {
|
||||
self.selectedIndexPath = IndexPath(row: indexPath.row, section: indexPath.section)
|
||||
self.tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
|
||||
}
|
||||
|
||||
func spaceListViewModelRevertSelection(_ viewModel: SpaceListViewModelType) {
|
||||
self.tableView.selectRow(at: self.selectedIndexPath, animated: true, scrollPosition: .none)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
@@ -206,7 +217,7 @@ extension SpaceListViewController: UITableViewDelegate {
|
||||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
if selectedIndexPath != indexPath {
|
||||
self.viewModel.process(viewAction: .selectRow(at: indexPath))
|
||||
self.viewModel.process(viewAction: .selectRow(at: indexPath, from: tableView.cellForRow(at: indexPath)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user