Skip to content

v0.1.0#5

Merged
SD10 merged 18 commits intomasterfrom
v0.1.0
Jul 27, 2017
Merged

v0.1.0#5
SD10 merged 18 commits intomasterfrom
v0.1.0

Conversation

@SD10
Copy link
Member

@SD10 SD10 commented Jul 22, 2017

No description provided.

public let highlightedImage: UIImage

public func image(highlighted: Bool) -> UIImage {
return highlighted ? image : highlightedImage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably be removed/repurposed considering we most likely won't use images for bubbles. The return values are flipped though 😛

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why don't we remove this now? I feel like this a key point in this projects development where we have an opportunity to remove any cruft.

@codecov-io
Copy link

codecov-io commented Jul 22, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@bbc9884). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             master     #5   +/-   ##
=======================================
  Coverage          ?   100%           
=======================================
  Files             ?      1           
  Lines             ?      7           
  Branches          ?      0           
=======================================
  Hits              ?      7           
  Misses            ?      0           
  Partials          ?      0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbc9884...32265a4. Read the comment docs.


case video(file: NSURL, thumbnail: UIImage)

case system(String)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is MessageData.system? or rather; what is the difference with .text and .system

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a little code comment will be helpful for people to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not sure because this is code leftover from the old repo. The only thing to be concerned about for the moment is MessageData.text. v1 should be basic messages and then expand to Media data types from there.

@towry eventually the code will be fully commented by v1. right now I'm just hacking things together 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I would suggest removing anything that does not make any since. I would rather not have things then to start out with bloat right off the bat. But that might just be me.

@SD10
Copy link
Member Author

SD10 commented Jul 23, 2017

Some things are shaping up but the code is still very rough. A lot is subject to change. I'm struggling over using a UICollectionViewController opposed to a regular UIViewController. I'd like my collectionView to be typed as MessagesCollectionView.

Type casting everywhere 😭

Copy link
Contributor

@MacMeDan MacMeDan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove anything that is not understood or that is not fully implemented.

public let highlightedImage: UIImage

