Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Example/ChatExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -642,7 +642,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -659,7 +659,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -675,7 +675,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -688,7 +688,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample";
};
name = Debug;
Expand All @@ -703,7 +703,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample";
};
name = Release;
Expand All @@ -716,7 +716,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = ChatExample;
};
name = Debug;
Expand All @@ -730,7 +730,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = ChatExample;
};
name = Release;
Expand Down
6 changes: 3 additions & 3 deletions Example/Sources/ConversationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ConversationViewController: MessagesViewController {
action: #selector(handleKeyboardButton))
}

func handleKeyboardButton() {
@objc func handleKeyboardButton() {

let actionSheetController = UIAlertController(title: "Change Keyboard Style", message: nil, preferredStyle: .actionSheet)
let actions = [
Expand Down Expand Up @@ -198,14 +198,14 @@ extension ConversationViewController: MessagesDataSource {

func cellTopLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? {
let name = message.sender.displayName
return NSAttributedString(string: name, attributes: [NSFontAttributeName: UIFont.preferredFont(forTextStyle: .caption1)])
return NSAttributedString(string: name, attributes: [NSAttributedStringKey.font: UIFont.preferredFont(forTextStyle: .caption1)])
}

func cellBottomLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? {
let formatter = DateFormatter()
formatter.dateStyle = .medium
let dateString = formatter.string(from: message.sentDate)
return NSAttributedString(string: dateString, attributes: [NSFontAttributeName: UIFont.preferredFont(forTextStyle: .caption2)])
return NSAttributedString(string: dateString, attributes: [NSAttributedStringKey.font: UIFont.preferredFont(forTextStyle: .caption2)])
}

}
Expand Down
10 changes: 5 additions & 5 deletions Example/Sources/SampleData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ struct SampleData {
let msg9Text = NSString(string: msg9String)
let msg9AttributedText = NSMutableAttributedString(string: String(msg9Text))

msg9AttributedText.addAttribute(NSFontAttributeName, value: UIFont.preferredFont(forTextStyle: .body), range: NSRange(location: 0, length: msg9Text.length))
msg9AttributedText.addAttributes([NSFontAttributeName: UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: UIFontWeightBold)], range: msg9Text.range(of: ".attributedText()"))
msg9AttributedText.addAttributes([NSFontAttributeName: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "bold"))
msg9AttributedText.addAttributes([NSFontAttributeName: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "italic"))
msg9AttributedText.addAttributes([NSForegroundColorAttributeName: UIColor.red], range: msg9Text.range(of: "colored"))
msg9AttributedText.addAttribute(NSAttributedStringKey.font, value: UIFont.preferredFont(forTextStyle: .body), range: NSRange(location: 0, length: msg9Text.length))
msg9AttributedText.addAttributes([NSAttributedStringKey.font: UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: UIFont.Weight.bold)], range: msg9Text.range(of: ".attributedText()"))
msg9AttributedText.addAttributes([NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "bold"))
msg9AttributedText.addAttributes([NSAttributedStringKey.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "italic"))
msg9AttributedText.addAttributes([NSAttributedStringKey.foregroundColor: UIColor.red], range: msg9Text.range(of: "colored"))

var msg9 = MockMessage(attributedText: msg9AttributedText, sender: Jobs, messageId: UUID().uuidString)
var msg10 = MockMessage(text: "1-800-555-0000", sender: Dan, messageId: UUID().uuidString)
Expand Down
2 changes: 1 addition & 1 deletion MessageKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.source_files = 'Sources/*.swift'

s.pod_target_xcconfig = {
"SWIFT_VERSION" => "3.0",
"SWIFT_VERSION" => "4.0",
}

s.ios.deployment_target = '9.0'
Expand Down
8 changes: 4 additions & 4 deletions MessageKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -604,7 +604,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -629,7 +629,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -650,7 +650,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Sources/AvatarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ open class AvatarView: UIView {

let textStyle = NSMutableParagraphStyle()
textStyle.alignment = .center
let textFontAttributes: [String: Any] = [NSFontAttributeName: font, NSForegroundColorAttributeName: placeholderTextColor, NSParagraphStyleAttributeName: textStyle]
let textFontAttributes: [NSAttributedStringKey: Any] = [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: placeholderTextColor, NSAttributedStringKey.paragraphStyle: textStyle]

let textTextHeight: CGFloat = initals.boundingRect(with: CGSize(width: textRect.width, height: CGFloat.infinity), options: .usesLineFragmentOrigin, attributes: textFontAttributes, context: nil).height
context.saveGState()
Expand Down
12 changes: 6 additions & 6 deletions Sources/InputBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ open class InputBarButtonItem: UIButton {
didSet {
switch spacing {
case .flexible:
setContentHuggingPriority(1, for: .horizontal)
setContentHuggingPriority(UILayoutPriority(rawValue: 1), for: .horizontal)
case .fixed:
setContentHuggingPriority(1000, for: .horizontal)
setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
case .none:
setContentHuggingPriority(500, for: .horizontal)
setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: .horizontal)
}
}
}
Expand Down Expand Up @@ -144,8 +144,8 @@ open class InputBarButtonItem: UIButton {
contentVerticalAlignment = .center
contentHorizontalAlignment = .center
imageView?.contentMode = .scaleAspectFit
setContentHuggingPriority(500, for: .horizontal)
setContentHuggingPriority(500, for: .vertical)
setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: .horizontal)
setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: .vertical)
setTitleColor(UIColor(red: 0, green: 122/255, blue: 1, alpha: 1), for: .normal)
setTitleColor(UIColor(red: 0, green: 122/255, blue: 1, alpha: 0.3), for: .highlighted)
setTitleColor(.lightGray, for: .disabled)
Expand Down Expand Up @@ -234,7 +234,7 @@ open class InputBarButtonItem: UIButton {
onKeyboardEditingBeginsAction?(self)
}

public func touchUpInsideAction() {
@objc public func touchUpInsideAction() {
onTouchUpInsideAction?(self)
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/MessageCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ open class MessageCollectionViewCell<ContentView: UIView>: UICollectionViewCell

// MARK: - Delegate Methods

func didTapAvatar() {
@objc func didTapAvatar() {
delegate?.didTapAvatar(in: self)
}

func didTapMessage() {
@objc func didTapMessage() {
delegate?.didTapMessage(in: self)
}

func didTapTopLabel() {
@objc func didTapTopLabel() {
delegate?.didTapTopLabel(in: self)
}

func didTapBottomLabel() {
@objc func didTapBottomLabel() {
delegate?.didTapBottomLabel(in: self)
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/MessageInputBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ open class MessageInputBar: UIView {

// MARK: - Notifications/Hooks

open func orientationDidChange() {
@objc open func orientationDidChange() {
invalidateIntrinsicContentSize()
}

open func textViewDidChange() {
@objc open func textViewDidChange() {
let trimmedText = inputTextView.text.trimmingCharacters(in: .whitespacesAndNewlines)

sendButton.isEnabled = !trimmedText.isEmpty
Expand All @@ -435,11 +435,11 @@ open class MessageInputBar: UIView {
invalidateIntrinsicContentSize()
}

open func textViewDidBeginEditing() {
@objc open func textViewDidBeginEditing() {
self.items.forEach { $0.keyboardEditingBeginsAction() }
}

open func textViewDidEndEditing() {
@objc open func textViewDidEndEditing() {
self.items.forEach { $0.keyboardEditingEndsAction() }
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/MessageKitDateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ open class MessageKitDateFormatter {
return formatter.string(from: date)
}

public func attributedString(from date: Date, with attributes: [String: Any]) -> NSAttributedString {
public func attributedString(from date: Date, with attributes: [NSAttributedStringKey: Any]) -> NSAttributedString {
let dateString = string(from: date)
return NSAttributedString(string: dateString, attributes: attributes)
}
Expand Down
32 changes: 16 additions & 16 deletions Sources/MessageLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,28 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
}
}

open var addressAttributes: [String: Any] = [:] {
open var addressAttributes: [NSAttributedStringKey: Any] = [:] {
didSet {
updateAttributes(for: .address)
setNeedsDisplay()
}
}

open var dateAttributes: [String: Any] = [:] {
open var dateAttributes: [NSAttributedStringKey: Any] = [:] {
didSet {
updateAttributes(for: .date)
setNeedsDisplay()
}
}

open var phoneNumberAttributes: [String: Any] = [:] {
open var phoneNumberAttributes: [NSAttributedStringKey: Any] = [:] {
didSet {
updateAttributes(for: .phoneNumber)
setNeedsDisplay()
}
}

open var urlAttributes: [String: Any] = [:] {
open var urlAttributes: [NSAttributedStringKey: Any] = [:] {
didSet {
updateAttributes(for: .url)
setNeedsDisplay()
Expand All @@ -156,10 +156,10 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
self.numberOfLines = 0
self.lineBreakMode = .byWordWrapping

let defaultAttributes: [String: Any] = [
NSForegroundColorAttributeName: self.textColor,
NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue,
NSUnderlineColorAttributeName: self.textColor
let defaultAttributes: [NSAttributedStringKey: Any] = [
NSAttributedStringKey.foregroundColor: self.textColor,
NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle.rawValue,
NSAttributedStringKey.underlineColor: self.textColor
]

self.addressAttributes = defaultAttributes
Expand Down Expand Up @@ -210,7 +210,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
guard let index = stringIndex(at: touchLocation) else { return true }
for (_, ranges) in rangesForDetectors {
for (nsRange, _) in ranges {
guard let range = nsRange.toRange() else { return true }
guard let range = Range(nsRange) else { return true }
if range.contains(index) { return false }
}
}
Expand All @@ -219,7 +219,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
guard let index = stringIndex(at: touchLocation) else { return false }
for (_, ranges) in rangesForDetectors {
for (nsRange, _) in ranges {
guard let range = nsRange.toRange() else { return false }
guard let range = Range(nsRange) else { return false }
if range.contains(index) { return true }
}
}
Expand Down Expand Up @@ -266,11 +266,11 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
let mutableAttributedString = NSMutableAttributedString(attributedString: text)
var textRange = NSRange(location: 0, length: 0)

let paragraphStyle = text.attribute(NSParagraphStyleAttributeName, at: 0, effectiveRange: &textRange) as? NSMutableParagraphStyle ?? NSMutableParagraphStyle()
let paragraphStyle = text.attribute(NSAttributedStringKey.paragraphStyle, at: 0, effectiveRange: &textRange) as? NSMutableParagraphStyle ?? NSMutableParagraphStyle()
paragraphStyle.lineBreakMode = lineBreakMode
paragraphStyle.alignment = textAlignment

mutableAttributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: textRange)
mutableAttributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: textRange)

return mutableAttributedString

Expand Down Expand Up @@ -304,7 +304,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {

}

private func detectorAttributes(for detectorType: DetectorType) -> [String: Any] {
private func detectorAttributes(for detectorType: DetectorType) -> [NSAttributedStringKey: Any] {

switch detectorType {
case .address:
Expand All @@ -319,7 +319,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {

}

private func detectorAttributes(for checkingResultType: NSTextCheckingResult.CheckingType) -> [String: Any] {
private func detectorAttributes(for checkingResultType: NSTextCheckingResult.CheckingType) -> [NSAttributedStringKey: Any] {
switch checkingResultType {
case NSTextCheckingResult.CheckingType.address:
return addressAttributes
Expand Down Expand Up @@ -413,14 +413,14 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
isUserInteractionEnabled = true
}

func handleGesture(_ gesture: UIGestureRecognizer) {
@objc func handleGesture(_ gesture: UIGestureRecognizer) {

let touchLocation = gesture.location(ofTouch: 0, in: self)
guard let index = stringIndex(at: touchLocation) else { return }

for (detectorType, ranges) in rangesForDetectors {
for (nsRange, value) in ranges {
guard let range = nsRange.toRange() else { return }
guard let range = Range(nsRange) else { return }
if range.contains(index) {
handleGesture(for: detectorType, value: value)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/MessagesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ extension MessagesViewController {
NotificationCenter.default.removeObserver(self, name: .UIKeyboardWillChangeFrame, object: nil)
}

func handleKeyboardDidChangeState(_ notification: Notification) {
@objc func handleKeyboardDidChangeState(_ notification: Notification) {

guard let keyboardEndFrame = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? CGRect else { return }

Expand Down
Loading