Files
2022-06-03 16:55:25 +03:00

54 lines
1.7 KiB
Swift

//
// + MessagesLayoutDelegate.swift
// Wallet
//
// Created by Saveliy Stavitsky on 2/9/21.
// Copyright © 2021 AM. All rights reserved.
//
import MessageKit
import Foundation
import UIKit
extension CryptoChatControllerChat: MessagesLayoutDelegate {
func messageBottomLabelHeight(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGFloat {
16
}
func cellTopLabelHeight(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGFloat {
if indexPath.section == 0 && loadedMsgsCount == messages.count {
return 32
}
// get previous message
let previousIndexPath = IndexPath(row: 0, section: indexPath.section - 1)
let previousMessage = messageForItem(at: previousIndexPath, in: messagesCollectionView)
if Calendar.current.isDate(message.sentDate, inSameDayAs: previousMessage.sentDate) {
return .zero
}
return 32
}
func cellBottomLabelHeight(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGFloat {
if unreadCount != 0 && loadedMsgsCount - indexPath.section - 1 == unreadCount {
return 32
}
return .zero
}
func headerViewSize(for section: Int, in messagesCollectionView: MessagesCollectionView) -> CGSize {
if section == 0 && loadedMsgsCount == messages.count {
return CGSize(width: messagesCollectionView.bounds.width,
height: 52 + 12 + infoView.frame.height + 12)
} else {
return .zero
}
}
}