Skip to content
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

Merged
merged 3 commits into from
Apr 13, 2017

Conversation

pgs-dkanak
Copy link
Contributor

Added custom message bubbles configuration with message grouping

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
@pgs-dkanak pgs-dkanak self-assigned this Apr 13, 2017
@pgs-dkanak pgs-dkanak requested a review from bdudarPGS April 13, 2017 08:50
return nil
}

private func cropAndResize(slice: ImageSlice)->UIImage {
Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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
@bdudarPGS bdudarPGS merged commit 0089101 into develop Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants