mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
Merge pull request #498 from MessageKit/enhancement/data-custom
Add .custom(Any) case to MessageData
This commit is contained in:
+22
-19
@@ -8,27 +8,30 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
|
||||
|
||||
### Added
|
||||
|
||||
Adds the following methods to `MessagesCollectionViewFlowLayout`:
|
||||
- `messageLabelInsets(for message: MessageType, at indexPath: IndexPath) -> UIEdgeInsets`
|
||||
- `messageContainerPadding(for message: MessageType, at indexPath: IndexPath) -> UIEdgeInsets`
|
||||
- `messageContainerMaxWidth(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
- `messageContainerSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellTopLabelAlignment(for message: MessageType, at indexPath: IndexPath) -> LabelAlignment`
|
||||
- `cellTopLabelSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellTopLabelMaxWidth(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
- `cellBottomLabelAlignment(for message: MessageType, at indexPath: IndexPath) -> LabelAlignment`
|
||||
- `cellBottomLabelSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellBottomLabelMaxWidth(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
- `avatarPosition(for message: MessageType, at indexPath: IndexPath) -> AvatarPosition`
|
||||
- `avatarSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellContentHeight(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
- **Breaking Change** Adds `.custom(Any?)` case to `MessageData`.
|
||||
[#498](https://github.com/MessageKit/MessageKit/pull/498) by [@SD10](https://github.com/SD10).
|
||||
|
||||
- Adds the following methods to `MessagesCollectionViewFlowLayout`:
|
||||
- `messageLabelInsets(for message: MessageType, at indexPath: IndexPath) -> UIEdgeInsets`
|
||||
- `messageContainerPadding(for message: MessageType, at indexPath: IndexPath) -> UIEdgeInsets`
|
||||
- `messageContainerMaxWidth(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
- `messageContainerSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellTopLabelAlignment(for message: MessageType, at indexPath: IndexPath) -> LabelAlignment`
|
||||
- `cellTopLabelSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellTopLabelMaxWidth(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
- `cellBottomLabelAlignment(for message: MessageType, at indexPath: IndexPath) -> LabelAlignment`
|
||||
- `cellBottomLabelSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellBottomLabelMaxWidth(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
- `avatarPosition(for message: MessageType, at indexPath: IndexPath) -> AvatarPosition`
|
||||
- `avatarSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
- `cellContentHeight(for message: MessageType, at indexPath: IndexPath) -> CGFloat`
|
||||
[#491](https://github.com/MessageKit/MessageKit/pull/491) by [@SD10](https://github.com/SD10).
|
||||
|
||||
Adds the following methods to `MessageCollectionViewCell`:
|
||||
- `layoutAvatarView(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
- `layoutMessageContainerView(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
- `layoutTopLabel(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
- `layoutBottomLabel(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
- Adds the following methods to `MessageCollectionViewCell`:
|
||||
- `layoutAvatarView(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
- `layoutMessageContainerView(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
- `layoutTopLabel(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
- `layoutBottomLabel(with attributes: MessagesCollectionViewLayoutAttributes)`
|
||||
[#491](https://github.com/MessageKit/MessageKit/pull/491) by [@SD10](https://github.com/SD10).
|
||||
|
||||
### [[Prerelease] 0.13.1](https://github.com/MessageKit/MessageKit/releases/tag/0.13.1)
|
||||
|
||||
@@ -68,6 +68,8 @@ extension MessagesViewController: UICollectionViewDataSource {
|
||||
let cell = messagesCollectionView.dequeueReusableCell(LocationMessageCell.self, for: indexPath)
|
||||
cell.configure(with: message, at: indexPath, and: messagesCollectionView)
|
||||
return cell
|
||||
case .custom:
|
||||
fatalError(MessageKitError.customDataUnresolvedCell)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,8 @@ extension MessagesCollectionViewFlowLayout {
|
||||
let width = messagesLayoutDelegate.widthForLocation(message: message, at: indexPath, with: maxWidth, in: messagesCollectionView)
|
||||
let height = messagesLayoutDelegate.heightForLocation(message: message, at: indexPath, with: maxWidth, in: messagesCollectionView)
|
||||
messageContainerSize = CGSize(width: width, height: height)
|
||||
case .custom:
|
||||
fatalError(MessageKitError.customDataUnresolvedSize)
|
||||
}
|
||||
|
||||
return messageContainerSize
|
||||
|
||||
@@ -30,10 +30,10 @@ public enum MessageData {
|
||||
|
||||
/// A standard text message.
|
||||
///
|
||||
/// NOTE: The font used for this message will be the value of the
|
||||
/// - Note: The font used for this message will be the value of the
|
||||
/// `messageLabelFont` property in the `MessagesCollectionViewFlowLayout` object.
|
||||
///
|
||||
/// Tip: Using `MessageData.attributedText(NSAttributedString)` doesn't require you
|
||||
/// Using `MessageData.attributedText(NSAttributedString)` doesn't require you
|
||||
/// to set this property and results in higher performance.
|
||||
case text(String)
|
||||
|
||||
@@ -52,14 +52,18 @@ public enum MessageData {
|
||||
/// An emoji message.
|
||||
case emoji(String)
|
||||
|
||||
/// A custom message.
|
||||
/// - Note: Using this case requires that you override the following methods and handle this case:
|
||||
/// - `collectionView(_:cellForItemAt indexPath: IndexPath) -> UICollectionViewCell`
|
||||
/// - `messageContainerSize(for message: MessageType, at indexPath: IndexPath) -> CGSize`
|
||||
case custom(Any?)
|
||||
|
||||
// MARK: - Not supported yet
|
||||
|
||||
// case audio(Data)
|
||||
//
|
||||
// case system(String)
|
||||
//
|
||||
// case custom(Any)
|
||||
//
|
||||
// case placeholder
|
||||
|
||||
}
|
||||
|
||||
@@ -33,4 +33,6 @@ enum MessageKitError {
|
||||
static let unrecognizedCheckingResult = "Received an unrecognized NSTextCheckingResult.CheckingType"
|
||||
static let couldNotLoadAssetsBundle = "MessageKit: Could not load the assets bundle"
|
||||
static let couldNotCreateAssetsPath = "MessageKit: Could not create path to the assets bundle."
|
||||
static let customDataUnresolvedCell = "Did not return a cell for MessageData.custom(Any)."
|
||||
static let customDataUnresolvedSize = "Did not return a size for MessageData.custom(Any)."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user