metatext-app-ios-iphone-ipad/Extensions/CollectionItem+Extensions.s...

65 lines
2.2 KiB
Swift
Raw Normal View History

2020-09-23 03:00:56 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
2020-10-30 08:11:24 +01:00
import UIKit
2020-09-23 03:00:56 +02:00
import ViewModels
2020-10-15 09:44:01 +02:00
extension CollectionItem {
2020-10-30 08:11:24 +01:00
static let cellClasses = [
StatusListCell.self,
AccountListCell.self,
LoadMoreCell.self,
2020-10-29 07:03:45 +01:00
NotificationListCell.self,
2021-01-24 04:12:30 +01:00
ConversationListCell.self,
2021-01-25 08:42:39 +01:00
TagTableViewCell.self,
UITableViewCell.self]
2020-10-15 09:44:01 +02:00
2020-09-23 03:00:56 +02:00
var cellClass: AnyClass {
switch self {
case .status:
return StatusListCell.self
case .account:
return AccountListCell.self
case .loadMore:
return LoadMoreCell.self
2020-10-30 08:11:24 +01:00
case let .notification(_, statusConfiguration):
return statusConfiguration == nil ? NotificationListCell.self : StatusListCell.self
2020-10-29 07:03:45 +01:00
case .conversation:
return ConversationListCell.self
2021-01-24 04:12:30 +01:00
case .tag:
return TagTableViewCell.self
2021-01-25 08:42:39 +01:00
case .moreResults:
return UITableViewCell.self
2020-09-23 03:00:56 +02:00
}
}
2021-01-19 01:46:38 +01:00
2021-01-26 01:06:35 +01:00
func estimatedHeight(width: CGFloat, identityContext: IdentityContext) -> CGFloat {
2021-01-19 01:46:38 +01:00
switch self {
case let .status(status, configuration):
return StatusView.estimatedHeight(
width: width,
2021-01-26 01:06:35 +01:00
identityContext: identityContext,
2021-01-19 01:46:38 +01:00
status: status,
configuration: configuration)
2021-01-26 07:57:44 +01:00
case let .account(account, configuration):
return AccountView.estimatedHeight(width: width, account: account, configuration: configuration)
2021-01-20 03:47:21 +01:00
case .loadMore:
return LoadMoreView.estimatedHeight
case let .notification(notification, configuration):
return NotificationView.estimatedHeight(
width: width,
2021-01-26 01:06:35 +01:00
identityContext: identityContext,
2021-01-20 03:47:21 +01:00
notification: notification,
configuration: configuration)
case let .conversation(conversation):
return ConversationView.estimatedHeight(
width: width,
2021-01-26 01:06:35 +01:00
identityContext: identityContext,
2021-01-20 03:47:21 +01:00
conversation: conversation)
2021-01-24 04:12:30 +01:00
case let .tag(tag):
return TagView.estimatedHeight(width: width, tag: tag)
2021-01-25 08:42:39 +01:00
case .moreResults:
return UITableView.automaticDimension
2021-01-19 01:46:38 +01:00
}
}
2020-09-23 03:00:56 +02:00
}