Skip to content

Commit 4422020

Browse files
committed
Merge branch 'master' of https://github.com/MessageKit/MessageKit into development
2 parents ca74370 + c52d6e4 commit 4422020

11 files changed

Lines changed: 126 additions & 45 deletions

File tree

CHANGELOG.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@ the `MessageData.location` case.
2929
[#579](https://github.com/MessageKit/MessageKit/pull/579) by [@SD10](https://github.com/SD10).
3030

3131
- Added `MessageSizeCalculator`, `MediaMessageSizeCalculator`, `TextMessageSizeCalculator`, and `LocationMessageSizeCalculator`
32-
classes that are responsible for sizing the `MessagesCollectionViewCell` types provided by MessageKit.
32+
classes that are responsible for sizing the `MessagesCollectionViewCell` types provided by MessageKit.
3333
[#579](https://github.com/MessageKit/MessageKit/pull/579) by [@SD10](https://github.com/sd10).
3434

35-
- Added `shouldManageSendButtonEnabledState` to `MessageInputBar` to disable automatically managing `MessageInputBar.sendButton`'s
36-
`isEnabled` state when text changes. (Default value is `true`).
37-
[#530](https://github.com/MessageKit/MessageKit/pull/530) by [@clayellis](https://github.com/clayellis).
38-
3935
- Added two new methods `cellTopLabelHeight(for:at:in)` and `cellBottomLabelHeight(for:at:in)` to `MessagesLayoutDelegate`
4036
[#580](https://github.com/MessageKit/MessageKit/pull/580) by [@SD10](https://github.com/sd10).
4137

@@ -115,6 +111,41 @@ You must now set this font explicitly through the `emojiMessageSizeCalculator` o
115111
You can now set this property through `textMessageSizeCalculator` property.
116112
[#579](https://github.com/MessageKit/MessageKit/pull/579) by [@SD10](https://github.com/sd10).
117113

114+
### Fixed
115+
116+
- Fixed equality checking on `MessagesCollectionViewLayoutAttributes`.
117+
[#593](https://github.com/MessageKit/MessageKit/pull/593) by [@zhongwuzw](https://github.com/zhongwuzw), [@SD10](https://github.com/sd10)
118+
119+
## [[Prerelease] 0.13.4](https://github.com/MessageKit/MessageKit/releases/tag/0.13.4)
120+
121+
### Fixed
122+
123+
- Fixed `bubbleTailOutline` invalidation of message bubble.
124+
[#633](https://github.com/MessageKit/MessageKit/pull/633) by [@zhongwuzw](https://github.com/zhongwuzw).
125+
126+
- Fixed `boundingRect(with:options:attributes:context)` wrong size calculation when use some font, e.g. custom font.
127+
[#645](https://github.com/MessageKit/MessageKit/pull/645) by [@zhongwuzw](https://github.com/zhongwuzw).
128+
129+
## [[Prerelease] 0.13.3](https://github.com/MessageKit/MessageKit/releases/tag/0.13.3)
130+
131+
### Fixed
132+
133+
- Fixed font invalidation of `attributedString` in `MessageLabel`.
134+
[#623](https://github.com/MessageKit/MessageKit/pull/623) by [@zhongwuzw](https://github.com/zhongwuzw).
135+
136+
## [[Prerelease] 0.13.2](https://github.com/MessageKit/MessageKit/releases/tag/0.13.2)
137+
138+
### Added
139+
140+
- Added `shouldManageSendButtonEnabledState` to `MessageInputBar` to disable automatically managing `MessageInputBar.sendButton`'s
141+
`isEnabled` state when text changes. (Default value is `true`).
142+
[#530](https://github.com/MessageKit/MessageKit/pull/530) by [@clayellis](https://github.com/clayellis).
143+
144+
### Fixed
145+
146+
- Fixed wrong separated components in messageInputBar.
147+
[#577](https://github.com/MessageKit/MessageKit/pull/577) by [@zhongwuzw](https://github.com/zhongwuzw).
148+
118149
## [[Prerelease] 0.13.1](https://github.com/MessageKit/MessageKit/releases/tag/0.13.1)
119150

120151
### Fixed
@@ -128,9 +159,6 @@ You can now set this property through `textMessageSizeCalculator` property.
128159
- Fixed message bubble tail orientation invalidation in `iOS9`.
129160
[#469](https://github.com/MessageKit/MessageKit/pull/469) by [@zhongwuzw](https://github.com/zhongwuzw).
130161

131-
- Fixed equality checking on `MessagesCollectionViewLayoutAttributes`.
132-
[#593](https://github.com/MessageKit/MessageKit/pull/593) by [@zhongwuzw](https://github.com/zhongwuzw), [@SD10](https://github.com/sd10)
133-
134162
## [[Prerelease] 0.13.0](https://github.com/MessageKit/MessageKit/releases/tag/0.13.0)
135163

136164
### Fixed

CONTRIBUTING.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,15 @@ The more information you can provide, the easier it will be for us to resolve yo
4141

4242
### Submitting a Pull Request
4343

44-
- Please read the MessageKit [VISION.md](https://github.com/MessageKit/MessageKit/blob/master/VISION.md) document to understand the project goals, scope, and other technical considerations.
45-
- We strongly encourage you to open an issue discussing any potential new features before an implementation is provided.
46-
- This ensures the feature is in scope and no ones time is wasted.
44+
We maintain two permanent, protected branches: `master` and `development`.
4745

48-
- **Please DO NOT submit pull requests to the `master` branch**
49-
- This branch is always stable and represents a release.
46+
`master` is for working on the current release, so any bug fixes or documentation spelling fixes should be merged into this branch.
5047

51-
- **Please DO submit your pull request to the branch representing the next release version**
48+
`development` is where we stage work for the *next* release, i.e. breaking API changes and related documentation updates. Contributors should gently encourage new pull-requests to point to the appropriate branch, and to rebase onto that branch if necessary.
5249

53-
1. Link to any issues the pull request resolves. If none exist, create one.
54-
2. Write unit tests for new functionality or fix any broken by your changes.
55-
3. If your changes affect documentation, please update them accordingly.
56-
4. Avoid pull requests with a large number of commits.
57-
5. Write clean code and follow the MessageKit [style guidelines](#style-guidelines).
50+
When a new version is ready to be released, please create a pull request to merge `development` into `master`, named something like "Release 10.0". Then we can have some final discussion before we merge it into `master` and push the release out to the public.
51+
52+
Since `development` is a *shared* branch, it is important not to ever rebase this branch onto `master`. If a bug fix is applied to `master` it can be merged into `development` using good old simple `git checkout development && git merge master`. Yes this will clutter the history a little bit, but it also provides important context to know how/when a patch was applied. Merge commits can be considered necessary historical data, not warts on an idealized history graph.
5853

5954
**You should submit one pull request per feature, the smaller the pull request the better chances it will be merged.**
6055
Enormous pull requests take a significant time to review and understand their implications on the existing codebase.
@@ -73,3 +68,9 @@ If any of the sections above are unclear and require further explanation, *do no
7368
MessageKit strives to build an inclusive open source community and to make contributing as easy as possible for members of all experience levels.
7469

7570
**You can get in touch with the MessageKit core team directly by joining our open Slack community channel: [here](https://join.slack.com/t/messagekit/shared_invite/MjI0NDkxNjgwMzA3LTE1MDIzMTU0MjUtMzJhZDZlNTkxMA).**
71+
72+
----
73+
74+
## [No Brown M&M's](http://en.wikipedia.org/wiki/Van_Halen#Contract_riders)
75+
76+
If you made it all the way to the end, bravo dear user, we love you. You can include this emoji in the top of your ticket to signal to us that you did in fact read this file and are trying to conform to it as best as possible: :ghost:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

MessageKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'MessageKit'
3-
s.version = '0.13.1'
3+
s.version = '0.13.4'
44
s.license = { :type => "MIT", :file => "LICENSE.md" }
55

66
s.summary = 'An elegant messages UI library for iOS.'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Sources/Extensions/NSAttributedString+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ extension NSAttributedString {
2929
internal func height(considering width: CGFloat) -> CGFloat {
3030

3131
let constraintBox = CGSize(width: width, height: .greatestFiniteMagnitude)
32-
let rect = self.boundingRect(with: constraintBox, options: .usesLineFragmentOrigin, context: nil)
32+
let rect = self.boundingRect(with: constraintBox, options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil)
3333
return rect.height
3434

3535
}
3636

3737
internal func width(considering height: CGFloat) -> CGFloat {
3838

3939
let constraintBox = CGSize(width: .greatestFiniteMagnitude, height: height)
40-
let rect = self.boundingRect(with: constraintBox, options: .usesLineFragmentOrigin, context: nil)
40+
let rect = self.boundingRect(with: constraintBox, options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil)
4141
return rect.width
4242

4343
}

Sources/Models/NSConstraintLayoutSet.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ internal class NSLayoutConstraintSet {
5151

5252
/// All of the currently configured constraints
5353
private var availableConstraints: [NSLayoutConstraint] {
54-
return [top, bottom, left, right, centerX, centerY, width, height]
55-
.flatMap {$0}
54+
let constraints = [top, bottom, left, right, centerX, centerY, width, height]
55+
var available: [NSLayoutConstraint] = []
56+
for constraint in constraints {
57+
if let value = constraint {
58+
available.append(value)
59+
}
60+
}
61+
return available
5662
}
5763

5864
/// Activates all of the non-nil constraints

Sources/Views/Cells/TextMessageCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ open class TextMessageCell: MessageContentCell {
6868
fatalError(MessageKitError.nilMessagesDisplayDelegate)
6969
}
7070

71-
let textColor = displayDelegate.textColor(for: message, at: indexPath, in: messagesCollectionView)
7271
let enabledDetectors = displayDelegate.enabledDetectors(for: message, at: indexPath, in: messagesCollectionView)
7372

7473
messageLabel.configure {
@@ -79,6 +78,7 @@ open class TextMessageCell: MessageContentCell {
7978
}
8079
switch message.data {
8180
case .text(let text), .emoji(let text):
81+
let textColor = displayDelegate.textColor(for: message, at: indexPath, in: messagesCollectionView)
8282
messageLabel.text = text
8383
messageLabel.textColor = textColor
8484
if let font = messageLabel.messageLabelFont {

Sources/Views/InputTextView.swift

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,26 +305,50 @@ open class InputTextView: UITextView {
305305
private func parseForComponents() -> [Any] {
306306

307307
var components = [Any]()
308-
let range = NSRange(location: 0, length: attributedText.length)
309-
attributedText.enumerateAttributes(in: range, options: []) { (object, range, _) in
310-
311-
if object.keys.contains(.attachment) {
312-
if let attachment = object[.attachment] as? NSTextAttachment {
313-
if let image = attachment.image {
314-
components.append(image)
315-
} else if let image = attachment.image(forBounds: attachment.bounds,
316-
textContainer: nil,
317-
characterIndex: range.location) {
318-
components.append(image)
308+
var attachments = [(NSRange, UIImage)]()
309+
let length = attributedText.length
310+
let range = NSRange(location: 0, length: length)
311+
attributedText.enumerateAttribute(.attachment, in: range) { (object, range, _) in
312+
if let attachment = object as? NSTextAttachment {
313+
if let image = attachment.image {
314+
attachments.append((range, image))
315+
} else if let image = attachment.image(forBounds: attachment.bounds,
316+
textContainer: nil,
317+
characterIndex: range.location) {
318+
attachments.append((range,image))
319+
}
320+
}
321+
}
322+
323+
var curLocation = 0
324+
if attachments.count == 0 {
325+
let text = attributedText.string.trimmingCharacters(in: .whitespacesAndNewlines)
326+
if !text.isEmpty {
327+
components.append(text)
328+
}
329+
}
330+
else {
331+
attachments.forEach { (attachment) in
332+
let (range, image) = attachment
333+
if curLocation < range.location {
334+
let textRange = NSMakeRange(curLocation, range.location)
335+
let text = attributedText.attributedSubstring(from: textRange).string.trimmingCharacters(in: .whitespacesAndNewlines)
336+
if !text.isEmpty {
337+
components.append(text)
319338
}
320339
}
321-
} else {
322-
let stringValue = attributedText.attributedSubstring(from: range).string.trimmingCharacters(in: .whitespacesAndNewlines)
323-
if !stringValue.isEmpty {
324-
components.append(stringValue)
340+
341+
curLocation = range.location + range.length
342+
components.append(image)
343+
}
344+
if curLocation < length - 1 {
345+
let text = attributedText.attributedSubstring(from: NSMakeRange(curLocation, length - curLocation)).string.trimmingCharacters(in: .whitespacesAndNewlines)
346+
if !text.isEmpty {
347+
components.append(text)
325348
}
326349
}
327350
}
351+
328352
return components
329353
}
330354

0 commit comments

Comments
 (0)