mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Fix review remarks
This commit is contained in:
@@ -24,7 +24,7 @@ protocol ThreadListCoordinatorDelegate: AnyObject {
|
||||
func threadListCoordinatorDidCancel(_ coordinator: ThreadListCoordinatorProtocol)
|
||||
}
|
||||
|
||||
/// `ThreadListCoordinatorProtocol` is a protocol describing a Coordinator that handle xxxxxxx navigation flow.
|
||||
/// `ThreadListCoordinatorProtocol` is a protocol describing a Coordinator that handle thread list navigation flow.
|
||||
protocol ThreadListCoordinatorProtocol: Coordinator, Presentable {
|
||||
var delegate: ThreadListCoordinatorDelegate? { get }
|
||||
}
|
||||
|
||||
@@ -20,12 +20,6 @@ import UIKit
|
||||
|
||||
final class ThreadListViewController: UIViewController {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private enum Constants {
|
||||
static let aConstant: Int = 666
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Outlets
|
||||
@@ -172,7 +166,7 @@ final class ThreadListViewController: UIViewController {
|
||||
navigationItem.rightBarButtonItem?.isEnabled = true
|
||||
}
|
||||
|
||||
private func renderEmptyView(withViewModel emptyViewModel: ThreadListEmptyViewModel) {
|
||||
private func renderEmptyView(withViewModel emptyViewModel: ThreadListEmptyModel) {
|
||||
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
|
||||
emptyView.configure(withViewModel: emptyViewModel)
|
||||
threadsTableView.isHidden = true
|
||||
|
||||
@@ -83,14 +83,14 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
return threads.count
|
||||
}
|
||||
|
||||
func threadViewModel(at index: Int) -> ThreadViewModel? {
|
||||
func threadViewModel(at index: Int) -> ThreadModel? {
|
||||
guard index < threads.count else {
|
||||
return nil
|
||||
}
|
||||
return viewModel(forThread: threads[index])
|
||||
}
|
||||
|
||||
var titleViewModel: ThreadRoomTitleViewModel {
|
||||
var titleViewModel: ThreadRoomTitleModel {
|
||||
guard let room = session.room(withRoomId: roomId) else {
|
||||
return .empty
|
||||
}
|
||||
@@ -109,33 +109,33 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
encrpytionBadge = nil
|
||||
}
|
||||
|
||||
return ThreadRoomTitleViewModel(roomAvatar: avatarViewData,
|
||||
roomEncryptionBadge: encrpytionBadge,
|
||||
roomDisplayName: room.displayName)
|
||||
return ThreadRoomTitleModel(roomAvatar: avatarViewData,
|
||||
roomEncryptionBadge: encrpytionBadge,
|
||||
roomDisplayName: room.displayName)
|
||||
}
|
||||
|
||||
private var emptyViewModel: ThreadListEmptyViewModel {
|
||||
private var emptyViewModel: ThreadListEmptyModel {
|
||||
switch selectedFilterType {
|
||||
case .all:
|
||||
return ThreadListEmptyViewModel(icon: Asset.Images.roomContextMenuReplyInThread.image,
|
||||
title: VectorL10n.threadsEmptyTitle,
|
||||
info: VectorL10n.threadsEmptyInfoAll,
|
||||
tip: VectorL10n.threadsEmptyTip,
|
||||
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
|
||||
showAllThreadsButtonHidden: true)
|
||||
return ThreadListEmptyModel(icon: Asset.Images.roomContextMenuReplyInThread.image,
|
||||
title: VectorL10n.threadsEmptyTitle,
|
||||
info: VectorL10n.threadsEmptyInfoAll,
|
||||
tip: VectorL10n.threadsEmptyTip,
|
||||
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
|
||||
showAllThreadsButtonHidden: true)
|
||||
case .myThreads:
|
||||
return ThreadListEmptyViewModel(icon: Asset.Images.roomContextMenuReplyInThread.image,
|
||||
title: VectorL10n.threadsEmptyTitle,
|
||||
info: VectorL10n.threadsEmptyInfoMy,
|
||||
tip: VectorL10n.threadsEmptyTip,
|
||||
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
|
||||
showAllThreadsButtonHidden: false)
|
||||
return ThreadListEmptyModel(icon: Asset.Images.roomContextMenuReplyInThread.image,
|
||||
title: VectorL10n.threadsEmptyTitle,
|
||||
info: VectorL10n.threadsEmptyInfoMy,
|
||||
tip: VectorL10n.threadsEmptyTip,
|
||||
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
|
||||
showAllThreadsButtonHidden: false)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func viewModel(forThread thread: MXThread) -> ThreadViewModel {
|
||||
private func viewModel(forThread thread: MXThread) -> ThreadModel {
|
||||
let rootAvatarViewData: AvatarViewData?
|
||||
let rootMessageSender: MXUser?
|
||||
let lastAvatarViewData: AvatarViewData?
|
||||
@@ -175,15 +175,15 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
||||
lastMessageSender = nil
|
||||
}
|
||||
|
||||
let summaryViewModel = ThreadSummaryViewModel(numberOfReplies: thread.numberOfReplies,
|
||||
lastMessageSenderAvatar: lastAvatarViewData,
|
||||
lastMessageText: lastMessageText)
|
||||
let summaryViewModel = ThreadSummaryModel(numberOfReplies: thread.numberOfReplies,
|
||||
lastMessageSenderAvatar: lastAvatarViewData,
|
||||
lastMessageText: lastMessageText)
|
||||
|
||||
return ThreadViewModel(rootMessageSenderAvatar: rootAvatarViewData,
|
||||
rootMessageSenderDisplayName: rootMessageSender?.displayname,
|
||||
rootMessageText: rootMessageText,
|
||||
lastMessageTime: lastMessageTime,
|
||||
summaryViewModel: summaryViewModel)
|
||||
return ThreadModel(rootMessageSenderAvatar: rootAvatarViewData,
|
||||
rootMessageSenderDisplayName: rootMessageSender?.displayname,
|
||||
rootMessageText: rootMessageText,
|
||||
lastMessageTime: lastMessageTime,
|
||||
summaryViewModel: summaryViewModel)
|
||||
}
|
||||
|
||||
private func rootMessageText(forThread thread: MXThread) -> String? {
|
||||
|
||||
@@ -38,10 +38,10 @@ protocol ThreadListViewModelProtocol {
|
||||
|
||||
var viewState: ThreadListViewState { get }
|
||||
|
||||
var titleViewModel: ThreadRoomTitleViewModel { get }
|
||||
var titleViewModel: ThreadRoomTitleModel { get }
|
||||
var selectedFilterType: ThreadListFilterType { get }
|
||||
var numberOfThreads: Int { get }
|
||||
func threadViewModel(at index: Int) -> ThreadViewModel?
|
||||
func threadViewModel(at index: Int) -> ThreadModel?
|
||||
}
|
||||
|
||||
enum ThreadListFilterType {
|
||||
|
||||
@@ -23,7 +23,7 @@ enum ThreadListViewState {
|
||||
case idle
|
||||
case loading
|
||||
case loaded
|
||||
case empty(_ viewModel: ThreadListEmptyViewModel)
|
||||
case empty(_ viewModel: ThreadListEmptyModel)
|
||||
case showingFilterTypes
|
||||
case error(Error)
|
||||
}
|
||||
|
||||
+6
-6
@@ -16,10 +16,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct ThreadViewModel {
|
||||
var rootMessageSenderAvatar: AvatarViewDataProtocol?
|
||||
var rootMessageSenderDisplayName: String?
|
||||
var rootMessageText: String?
|
||||
var lastMessageTime: String?
|
||||
var summaryViewModel: ThreadSummaryViewModel?
|
||||
struct ThreadModel {
|
||||
let rootMessageSenderAvatar: AvatarViewDataProtocol?
|
||||
let rootMessageSenderDisplayName: String?
|
||||
let rootMessageText: String?
|
||||
let lastMessageTime: String?
|
||||
let summaryViewModel: ThreadSummaryModel?
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class ThreadTableViewCell: UITableViewCell {
|
||||
separatorInset = Constants.separatorInset
|
||||
}
|
||||
|
||||
func configure(withViewModel viewModel: ThreadViewModel) {
|
||||
func configure(withViewModel viewModel: ThreadModel) {
|
||||
if let rootAvatar = viewModel.rootMessageSenderAvatar {
|
||||
rootMessageAvatarView.fill(with: rootAvatar)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct ThreadListEmptyViewModel {
|
||||
struct ThreadListEmptyModel {
|
||||
let icon: UIImage?
|
||||
let title: String?
|
||||
let info: String?
|
||||
@@ -22,6 +22,7 @@ protocol ThreadListEmptyViewDelegate: AnyObject {
|
||||
func threadListEmptyViewTappedShowAllThreads(_ emptyView: ThreadListEmptyView)
|
||||
}
|
||||
|
||||
/// View to be shown on the thread list screen when no thread is available. Use a `ThreadListEmptyModel` instance to configure.
|
||||
class ThreadListEmptyView: UIView {
|
||||
|
||||
@IBOutlet weak var delegate: ThreadListEmptyViewDelegate?
|
||||
@@ -38,7 +39,7 @@ class ThreadListEmptyView: UIView {
|
||||
loadNibContent()
|
||||
}
|
||||
|
||||
func configure(withViewModel viewModel: ThreadListEmptyViewModel) {
|
||||
func configure(withViewModel viewModel: ThreadListEmptyModel) {
|
||||
iconView.image = viewModel.icon
|
||||
titleLabel.text = viewModel.title
|
||||
infoLabel.text = viewModel.info
|
||||
|
||||
Reference in New Issue
Block a user