public func image(highlighted: Bool) -> UIImage {
return highlighted ? image : highlightedImage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why don't we remove this now? I feel like this a key point in this projects development where we have an opportunity to remove any cruft.


var sentDate: Date { get }

var data: MessageData { get }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why we would not have the sentDate as a part of the messageData. Can we think of a reason we would want this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also get confused with naming. Here "MessageData" is the enum of different message category, while the protocol is holding the message content. It's better to name the protocol as "MessageData" and the enum as "MessageType".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had similar concerns. I'm considering:
MessageType -> MessageRepresentable
MessageData -> MessageType

@SD10
Copy link
Member Author

SD10 commented Jul 23, 2017

v0.1.0 Features:

  • Message Bubbles Incoming/Outgoing
  • Message Avatars
  • Basic Text Messages Support
  • Resizing Messages Based on Text Length
  • Input Bar With Send Button
  • Move Input Bar When Showing Keyboard


override func apply(_ layoutAttributes: UICollectionViewLayoutAttributes) {
guard let attributes = layoutAttributes as? MessagesCollectionViewLayoutAttributes else { return }
print(attributes.avatarSize)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For print statements, you should probably forward them to a print statement that only works in DEBUG mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArtSabintsev I left those by accident 👍 Thanks. I would never allow them in a release

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the print statements is temporary here, I would add a comment to such thing as to be removed. Even in debug mode, other people may not want to see all kind print messages in the console. But it is good to decorate print statement in a DEBUG util in case the code being merged to master branch or we can use swift lint tool to check that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the code will be cleaned up before any merge to master. Having this PR open is just to show the public that there is work being done.

return attributes.messageFont == messageFont && attributes.avatarSize == avatarSize &&
attributes.avatarToEdgePadding == avatarToEdgePadding && attributes.avatarBottomPadding == avatarBottomPadding &&
attributes.avatarToContainerPadding == avatarToContainerPadding && attributes.messageLeftRightPadding == messageLeftRightPadding &&
attributes.direction == direction
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better formatting.

return attributes.messageFont == messageFont &&
    attributes.avatarSize == avatarSize &&
    attributes.avatarToEdgePadding == avatarToEdgePadding &&
    attributes.avatarBottomPadding == avatarBottomPadding &&
    attributes.avatarToContainerPadding == avatarToContainerPadding &&
    attributes.messageLeftRightPadding == messageLeftRightPadding &&
    attributes.direction == direction


case photo(UIImage)

case video(file: NSURL, thumbnail: UIImage)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the video type apply a UIButton to as its internal property? Or is it autoplay when video is sent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't commented out yet but v1 will only support basic types like text(String). More details to come when I write up a Vision.md

let containerX = contentView.frame.width - attributes.messageLeftRightPadding - containerWidth
let containerY: CGFloat = 0
messageContainerView.frame = CGRect(x: containerX, y: containerY, width: containerWidth, height: containerHeight)
}
Copy link

@lzyraining lzyraining Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic from the AvatarSizeCalculator is blocking incoming avatar. And there is no difference between incoming and outgoing case. Recommend to add a todo list to remove this constraint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's half implemented, not done yet. This branch is really outdated.

func setupConstraints() {

messagesCollectionView.translatesAutoresizingMaskIntoConstraints = false
view.addConstraint(NSLayoutConstraint(item: messagesCollectionView, attribute: .top, relatedBy: .equal, toItem: topLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0))
Copy link

@nunogoncalves nunogoncalves Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just here sniffing around.
Why not using anchors? Minimum targets?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, minimum targets. I struggled with the decision to support iOS 8. I figured why not unless it becomes a hassle.


class AvatarSizeCalculator {

func avatarSizeFor(messageType: MessageType, with layout: MessagesCollectionViewFlowLayout) -> CGSize {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I may,
func avatarSize(for messageType: MessageType, with layout: MessagesCollectionViewFlowLayout) would make the calling site read better. :)


fileprivate extension String {

func height(considering width: CGFloat, font: UIFont) -> CGFloat {
Copy link

@nunogoncalves nunogoncalves Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just another tiny suggestion:

func height(considering width: CGFloat, and font: UIFont)

would produce a calling site reading experience a bit smoother.

height(considering: width, and: UIFont.systemFont...)

Also, this is nice for views with number of lines = 0. If you want to have a label with max number of lines = 2 for example, this won't do it as it will only consider the text. That way I would prefer the sizeThatFits from the label.

@SD10
Copy link
Member Author

SD10 commented Jul 26, 2017

Hi @ everyone, first and foremost sorry for the delay! I ran into a nasty bug that ate up most of my time.

I'm sure that most of you have gotten bored looking for some way to contribute, but let's not take this PR too seriously. It was primarily to show people this repo is active.

It's a WIP so you may see some hacky code or half implemented solutions. It doesn't mean I have the intention of leaving them this way 😅


func avatarForMessage(_ message: MessageType, at indexPath: IndexPath, in collectionView: UICollectionView) -> Avatar {
let image = isFromCurrentSender(message: message) ? #imageLiteral(resourceName: "Steve-Jobs") : #imageLiteral(resourceName: "Tim-Cook")
return Avatar(placeholderImage: image)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not let Sender own the Avatar? To make the API more user friendly. We don't need to map the avatar to message manually.

func avatarForMessage(_ message: MessageType, at indexPath: IndexPath, in collectionView: UICollectionView) -> Avatar {
       return message.sender.avatar
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lzyraining thanks for the feedback!

Deciding how to expose an API that allows for easy customization will be a difficult task. I hope to release a really basic v0.1.0 beta in the next few hours and will be looking for feedback/suggestions.

As for your suggestion, I don't think Sender is a good fit for the responsibility of Avatar because some people may not even want Avatars. I'd like to keep this types responsibility minimal. I've even considered making it a protocol.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SD10 I agree that it's difficult to build easy customized API. Thanks for the optional type in swift, we can simple handle who don't want Avatars by putting a question mark.

I like the idea using protocol for some models. Swift is basically protocol oriented programming language. It's amazing that protocol allows inheritance and extension to make customize and default values easy. But my concern is that we are build a framework for all potential use. From a user's perspective, I don't want to build all the models which are declared as protocol in the library. I just want to it easy to use.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lzyraining Thanks, I had considered making Avatar optional here as well. It will take a bit of time to decide on a nice API. The great thing is we don't have to worry about API stability at this moment 😃

Thanks for raising the concerns of having to build the models required by protocols. I was originally thinking that people would probably already have a User model that they could conform Sender to -- but I see this could also be difficult and intrusive.

@SD10 SD10 changed the title [WIP] v0.1.0 v0.1.0 Jul 27, 2017
@SD10 SD10 merged commit 7efca7b into master Jul 27, 2017
@SD10 SD10 deleted the v0.1.0 branch August 1, 2017 05:04
result0924 pushed a commit to result0924/MessageKit that referenced this pull request Oct 5, 2023
Let cell support diary quote message type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants