mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
Swift
55 lines
1.6 KiB
Swift
3 years ago
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||
|
|
||
|
import UIKit
|
||
|
import SignalUtilitiesKit
|
||
|
import SessionUtilitiesKit
|
||
|
import SessionMessagingKit
|
||
|
|
||
|
final class DateHeaderCell: MessageCell {
|
||
|
// MARK: - UI
|
||
|
|
||
|
private lazy var dateLabel: UILabel = {
|
||
|
let result: UILabel = UILabel()
|
||
|
result.font = .boldSystemFont(ofSize: Values.verySmallFontSize)
|
||
|
result.themeTextColor = .textPrimary
|
||
|
result.textAlignment = .center
|
||
|
|
||
|
return result
|
||
|
}()
|
||
|
|
||
|
// MARK: - Lifecycle
|
||
|
|
||
|
override func setUpViewHierarchy() {
|
||
|
super.setUpViewHierarchy()
|
||
|
|
||
|
contentView.addSubview(dateLabel)
|
||
|
|
||
|
dateLabel.pin(.top, to: .top, of: contentView, withInset: Values.mediumSpacing)
|
||
|
dateLabel.pin(.leading, to: .leading, of: contentView)
|
||
|
dateLabel.pin(.trailing, to: .trailing, of: contentView)
|
||
|
dateLabel.pin(.bottom, to: .bottom, of: contentView, withInset: -Values.smallSpacing)
|
||
|
}
|
||
|
|
||
|
// MARK: - Updating
|
||
|
|
||
|
override func prepareForReuse() {
|
||
|
super.prepareForReuse()
|
||
|
|
||
|
dateLabel.text = ""
|
||
|
}
|
||
|
|
||
|
override func update(
|
||
|
with cellViewModel: MessageViewModel,
|
||
|
mediaCache: NSCache<NSString, AnyObject>,
|
||
|
playbackInfo: ConversationViewModel.PlaybackInfo?,
|
||
|
showExpandedReactions: Bool,
|
||
|
lastSearchText: String?
|
||
|
) {
|
||
|
guard cellViewModel.cellType == .dateHeader else { return }
|
||
|
|
||
|
dateLabel.text = cellViewModel.dateForUI.formattedForDisplay
|
||
|
}
|
||
|
|
||
|
override func dynamicUpdate(with cellViewModel: MessageViewModel, playbackInfo: ConversationViewModel.PlaybackInfo?) {}
|
||
|
}
|