@@ -33,23 +33,23 @@ open class MessagesCollectionViewFlowLayout: UICollectionViewFlowLayout {
3333 return MessagesCollectionViewLayoutAttributes . self
3434 }
3535
36- /** The `MessagesCollectionView` that owns this layout object. */
36+ /// The `MessagesCollectionView` that owns this layout object.
3737 public var messagesCollectionView : MessagesCollectionView {
3838 guard let messagesCollectionView = collectionView as? MessagesCollectionView else {
3939 fatalError ( MessageKitError . layoutUsedOnForeignType)
4040 }
4141 return messagesCollectionView
4242 }
4343
44- /** The `MessagesDataSource` for the layout's collection view. */
44+ /// The `MessagesDataSource` for the layout's collection view.
4545 public var messagesDataSource : MessagesDataSource {
4646 guard let messagesDataSource = messagesCollectionView. messagesDataSource else {
4747 fatalError ( MessageKitError . nilMessagesDataSource)
4848 }
4949 return messagesDataSource
5050 }
5151
52- /** The `MessagesLayoutDelegate` for the layout's collection view. */
52+ /// The `MessagesLayoutDelegate` for the layout's collection view.
5353 public var messagesLayoutDelegate : MessagesLayoutDelegate {
5454 guard let messagesLayoutDelegate = messagesCollectionView. messagesLayoutDelegate else {
5555 fatalError ( MessageKitError . nilMessagesLayoutDelegate)
@@ -155,4 +155,70 @@ open class MessagesCollectionViewFlowLayout: UICollectionViewFlowLayout {
155155 let calculator = cellSizeCalculatorForItem ( at: indexPath)
156156 return calculator. sizeForItem ( at: indexPath)
157157 }
158+
159+ /// Set `incomingAvatarSize` of all `MessageSizeCalculator`s
160+ public func setMessageIncomingAvatarSize( _ newSize: CGSize ) {
161+ messageSizeCalculators ( ) . forEach { $0. incomingAvatarSize = newSize }
162+ }
163+
164+ /// Set `outgoingAvatarSize` of all `MessageSizeCalculator`s
165+ public func setMessageOutgoingAvatarSize( _ newSize: CGSize ) {
166+ messageSizeCalculators ( ) . forEach { $0. outgoingAvatarSize = newSize }
167+ }
168+
169+ /// Set `incomingAvatarPosition` of all `MessageSizeCalculator`s
170+ public func setMessageIncomingAvatarPosition( _ newPosition: AvatarPosition ) {
171+ messageSizeCalculators ( ) . forEach { $0. incomingAvatarPosition = newPosition }
172+ }
173+
174+ /// Set `outgoingAvatarPosition` of all `MessageSizeCalculator`s
175+ public func setMessageOutgoingAvatarPosition( _ newPosition: AvatarPosition ) {
176+ messageSizeCalculators ( ) . forEach { $0. outgoingAvatarPosition = newPosition }
177+ }
178+
179+ /// Set `incomingMessagePadding` of all `MessageSizeCalculator`s
180+ public func setMessageIncomingMessagePadding( _ newPadding: UIEdgeInsets ) {
181+ messageSizeCalculators ( ) . forEach { $0. incomingMessagePadding = newPadding }
182+ }
183+
184+ /// Set `outgoingMessagePadding` of all `MessageSizeCalculator`s
185+ public func setMessageOutgoingMessagePadding( _ newPadding: UIEdgeInsets ) {
186+ messageSizeCalculators ( ) . forEach { $0. outgoingMessagePadding = newPadding }
187+ }
188+
189+ /// Set `incomingCellTopLabelAlignment` of all `MessageSizeCalculator`s
190+ public func setMessageIncomingCellTopLabelAlignment( _ newAlignment: LabelAlignment ) {
191+ messageSizeCalculators ( ) . forEach { $0. incomingCellTopLabelAlignment = newAlignment }
192+ }
193+
194+ /// Set `outgoingCellTopLabelAlignment` of all `MessageSizeCalculator`s
195+ public func setMessageOutgoingCellTopLabelAlignment( _ newAlignment: LabelAlignment ) {
196+ messageSizeCalculators ( ) . forEach { $0. outgoingCellTopLabelAlignment = newAlignment }
197+ }
198+
199+ /// Set `incomingMessageTopLabelAlignment` of all `MessageSizeCalculator`s
200+ public func setMessageIncomingMessageTopLabelAlignment( _ newAlignment: LabelAlignment ) {
201+ messageSizeCalculators ( ) . forEach { $0. incomingMessageTopLabelAlignment = newAlignment }
202+ }
203+
204+ /// Set `outgoingMessageTopLabelAlignment` of all `MessageSizeCalculator`s
205+ public func setMessageOutgoingMessageTopLabelAlignment( _ newAlignment: LabelAlignment ) {
206+ messageSizeCalculators ( ) . forEach { $0. outgoingMessageTopLabelAlignment = newAlignment }
207+ }
208+
209+ /// Set `incomingMessageBottomLabelAlignment` of all `MessageSizeCalculator`s
210+ public func setMessageIncomingMessageBottomLabelAlignment( _ newAlignment: LabelAlignment ) {
211+ messageSizeCalculators ( ) . forEach { $0. incomingMessageBottomLabelAlignment = newAlignment }
212+ }
213+
214+ /// Set `outgoingMessageBottomLabelAlignment` of all `MessageSizeCalculator`s
215+ public func setMessageOutgoingMessageBottomLabelAlignment( _ newAlignment: LabelAlignment ) {
216+ messageSizeCalculators ( ) . forEach { $0. outgoingMessageBottomLabelAlignment = newAlignment }
217+ }
218+
219+ /// Get all `MessageSizeCalculator`s
220+ open func messageSizeCalculators( ) -> [ MessageSizeCalculator ] {
221+ return [ textMessageSizeCalculator, attributedTextMessageSizeCalculator, emojiMessageSizeCalculator, photoMessageSizeCalculator, videoMessageSizeCalculator, locationMessageSizeCalculator]
222+ }
223+
158224}
0 commit comments