Merge branch 'ismail/5068_start_thread' into ismail/5068_design_tweaks

This commit is contained in:
ismailgulek
2022-01-26 14:27:25 +03:00
202 changed files with 3665 additions and 897 deletions
@@ -25,7 +25,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
@@ -184,7 +178,7 @@ final class ThreadListViewController: UIViewController {
}
}
private func renderEmptyView(withViewModel emptyViewModel: ThreadListEmptyViewModel) {
private func renderEmptyView(withViewModel emptyViewModel: ThreadListEmptyModel) {
self.activityPresenter.removeCurrentActivityIndicator(animated: true)
emptyView.configure(withViewModel: emptyViewModel)
threadsTableView.isHidden = true
@@ -92,14 +92,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
}
@@ -118,33 +118,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.threadsIcon.image,
title: VectorL10n.threadsEmptyTitle,
info: VectorL10n.threadsEmptyInfoAll,
tip: VectorL10n.threadsEmptyTip,
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
showAllThreadsButtonHidden: true)
return ThreadListEmptyModel(icon: Asset.Images.threadsIcon.image,
title: VectorL10n.threadsEmptyTitle,
info: VectorL10n.threadsEmptyInfoAll,
tip: VectorL10n.threadsEmptyTip,
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
showAllThreadsButtonHidden: true)
case .myThreads:
return ThreadListEmptyViewModel(icon: Asset.Images.threadsIcon.image,
title: VectorL10n.threadsEmptyTitle,
info: VectorL10n.threadsEmptyInfoMy,
tip: nil,
showAllThreadsButtonTitle: VectorL10n.threadsEmptyShowAllThreads,
showAllThreadsButtonHidden: false)
return ThreadListEmptyModel(icon: Asset.Images.threadsIcon.image,
title: VectorL10n.threadsEmptyTitle,
info: VectorL10n.threadsEmptyInfoMy,
tip: nil,
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?
@@ -184,17 +184,17 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
lastMessageSender = nil
}
let summaryViewModel = ThreadSummaryViewModel(numberOfReplies: thread.numberOfReplies,
lastMessageSenderAvatar: lastAvatarViewData,
lastMessageText: lastMessageText)
return ThreadViewModel(rootMessageSenderUserId: rootMessageSender?.userId,
rootMessageSenderAvatar: rootAvatarViewData,
rootMessageSenderDisplayName: rootMessageSender?.displayname,
rootMessageText: rootMessageText,
rootMessageRedacted: thread.rootMessage?.isRedactedEvent() ?? false,
lastMessageTime: lastMessageTime,
summaryViewModel: summaryViewModel)
let summaryViewModel = ThreadSummaryModel(numberOfReplies: thread.numberOfReplies,
lastMessageSenderAvatar: lastAvatarViewData,
lastMessageText: lastMessageText)
return ThreadModel(rootMessageSenderUserId: rootMessageSender?.userId,
rootMessageSenderAvatar: rootAvatarViewData,
rootMessageSenderDisplayName: rootMessageSender?.displayname,
rootMessageText: rootMessageText,
rootMessageRedacted: thread.rootMessage?.isRedactedEvent() ?? false,
lastMessageTime: lastMessageTime,
summaryViewModel: summaryViewModel)
}
private func rootMessageText(forThread thread: MXThread) -> NSAttributedString? {
@@ -39,10 +39,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 showingLongPressActions
case share(_ string: String)
@@ -16,12 +16,12 @@
import Foundation
struct ThreadViewModel {
struct ThreadModel {
var rootMessageSenderUserId: String?
var rootMessageSenderAvatar: AvatarViewDataProtocol?
var rootMessageSenderDisplayName: String?
var rootMessageText: NSAttributedString?
var rootMessageRedacted: Bool
var lastMessageTime: String?
var summaryViewModel: ThreadSummaryViewModel?
var summaryViewModel: ThreadSummaryModel?
}
@@ -50,7 +50,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 {
@@ -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