-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/dk/kil 84 custom message bubbles #7
Conversation
Added separator line Added image for demo
Added custom bubbles Added bubbles ordering Added bubble-specific margins calculation Added external settings interface to set custom bubbles
MessagesView/BubbleImage.swift
Outdated
return nil | ||
} | ||
|
||
private func cropAndResize(slice: ImageSlice)->UIImage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get rid of some code duplication and optionals. Try:
private func cropAndResize(slice: ImageSlice?) -> UIImage {
guard let slice = slice, let croppedImage = image.cgImage?.cropping(to: slice.cropRect) else {
return UIImage()
}
return UIImage(cgImage: croppedImage).resizableImage(withCapInsets: slice.resizeInsets, resizingMode: .stretch).withRenderingMode(.alwaysTemplate)
}
and then:
lazy var whole: UIImage = self.cropAndResize(slice: self.wholeSlice)
lazy var top: UIImage = self.cropAndResize(slice: self.topSlice)
lazy var middle: UIImage = self.cropAndResize(slice: self.middleSlice)
lazy var bottom: UIImage = self.cropAndResize(slice: self.bottomSlice)
import Foundation | ||
|
||
class MessagesGroupingCoordinator { | ||
public func selectBackgroundFor(index: Int, inMessages messages: [MessagesViewChatMessage], withBubble bubbbleImage: BubbleImage)->UIImage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be moved to MessageView, no need for separate class with no properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done this way due to predictability of different grouping styles available in future. If there will be any, we will simply add new grouping coordinator object. Conversely there is no need to put it in another class if we got only one way of grouping messages. For now however, this way of embedding this functionality is just a mark that grouping criteria might change in the future.
Removed MessagesGroupingCoordinator
Added custom message bubbles configuration with message grouping