From 7a942711a6e42f9b27f5b318b44bb5c106cd9ef9 Mon Sep 17 00:00:00 2001 From: Nathan Tannar Date: Fri, 5 Apr 2019 09:37:57 -0700 Subject: [PATCH 01/64] Convert to Swift 5 / Fix Linting --- .circleci/config.yml | 2 +- .swift-version | 2 +- .swiftlint.yml | 1 - Cartfile | 2 +- Cartfile.private | 4 +-- Cartfile.resolved | 6 ++--- MessageKit.podspec | 8 +++--- MessageKit.xcodeproj/project.pbxproj | 13 +++++---- .../xcschemes/MessageKit.xcscheme | 2 +- .../xcschemes/MessageKitTests.xcscheme | 2 +- .../MessagesViewController+Keyboard.swift | 10 +++---- .../MessagesViewController+Menu.swift | 6 ++--- Sources/Extensions/Bundle+Extensions.swift | 4 +-- Sources/Extensions/CGRect+Extensions.swift | 4 +-- .../NSAttributedString+Extensions.swift | 4 +-- Sources/Extensions/UIColor+Extensions.swift | 12 ++++----- .../Extensions/UIEdgeInsets+Extensions.swift | 6 ++--- Sources/Extensions/UIImage+Extension.swift | 2 +- Sources/Extensions/UIView+Extensions.swift | 10 +++---- Sources/Models/AvatarPosition.swift | 8 +++--- Sources/Models/DetectorType.swift | 4 +-- Sources/Models/HorizontalEdgeInsets.swift | 12 +++++---- Sources/Models/LabelAlignment.swift | 6 ++--- Sources/Models/Sender.swift | 6 ++--- Sources/Supporting/MessageInputBar.swift | 27 ++----------------- 25 files changed, 72 insertions(+), 91 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e4c9ab21..e2a5ffbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ jobs: # Specify the Xcode version to use. macos: - xcode: "10.0.0" + xcode: "10.2.0" # Define the steps required to build the project. steps: diff --git a/.swift-version b/.swift-version index bf77d549..819e07a2 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2 +5.0 diff --git a/.swiftlint.yml b/.swiftlint.yml index 8bf8a3da..5ebf9e77 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -12,7 +12,6 @@ custom_rules: message: "Use like open override or public override instead" # violation message. optional. severity: warning # violation severity. optional. opt_in_rules: - - explicit_acl - explicit_top_level_acl explicit_acl: error explicit_top_level_acl: error diff --git a/Cartfile b/Cartfile index 50814158..ed7bec6d 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nathantannar4/InputBarAccessoryView" "4.2.1" +github "nathantannar4/InputBarAccessoryView" "4.3.0" diff --git a/Cartfile.private b/Cartfile.private index afc87ddb..29d169d6 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ -github "Quick/Quick" ~> 1.2.0 -github "Quick/Nimble" ~> 7.0.3 +github "Quick/Quick" ~> 2.0.0 +github "Quick/Nimble" ~> 8.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index c12c3fca..7acd3164 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "Quick/Nimble" "v7.3.4" -github "Quick/Quick" "v1.3.4" -github "nathantannar4/InputBarAccessoryView" "4.2.1" +github "Quick/Nimble" "v8.0.1" +github "Quick/Quick" "v2.0.0" +github "nathantannar4/InputBarAccessoryView" "4.3.0" diff --git a/MessageKit.podspec b/MessageKit.podspec index f6948f72..c486d5b6 100644 --- a/MessageKit.podspec +++ b/MessageKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MessageKit' - s.version = '3.0.0-beta-swift4-2' + s.version = '3.0.0-beta-swift5' s.license = { :type => "MIT", :file => "LICENSE.md" } s.summary = 'An elegant messages UI library for iOS.' @@ -12,16 +12,16 @@ Pod::Spec.new do |s| s.source_files = 'Sources/**/*.swift' s.pod_target_xcconfig = { - "SWIFT_VERSION" => "4.2", + "SWIFT_VERSION" => "5.0", } - s.swift_version = '4.2' + s.swift_version = '5.0' s.ios.deployment_target = '9.0' s.ios.resource_bundle = { 'MessageKitAssets' => 'Assets/MessageKitAssets.bundle/Images' } s.requires_arc = true - s.dependency 'InputBarAccessoryView' + s.dependency 'InputBarAccessoryView', '~> 4.3.0' end diff --git a/MessageKit.xcodeproj/project.pbxproj b/MessageKit.xcodeproj/project.pbxproj index 08abc0b6..d178c1d6 100644 --- a/MessageKit.xcodeproj/project.pbxproj +++ b/MessageKit.xcodeproj/project.pbxproj @@ -563,7 +563,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = MessageKit; TargetAttributes = { 88916B211CF0DF2F00469F91 = { @@ -580,6 +580,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 88916B181CF0DF2F00469F91; @@ -737,6 +738,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -786,7 +788,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -797,6 +799,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -838,7 +841,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -868,7 +871,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -894,7 +897,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme b/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme index 0bb9eb20..1f6e5d93 100644 --- a/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme +++ b/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme @@ -1,6 +1,6 @@ CGFloat { + func requiredInitialScrollViewBottomInset() -> CGFloat { guard let inputAccessoryView = inputAccessoryView else { return 0 } return max(0, inputAccessoryView.frame.height + additionalBottomInset - automaticallyAddedBottomInset) } diff --git a/Sources/Controllers/MessagesViewController+Menu.swift b/Sources/Controllers/MessagesViewController+Menu.swift index fc1cb5a2..9a02f20b 100644 --- a/Sources/Controllers/MessagesViewController+Menu.swift +++ b/Sources/Controllers/MessagesViewController+Menu.swift @@ -24,15 +24,15 @@ import Foundation -extension MessagesViewController { +internal extension MessagesViewController { // MARK: - Register / Unregister Observers - internal func addMenuControllerObservers() { + func addMenuControllerObservers() { NotificationCenter.default.addObserver(self, selector: #selector(MessagesViewController.menuControllerWillShow(_:)), name: UIMenuController.willShowMenuNotification, object: nil) } - internal func removeMenuControllerObservers() { + func removeMenuControllerObservers() { NotificationCenter.default.removeObserver(self, name: UIMenuController.willShowMenuNotification, object: nil) } diff --git a/Sources/Extensions/Bundle+Extensions.swift b/Sources/Extensions/Bundle+Extensions.swift index 17dda2e8..ea13d297 100644 --- a/Sources/Extensions/Bundle+Extensions.swift +++ b/Sources/Extensions/Bundle+Extensions.swift @@ -24,9 +24,9 @@ import Foundation -extension Bundle { +internal extension Bundle { - internal static func messageKitAssetBundle() -> Bundle { + static func messageKitAssetBundle() -> Bundle { let podBundle = Bundle(for: MessagesViewController.self) guard let resourceBundleUrl = podBundle.url(forResource: "MessageKitAssets", withExtension: "bundle") else { diff --git a/Sources/Extensions/CGRect+Extensions.swift b/Sources/Extensions/CGRect+Extensions.swift index 17e4347e..f5112a3d 100644 --- a/Sources/Extensions/CGRect+Extensions.swift +++ b/Sources/Extensions/CGRect+Extensions.swift @@ -24,9 +24,9 @@ import Foundation -extension CGRect { +internal extension CGRect { - internal init(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) { + init(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) { self.init(x: x, y: y, width: w, height: h) } diff --git a/Sources/Extensions/NSAttributedString+Extensions.swift b/Sources/Extensions/NSAttributedString+Extensions.swift index 430a64c5..e0fe3760 100644 --- a/Sources/Extensions/NSAttributedString+Extensions.swift +++ b/Sources/Extensions/NSAttributedString+Extensions.swift @@ -24,9 +24,9 @@ import Foundation -extension NSAttributedString { +internal extension NSAttributedString { - internal func width(considering height: CGFloat) -> CGFloat { + func width(considering height: CGFloat) -> CGFloat { let constraintBox = CGSize(width: .greatestFiniteMagnitude, height: height) let rect = self.boundingRect(with: constraintBox, options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil) diff --git a/Sources/Extensions/UIColor+Extensions.swift b/Sources/Extensions/UIColor+Extensions.swift index 02f5819c..0d85ba9e 100644 --- a/Sources/Extensions/UIColor+Extensions.swift +++ b/Sources/Extensions/UIColor+Extensions.swift @@ -24,16 +24,16 @@ import Foundation -extension UIColor { +internal extension UIColor { - internal static let incomingGray = UIColor(red: 230/255, green: 230/255, blue: 235/255, alpha: 1.0) + static let incomingGray = UIColor(red: 230/255, green: 230/255, blue: 235/255, alpha: 1.0) - internal static let outgoingGreen = UIColor(red: 69/255, green: 214/255, blue: 93/255, alpha: 1.0) + static let outgoingGreen = UIColor(red: 69/255, green: 214/255, blue: 93/255, alpha: 1.0) - internal static let inputBarGray = UIColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1.0) + static let inputBarGray = UIColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1.0) - internal static let playButtonLightGray = UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1.0) + static let playButtonLightGray = UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1.0) - internal static let sendButtonBlue = UIColor(red: 15/255, green: 135/255, blue: 255/255, alpha: 1.0) + static let sendButtonBlue = UIColor(red: 15/255, green: 135/255, blue: 255/255, alpha: 1.0) } diff --git a/Sources/Extensions/UIEdgeInsets+Extensions.swift b/Sources/Extensions/UIEdgeInsets+Extensions.swift index 8e259f56..bd938be8 100644 --- a/Sources/Extensions/UIEdgeInsets+Extensions.swift +++ b/Sources/Extensions/UIEdgeInsets+Extensions.swift @@ -24,13 +24,13 @@ import Foundation -extension UIEdgeInsets { +internal extension UIEdgeInsets { - internal var vertical: CGFloat { + var vertical: CGFloat { return top + bottom } - internal var horizontal: CGFloat { + var horizontal: CGFloat { return left + right } diff --git a/Sources/Extensions/UIImage+Extension.swift b/Sources/Extensions/UIImage+Extension.swift index 157fd0f4..5195a1e7 100644 --- a/Sources/Extensions/UIImage+Extension.swift +++ b/Sources/Extensions/UIImage+Extension.swift @@ -33,7 +33,7 @@ import UIKit /// This extension provide a way to access image resources with in framework public extension UIImage { - public class func messageKitImageWith(type: ImageType) -> UIImage? { + class func messageKitImageWith(type: ImageType) -> UIImage? { let assetBundle = Bundle.messageKitAssetBundle() let imagePath = assetBundle.path(forResource: type.rawValue, ofType: "png", inDirectory: "Images") let image = UIImage(contentsOfFile: imagePath ?? "") diff --git a/Sources/Extensions/UIView+Extensions.swift b/Sources/Extensions/UIView+Extensions.swift index 8eb50bbf..42bbbbd9 100644 --- a/Sources/Extensions/UIView+Extensions.swift +++ b/Sources/Extensions/UIView+Extensions.swift @@ -24,9 +24,9 @@ import UIKit -extension UIView { +internal extension UIView { - internal func fillSuperview() { + func fillSuperview() { guard let superview = self.superview else { return } @@ -41,7 +41,7 @@ extension UIView { NSLayoutConstraint.activate(constraints) } - internal func centerInSuperview() { + func centerInSuperview() { guard let superview = self.superview else { return } @@ -53,7 +53,7 @@ extension UIView { NSLayoutConstraint.activate(constraints) } - internal func constraint(equalTo size: CGSize) { + func constraint(equalTo size: CGSize) { guard superview != nil else { return } translatesAutoresizingMaskIntoConstraints = false let constraints: [NSLayoutConstraint] = [ @@ -65,7 +65,7 @@ extension UIView { } @discardableResult - internal func addConstraints(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, centerY: NSLayoutYAxisAnchor? = nil, centerX: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, centerYConstant: CGFloat = 0, centerXConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) -> [NSLayoutConstraint] { + func addConstraints(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, centerY: NSLayoutYAxisAnchor? = nil, centerX: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, centerYConstant: CGFloat = 0, centerXConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) -> [NSLayoutConstraint] { if self.superview == nil { return [] diff --git a/Sources/Models/AvatarPosition.swift b/Sources/Models/AvatarPosition.swift index 6421e48f..c62c99fe 100644 --- a/Sources/Models/AvatarPosition.swift +++ b/Sources/Models/AvatarPosition.swift @@ -26,7 +26,7 @@ import Foundation /// Used to determine the `Horizontal` and `Vertical` position of // an `AvatarView` in a `MessageCollectionViewCell`. -public struct AvatarPosition { +public struct AvatarPosition: Equatable { /// An enum representing the horizontal alignment of an `AvatarView`. public enum Horizontal { @@ -89,10 +89,10 @@ public struct AvatarPosition { // MARK: - Equatable Conformance -extension AvatarPosition: Equatable { +public extension AvatarPosition { - public static func == (lhs: AvatarPosition, rhs: AvatarPosition) -> Bool { + static func == (lhs: AvatarPosition, rhs: AvatarPosition) -> Bool { return lhs.vertical == rhs.vertical && lhs.horizontal == rhs.horizontal } - + } diff --git a/Sources/Models/DetectorType.swift b/Sources/Models/DetectorType.swift index 0dfd651a..1b711a77 100644 --- a/Sources/Models/DetectorType.swift +++ b/Sources/Models/DetectorType.swift @@ -58,8 +58,8 @@ public enum DetectorType: Hashable { } ///The hashValue of the `DetectorType` so we can conform to `Hashable` and be sorted. - public var hashValue: Int { - return self.toInt() + public func hash(into hasher: inout Hasher) { + hasher.combine(toInt()) } /// Return an 'Int' value for each `DetectorType` type so `DetectorType` can conform to `Hashable` diff --git a/Sources/Models/HorizontalEdgeInsets.swift b/Sources/Models/HorizontalEdgeInsets.swift index 7e92b030..91461fa9 100644 --- a/Sources/Models/HorizontalEdgeInsets.swift +++ b/Sources/Models/HorizontalEdgeInsets.swift @@ -25,7 +25,7 @@ import Foundation /// A varient of `UIEdgeInsets` that only has horizontal inset properties -public struct HorizontalEdgeInsets { +public struct HorizontalEdgeInsets: Equatable { public var left: CGFloat public var right: CGFloat @@ -40,16 +40,18 @@ public struct HorizontalEdgeInsets { } } -extension HorizontalEdgeInsets: Equatable { +// MARK: Equatable Conformance - public static func == (lhs: HorizontalEdgeInsets, rhs: HorizontalEdgeInsets) -> Bool { +public extension HorizontalEdgeInsets { + + static func == (lhs: HorizontalEdgeInsets, rhs: HorizontalEdgeInsets) -> Bool { return lhs.left == rhs.left && lhs.right == rhs.right } } -extension HorizontalEdgeInsets { +internal extension HorizontalEdgeInsets { - internal var horizontal: CGFloat { + var horizontal: CGFloat { return left + right } } diff --git a/Sources/Models/LabelAlignment.swift b/Sources/Models/LabelAlignment.swift index 2c6b0ba2..31465075 100644 --- a/Sources/Models/LabelAlignment.swift +++ b/Sources/Models/LabelAlignment.swift @@ -24,7 +24,7 @@ import UIKit -public struct LabelAlignment { +public struct LabelAlignment: Equatable { public var textAlignment: NSTextAlignment public var textInsets: UIEdgeInsets @@ -38,9 +38,9 @@ public struct LabelAlignment { // MARK: - Equatable Conformance -extension LabelAlignment: Equatable { +public extension LabelAlignment { - public static func == (lhs: LabelAlignment, rhs: LabelAlignment) -> Bool { + static func == (lhs: LabelAlignment, rhs: LabelAlignment) -> Bool { return lhs.textAlignment == rhs.textAlignment && lhs.textInsets == rhs.textInsets } diff --git a/Sources/Models/Sender.swift b/Sources/Models/Sender.swift index 28468785..bd5a31c5 100644 --- a/Sources/Models/Sender.swift +++ b/Sources/Models/Sender.swift @@ -25,7 +25,7 @@ import Foundation /// An object that groups the metadata of a messages sender. -@available(*, deprecated: 3.0.0, message: "`Sender` has been replaced with the `SenderType` protocol in 3.0.0") +@available(*, deprecated, message: "`Sender` has been replaced with the `SenderType` protocol in 3.0.0") public struct Sender: SenderType { /// MARK: - Properties @@ -35,7 +35,7 @@ public struct Sender: SenderType { /// Note: This value must be unique across all senders. public let senderId: String - @available(*, deprecated: 3.0.0, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") + @available(*, deprecated, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") public var id: String { return senderId } @@ -50,7 +50,7 @@ public struct Sender: SenderType { self.displayName = displayName } - @available(*, deprecated: 3.0.0, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") + @available(*, deprecated, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") public init(id: String, displayName: String) { self.init(senderId: id, displayName: displayName) } diff --git a/Sources/Supporting/MessageInputBar.swift b/Sources/Supporting/MessageInputBar.swift index 575edd50..a2c2919c 100644 --- a/Sources/Supporting/MessageInputBar.swift +++ b/Sources/Supporting/MessageInputBar.swift @@ -25,31 +25,8 @@ import UIKit import InputBarAccessoryView -@available(*, obsoleted: 3.0.0, renamed: "InputBarAccessoryView") +@available(*, deprecated, renamed: "InputBarAccessoryView") public typealias MessageInputBar = InputBarAccessoryView -@available(*, obsoleted: 3.0.0, renamed: "InputBarAccessoryViewDelegate") +@available(*, deprecated, renamed: "InputBarAccessoryViewDelegate") public typealias MessageInputBarDelegate = InputBarAccessoryViewDelegate - -//public extension MessageInputBarDelegate { -// -// @available(*, obsoleted: 3.0.0, message: "`MessageInputBar` has been replaced with `InputBarAccessoryView` in 3.0.0. Use `inputBar(_ inputBar: InputBarAccessoryView, didPressSendButtonWith text: String)` instead.") -// func messageInputBar(_ inputBar: MessageInputBar, didPressSendButtonWith text: String) { -// } -// -// @available(*, obsoleted: 3.0.0, message: "`MessageInputBar` has been replaced with `InputBarAccessoryView` in 3.0.0. Use `inputBar(_ inputBar: InputBarAccessoryView, textViewTextDidChangeTo text: String)` instead.") -// func messageInputBar(_ inputBar: MessageInputBar, textViewTextDidChangeTo text: String) { -// } -// -// @available(*, obsoleted: 3.0.0, message: "`MessageInputBar` has been replaced with `InputBarAccessoryView` in 3.0.0. Use `inputBar(_ inputBar: InputBarAccessoryView, didChangeIntrinsicContentTo size: CGSize)` instead.") -// func messageInputBar(_ inputBar: MessageInputBar, didChangeIntrinsicContentTo size: CGSize) { -// } -//} -// -//extension InputBarButtonItem { -// -// @available(*, renamed: "inputBarAccessoryView") -// public var messageInputBar: MessageInputBar? { -// return inputBarAccessoryView -// } -//} From 5edb955e52a519be3317611e347f1bc2b5311247 Mon Sep 17 00:00:00 2001 From: Nathan Tannar Date: Fri, 5 Apr 2019 09:51:15 -0700 Subject: [PATCH 02/64] Update Example to Swift 5 --- Example/.Podfile.un~ | Bin 628 -> 0 bytes Example/ChatExample.xcodeproj/project.pbxproj | 21 ++++++++++-------- .../xcschemes/ChatExample.xcscheme | 2 +- .../xcschemes/ChatExampleUITests.xcscheme | 2 +- Example/Podfile.lock | 10 ++++----- Example/Podfile~ | 16 ------------- Example/Sources/Data Generation/Lorem.swift | 8 +++---- 7 files changed, 23 insertions(+), 36 deletions(-) delete mode 100644 Example/.Podfile.un~ delete mode 100644 Example/Podfile~ diff --git a/Example/.Podfile.un~ b/Example/.Podfile.un~ deleted file mode 100644 index 8e635e873c954879ae48535cb0638240cdf80041..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 628 zcmWH`%$*;a=aT=FfvJX1uI8zJ&VRp+HftVn-1)vg!s@o?+VAtHCSSQEcItls0|Ns; z5F-OdAP0m&0LBLMV~T~MSRf+t7a;N|BuI)4Ch{K$;KslNM`@Md~^VR_U1~3bu9%>KP>^1;tkS`aph0 sX_8)Yey%=LwRdI-j0w}I2UG>poK%#Umz)9CpPN`*l3Jv0+W34G05;o29{>OV diff --git a/Example/ChatExample.xcodeproj/project.pbxproj b/Example/ChatExample.xcodeproj/project.pbxproj index 7cc41a7f..63b5cfe8 100644 --- a/Example/ChatExample.xcodeproj/project.pbxproj +++ b/Example/ChatExample.xcodeproj/project.pbxproj @@ -368,7 +368,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = MessageKit; TargetAttributes = { 882B5E321CF7D4B900B6E160 = { @@ -391,6 +391,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -599,6 +600,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -647,7 +649,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -656,6 +658,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -696,7 +699,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -713,7 +716,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -729,7 +732,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -742,7 +745,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample"; }; name = Debug; @@ -757,7 +760,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample"; }; name = Release; @@ -770,7 +773,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = ChatExample; }; name = Debug; @@ -784,7 +787,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = ChatExample; }; name = Release; diff --git a/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme b/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme index e34206a1..31f17b89 100644 --- a/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme +++ b/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme @@ -1,6 +1,6 @@ 4.3.0) DEPENDENCIES: - MessageKit (from `../`) @@ -15,8 +15,8 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - InputBarAccessoryView: 2b937602598e2fab3149f37f51dd7ad795653812 - MessageKit: 4226995f0811d3a51b8e80b56d2e95c97fa879e8 + InputBarAccessoryView: 28dca73f28df7822fe5377f83cfc4547e22f90ff + MessageKit: 96420f1fe84d037451cc7b11800a559189f40c25 PODFILE CHECKSUM: cecdb7bc8129cf99f66de9f68eea3256fec30c3d diff --git a/Example/Podfile~ b/Example/Podfile~ deleted file mode 100644 index bf44d23b..00000000 --- a/Example/Podfile~ +++ /dev/null @@ -1,16 +0,0 @@ -platform :ios, '9.0' - -target 'ChatExample' do - use_frameworks! - pod 'MessageKit', :path => '../' - pod 'MessageInputBar', :git => 'https://github.com/MessageKit/MessageInputBar.git', :branch => 'master' - -target 'ChatExampleTests' do - inherit! :search_paths -end - -target 'ChatExampleUITests' do - inherit! :search_paths -end - -end diff --git a/Example/Sources/Data Generation/Lorem.swift b/Example/Sources/Data Generation/Lorem.swift index 47597730..b368af71 100755 --- a/Example/Sources/Data Generation/Lorem.swift +++ b/Example/Sources/Data Generation/Lorem.swift @@ -222,7 +222,7 @@ public extension Array { /** Shuffle the array in-place using the Fisher-Yates algorithm. */ - public mutating func shuffle() { + mutating func shuffle() { for i in 0..<(count - 1) { let j = Int(arc4random_uniform(UInt32(count - i))) + i if j != i { @@ -237,7 +237,7 @@ public extension Array { - returns: Returns a shuffled version of the array. */ - public func shuffled() -> [Element] { + func shuffled() -> [Element] { var list = self list.shuffle() @@ -249,7 +249,7 @@ public extension Array { - returns: Returns a random element from the array or `nil` if the array is empty. */ - public func random() -> Element? { + func random() -> Element? { return (count > 0) ? self.shuffled()[0] : nil } @@ -257,7 +257,7 @@ public extension Array { Return a random subset of `cnt` elements from the array. - returns: Returns a random subset of `cnt` elements from the array. */ - public func random(_ count: Int = 1) -> [Element] { + func random(_ count: Int = 1) -> [Element] { let result = shuffled() return (count > result.count) ? result : Array(result[0.. Date: Tue, 4 Jun 2019 16:26:50 -0700 Subject: [PATCH 03/64] Add loading indicator to audio message cell --- Example/Podfile.lock | 6 ++--- Sources/Views/Cells/AudioMessageCell.swift | 31 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 16b0475c..c76c9353 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,6 +1,6 @@ PODS: - InputBarAccessoryView (4.3.0) - - MessageKit (3.0.0-beta-swift5): + - MessageKit (3.1.0): - InputBarAccessoryView (~> 4.3.0) DEPENDENCIES: @@ -16,8 +16,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: InputBarAccessoryView: 28dca73f28df7822fe5377f83cfc4547e22f90ff - MessageKit: 96420f1fe84d037451cc7b11800a559189f40c25 + MessageKit: 72add24fcba6c6ca1e09385285f6f66757340769 PODFILE CHECKSUM: cecdb7bc8129cf99f66de9f68eea3256fec30c3d -COCOAPODS: 1.6.1 +COCOAPODS: 1.7.0 diff --git a/Sources/Views/Cells/AudioMessageCell.swift b/Sources/Views/Cells/AudioMessageCell.swift index a9251ce5..1a37272a 100644 --- a/Sources/Views/Cells/AudioMessageCell.swift +++ b/Sources/Views/Cells/AudioMessageCell.swift @@ -47,18 +47,44 @@ open class AudioMessageCell: MessageContentCell { return durationLabel }() + private lazy var activityIndicatorView: UIActivityIndicatorView = { + let activityIndicatorView = UIActivityIndicatorView(style: .gray) + activityIndicatorView.hidesWhenStopped = true + activityIndicatorView.isHidden = true + return activityIndicatorView + }() + public lazy var progressView: UIProgressView = { let progressView = UIProgressView(progressViewStyle: .default) progressView.progress = 0.0 return progressView }() + public var isLoadingIndicatorVisible: Bool { + get { + return activityIndicatorView.isHidden + } + set { + if newValue { + activityIndicatorView.isHidden = false + playButton.isHidden = true + activityIndicatorView.startAnimating() + } + else { + playButton.isHidden = false + activityIndicatorView.stopAnimating() + } + } + } + // MARK: - Methods /// Responsible for setting up the constraints of the cell's subviews. open func setupConstraints() { playButton.constraint(equalTo: CGSize(width: 25, height: 25)) - playButton.addConstraints(left: messageContainerView.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 5) + playButton.addConstraints(left: messageContainerView.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 10) + activityIndicatorView.constraint(equalTo: CGSize(width: 25, height: 25)) + activityIndicatorView.addConstraints(centerY: playButton.centerYAnchor, centerX: playButton.centerXAnchor) durationLabel.addConstraints(right: messageContainerView.rightAnchor, centerY: messageContainerView.centerYAnchor, rightConstant: 15) progressView.addConstraints(left: playButton.rightAnchor, right: durationLabel.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 5, rightConstant: 5) } @@ -66,6 +92,7 @@ open class AudioMessageCell: MessageContentCell { open override func setupSubviews() { super.setupSubviews() messageContainerView.addSubview(playButton) + messageContainerView.addSubview(activityIndicatorView) messageContainerView.addSubview(durationLabel) messageContainerView.addSubview(progressView) setupConstraints() @@ -75,6 +102,8 @@ open class AudioMessageCell: MessageContentCell { super.prepareForReuse() progressView.progress = 0 playButton.isSelected = false + activityIndicatorView.stopAnimating() + playButton.isHidden = false durationLabel.text = "0:00" } From 78757db1f8082199b1c6cec8d8b7392d2e0e109c Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Tue, 4 Jun 2019 18:47:38 -0700 Subject: [PATCH 04/64] Remove size constraint, ideally there woudl be a >= 0 from all edges just to be safe --- Sources/Views/Cells/AudioMessageCell.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/Views/Cells/AudioMessageCell.swift b/Sources/Views/Cells/AudioMessageCell.swift index 1a37272a..922aa60c 100644 --- a/Sources/Views/Cells/AudioMessageCell.swift +++ b/Sources/Views/Cells/AudioMessageCell.swift @@ -83,7 +83,6 @@ open class AudioMessageCell: MessageContentCell { open func setupConstraints() { playButton.constraint(equalTo: CGSize(width: 25, height: 25)) playButton.addConstraints(left: messageContainerView.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 10) - activityIndicatorView.constraint(equalTo: CGSize(width: 25, height: 25)) activityIndicatorView.addConstraints(centerY: playButton.centerYAnchor, centerX: playButton.centerXAnchor) durationLabel.addConstraints(right: messageContainerView.rightAnchor, centerY: messageContainerView.centerYAnchor, rightConstant: 15) progressView.addConstraints(left: playButton.rightAnchor, right: durationLabel.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 5, rightConstant: 5) From c7c31d67b3cc6fa72bc99691e3c5266a629eee9c Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Tue, 11 Jun 2019 09:41:33 -0700 Subject: [PATCH 05/64] Address comments. --- CHANGELOG.md | 6 ++++++ Sources/Views/Cells/AudioMessageCell.swift | 21 ++------------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aba7f2d..6a2149d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/MessageKit/MessageKit/releases) on GitHub. +## Upcoming Release + +### Added + +- Add loading indicator to AudioMessageCell. [#1084](hub.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry)) + ## 3.0.0 ### Dependency Changes diff --git a/Sources/Views/Cells/AudioMessageCell.swift b/Sources/Views/Cells/AudioMessageCell.swift index 922aa60c..b08d7ad5 100644 --- a/Sources/Views/Cells/AudioMessageCell.swift +++ b/Sources/Views/Cells/AudioMessageCell.swift @@ -47,7 +47,7 @@ open class AudioMessageCell: MessageContentCell { return durationLabel }() - private lazy var activityIndicatorView: UIActivityIndicatorView = { + public lazy var activityIndicatorView: UIActivityIndicatorView = { let activityIndicatorView = UIActivityIndicatorView(style: .gray) activityIndicatorView.hidesWhenStopped = true activityIndicatorView.isHidden = true @@ -59,30 +59,13 @@ open class AudioMessageCell: MessageContentCell { progressView.progress = 0.0 return progressView }() - - public var isLoadingIndicatorVisible: Bool { - get { - return activityIndicatorView.isHidden - } - set { - if newValue { - activityIndicatorView.isHidden = false - playButton.isHidden = true - activityIndicatorView.startAnimating() - } - else { - playButton.isHidden = false - activityIndicatorView.stopAnimating() - } - } - } // MARK: - Methods /// Responsible for setting up the constraints of the cell's subviews. open func setupConstraints() { playButton.constraint(equalTo: CGSize(width: 25, height: 25)) - playButton.addConstraints(left: messageContainerView.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 10) + playButton.addConstraints(left: messageContainerView.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 5) activityIndicatorView.addConstraints(centerY: playButton.centerYAnchor, centerX: playButton.centerXAnchor) durationLabel.addConstraints(right: messageContainerView.rightAnchor, centerY: messageContainerView.centerYAnchor, rightConstant: 15) progressView.addConstraints(left: playButton.rightAnchor, right: durationLabel.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 5, rightConstant: 5) From 0df7a937d52d328be1b3a788ca21f2f8e4feb6de Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Tue, 11 Jun 2019 10:18:05 -0700 Subject: [PATCH 06/64] Add support for styling NSLinkAttribute with existing urlAttributes. --- Sources/Views/MessageLabel.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/Views/MessageLabel.swift b/Sources/Views/MessageLabel.swift index 3ea89490..90a78c05 100644 --- a/Sources/Views/MessageLabel.swift +++ b/Sources/Views/MessageLabel.swift @@ -273,6 +273,11 @@ open class MessageLabel: UILabel { guard let rangeTuples = rangesForDetectors[detector] else { continue } for (range, _) in rangeTuples { + // This will enable us to attribute it with our own styles, since `UILabel` does not provide link attribute overrides like `UITextView` does + if detector.textCheckingType == .link { + mutableAttributedString.removeAttribute(NSAttributedString.Key.link, range: range) + } + let attributes = detectorAttributes(for: detector) mutableAttributedString.addAttributes(attributes, range: range) } From 91e1ca15c8e98b5cffe7b41d760530b6f7db50d9 Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Tue, 11 Jun 2019 10:23:14 -0700 Subject: [PATCH 07/64] Update CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aba7f2d..4bfe51ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ## 3.0.0 +## Upcoming Release + +### Added + +- Add support for styling NSLinkAttribute with existing urlAttributes in MessageLabel. [#1091](https://github.com/MessageKit/MessageKit/pull/1091) by [@marcetcheverry](https://github.com/marcetcheverry) + +## Upcoming Release ### Dependency Changes - **Breaking Change** The dependency `MessageInputBar` was replaced with `InputBarAccessoryView`. As `MessageInputBar` was previously a fork this means no functionality has been lost but improvements and bug fixes will be present. `InputBarAccessoryView` has more of a following outside of `MessageKit` making its development faster than `MessageInputBar`. Maintaining two versions only increased the workload. You can find the changelog for `InputBarAccessoryView` [here](https://github.com/nathantannar4/InputBarAccessoryView/blob/master/CHANGELOG.md). From fbc427f7a3016a5f463998632a07e221105c7a1b Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Wed, 12 Jun 2019 01:10:50 -0700 Subject: [PATCH 08/64] Lazily initialize the messageInputBar for those that don't want to use it. --- Sources/Controllers/MessagesViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index 0e154c4f..db05420f 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -34,7 +34,7 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { open var messagesCollectionView = MessagesCollectionView() /// The `InputBarAccessoryView` used as the `inputAccessoryView` in the view controller. - open var messageInputBar = InputBarAccessoryView() + open lazy var messageInputBar = InputBarAccessoryView() /// A Boolean value that determines whether the `MessagesCollectionView` scrolls to the /// bottom whenever the `InputTextView` begins editing. From 6878b35e035f02a8114d39e0e32a9f112d4b7bcc Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Wed, 12 Jun 2019 01:18:06 -0700 Subject: [PATCH 09/64] Update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aba7f2d..77ee828b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/MessageKit/MessageKit/releases) on GitHub. +## Upcoming Release + +### Added +- Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) + ## 3.0.0 ### Dependency Changes From 4e72543fa00218f19844ccda4cf12db02c09dd3e Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Mon, 17 Jun 2019 17:23:50 -0700 Subject: [PATCH 10/64] Fix a typo in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d26aaf31..d969b110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Added -- Add loading indicator to AudioMessageCell. [#1084](hub.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry)) +- Add loading indicator to AudioMessageCell. [#1084](https://github.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry)) - Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) From 85b3a202902dc2ceb1c0c634ef0d32c0fb7ff616 Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Mon, 17 Jun 2019 17:25:10 -0700 Subject: [PATCH 11/64] Fix second typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d969b110..cbe6a90b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Added -- Add loading indicator to AudioMessageCell. [#1084](https://github.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry)) +- Add loading indicator to AudioMessageCell. [#1084](https://github.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry) - Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) From a0462c1598c741d3068c35ffbf90744c292e6f9e Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Tue, 25 Jun 2019 14:05:27 -0700 Subject: [PATCH 12/64] Fix scrollToBottom not working properly in some cases --- Sources/Views/MessagesCollectionView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/Views/MessagesCollectionView.swift b/Sources/Views/MessagesCollectionView.swift index 22e75474..27ca2d03 100644 --- a/Sources/Views/MessagesCollectionView.swift +++ b/Sources/Views/MessagesCollectionView.swift @@ -101,9 +101,8 @@ open class MessagesCollectionView: UICollectionView { } public func scrollToBottom(animated: Bool = false) { - let collectionViewContentHeight = collectionViewLayout.collectionViewContentSize.height - performBatchUpdates(nil) { _ in + let collectionViewContentHeight = self.collectionViewLayout.collectionViewContentSize.height self.scrollRectToVisible(CGRect(0.0, collectionViewContentHeight - 1.0, 1.0, 1.0), animated: animated) } } From 6528fe7d56c711da6f7510a149192af95beb7004 Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Tue, 25 Jun 2019 14:15:48 -0700 Subject: [PATCH 13/64] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe6a90b..53432857 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa - Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) +### Changed + +- Fixes scrollToBottom method to properly handle calls made early in the view lifecycle. [#1110](https://github.com/MessageKit/MessageKit/pull/1110) by [@marcetcheverry](https://github.com/marcetcheverry) + ## 3.0.0 ### Dependency Changes From 4dd25258a90f8f5bdd0ef71809d6a1ab005efe5f Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Wed, 26 Jun 2019 11:58:03 -0700 Subject: [PATCH 14/64] Add missing cellTopLabelAlignment to MessageSizeCalculator --- Sources/Layout/MessageSizeCalculator.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Layout/MessageSizeCalculator.swift b/Sources/Layout/MessageSizeCalculator.swift index 4cca7e1c..2b95457f 100644 --- a/Sources/Layout/MessageSizeCalculator.swift +++ b/Sources/Layout/MessageSizeCalculator.swift @@ -78,6 +78,7 @@ open class MessageSizeCalculator: CellSizeCalculator { attributes.messageContainerPadding = messageContainerPadding(for: message) attributes.messageContainerSize = messageContainerSize(for: message) attributes.cellTopLabelSize = cellTopLabelSize(for: message, at: indexPath) + attributes.cellTopLabelAlignment = cellTopLabelAlignment(for: message) attributes.cellBottomLabelSize = cellBottomLabelSize(for: message, at: indexPath) attributes.cellBottomLabelAlignment = cellBottomLabelAlignment(for: message) attributes.messageTopLabelSize = messageTopLabelSize(for: message, at: indexPath) From ff9a877f3af0592e7b84da1d38b32422e281767f Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Wed, 26 Jun 2019 12:12:59 -0700 Subject: [PATCH 15/64] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe6a90b..aa8289bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa - Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) +### Changed + +- Add missing cellTopLabelAlignment to MessageSizeCalculator. [#1113](https://github.com/MessageKit/MessageKit/pull/1113) by [@marcetcheverry](https://github.com/marcetcheverry) + ## 3.0.0 ### Dependency Changes From 003ab9c0cedb3c71797a4c2b374665336406b931 Mon Sep 17 00:00:00 2001 From: Mark Descalzo Date: Thu, 27 Jun 2019 09:58:08 -0600 Subject: [PATCH 16/64] Added missing textAlignment and textInsets assignments to layoutcellTopLabel method. --- Sources/Views/Cells/MessageContentCell.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Views/Cells/MessageContentCell.swift b/Sources/Views/Cells/MessageContentCell.swift index 9fdfefeb..629cc272 100644 --- a/Sources/Views/Cells/MessageContentCell.swift +++ b/Sources/Views/Cells/MessageContentCell.swift @@ -267,6 +267,9 @@ open class MessageContentCell: MessageCollectionViewCell { /// Positions the cell's top label. /// - attributes: The `MessagesCollectionViewLayoutAttributes` for the cell. open func layoutCellTopLabel(with attributes: MessagesCollectionViewLayoutAttributes) { + cellTopLabel.textAlignment = attributes.cellTopLabelAlignment.textAlignment + cellTopLabel.textInsets = attributes.cellTopLabelAlignment.textInsets + cellTopLabel.frame = CGRect(origin: .zero, size: attributes.cellTopLabelSize) } From 4859ec5b8c12fa54201254871b26603341c68cee Mon Sep 17 00:00:00 2001 From: Mark Descalzo Date: Thu, 27 Jun 2019 13:31:35 -0600 Subject: [PATCH 17/64] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe6a90b..1c757c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Added +- Add missing textAlignment and textInsets assignments to layoutCellTopLabel method in MessageContentCell. [#1117](https://github.com/MessageKit/MessageKit/pull/1117) by [@mdescalzo](https://github.com/mdescalzo) + - Add loading indicator to AudioMessageCell. [#1084](https://github.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry) - Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) From a89152780213c73a2b45314466c3d7a372e482a9 Mon Sep 17 00:00:00 2001 From: Marc Etcheverry Date: Fri, 28 Jun 2019 19:25:18 -0700 Subject: [PATCH 18/64] Fix CHANGELOG --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bfe51ff..fabeb694 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,14 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/MessageKit/MessageKit/releases) on GitHub. -## 3.0.0 - ## Upcoming Release ### Added - Add support for styling NSLinkAttribute with existing urlAttributes in MessageLabel. [#1091](https://github.com/MessageKit/MessageKit/pull/1091) by [@marcetcheverry](https://github.com/marcetcheverry) -## Upcoming Release +## 3.0.0 + ### Dependency Changes - **Breaking Change** The dependency `MessageInputBar` was replaced with `InputBarAccessoryView`. As `MessageInputBar` was previously a fork this means no functionality has been lost but improvements and bug fixes will be present. `InputBarAccessoryView` has more of a following outside of `MessageKit` making its development faster than `MessageInputBar`. Maintaining two versions only increased the workload. You can find the changelog for `InputBarAccessoryView` [here](https://github.com/nathantannar4/InputBarAccessoryView/blob/master/CHANGELOG.md). From ff704fb78f4b1d88790d30eaf73d9998a7f1ba21 Mon Sep 17 00:00:00 2001 From: Bruno Guidolim Date: Wed, 3 Jul 2019 08:37:15 +0200 Subject: [PATCH 19/64] Set the proper notification to invalidate layout. --- Sources/Layout/MessagesCollectionViewFlowLayout.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Layout/MessagesCollectionViewFlowLayout.swift b/Sources/Layout/MessagesCollectionViewFlowLayout.swift index b5e76738..95ac736d 100644 --- a/Sources/Layout/MessagesCollectionViewFlowLayout.swift +++ b/Sources/Layout/MessagesCollectionViewFlowLayout.swift @@ -89,7 +89,7 @@ open class MessagesCollectionViewFlowLayout: UICollectionViewFlowLayout { } private func setupObserver() { - NotificationCenter.default.addObserver(self, selector: #selector(MessagesCollectionViewFlowLayout.handleOrientationChange(_:)), name: UIDevice.orientationDidChangeNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(MessagesCollectionViewFlowLayout.handleOrientationChange(_:)), name: UIApplication.didChangeStatusBarOrientationNotification, object: nil) } // MARK: - Typing Indicator API From 3998ac11fce275df62c8911ecf2e2ec310c18155 Mon Sep 17 00:00:00 2001 From: Bruno Guidolim Date: Sun, 7 Jul 2019 23:49:54 +0200 Subject: [PATCH 20/64] Added entry to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aba7f2d..22889d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,9 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa - Added `cellBottomLabelSize(for:, at:)` and `cellBottomLabelAlignment(for:)` functions to `MessageSizeCalculator` class. [#920](https://github.com/MessageKit/MessageKit/pull/920) by [@maxxx777](https://github.com/maxxx777) +### Fixed + - Set the proper notification to invalidate layout. MessageKit now relies on `UIApplication` orientation notification instead of `UIDevice`, which invalidates the layout only when it is needed. [#1126](https://github.com/MessageKit/MessageKit/pull/1126) by [@bguidolim](https://github.com/bguidolim) + ## [2.0.0](https://github.com/MessageKit/MessageKit/releases/tag/2.0.0) ### Added From 6d44cdaea3cfd2cb08d69024c34191551453480f Mon Sep 17 00:00:00 2001 From: Bruno Guidolim Date: Mon, 8 Jul 2019 09:47:35 +0200 Subject: [PATCH 21/64] Fixed changelog description --- CHANGELOG.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22889d20..0a90e856 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/MessageKit/MessageKit/releases) on GitHub. +## Upcoming release + +### Fixed + - Set the proper notification to invalidate layout. MessageKit now relies on `UIApplication` orientation notification instead of `UIDevice`, which invalidates the layout only when it is needed. [#1126](https://github.com/MessageKit/MessageKit/pull/1126) by [@bguidolim](https://github.com/bguidolim) + ## 3.0.0 ### Dependency Changes @@ -73,9 +78,6 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa - Added `cellBottomLabelSize(for:, at:)` and `cellBottomLabelAlignment(for:)` functions to `MessageSizeCalculator` class. [#920](https://github.com/MessageKit/MessageKit/pull/920) by [@maxxx777](https://github.com/maxxx777) -### Fixed - - Set the proper notification to invalidate layout. MessageKit now relies on `UIApplication` orientation notification instead of `UIDevice`, which invalidates the layout only when it is needed. [#1126](https://github.com/MessageKit/MessageKit/pull/1126) by [@bguidolim](https://github.com/bguidolim) - ## [2.0.0](https://github.com/MessageKit/MessageKit/releases/tag/2.0.0) ### Added From 57af77527f2a5ed8575c67f988e22f963adc392f Mon Sep 17 00:00:00 2001 From: Domenico Date: Sun, 18 Aug 2019 19:26:07 +0200 Subject: [PATCH 22/64] Added image tapped delegate --- .../View Controllers/ChatViewController.swift | 4 ++++ Sources/Protocols/MessageCellDelegate.swift | 12 ++++++++++++ Sources/Views/Cells/MediaMessageCell.swift | 13 +++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Example/Sources/View Controllers/ChatViewController.swift b/Example/Sources/View Controllers/ChatViewController.swift index 817e8027..71c853ed 100644 --- a/Example/Sources/View Controllers/ChatViewController.swift +++ b/Example/Sources/View Controllers/ChatViewController.swift @@ -195,6 +195,10 @@ extension ChatViewController: MessageCellDelegate { print("Message tapped") } + func didTapImage(in cell: MessageCollectionViewCell) { + print("Image tapped") + } + func didTapCellTopLabel(in cell: MessageCollectionViewCell) { print("Top cell label tapped") } diff --git a/Sources/Protocols/MessageCellDelegate.swift b/Sources/Protocols/MessageCellDelegate.swift index dd07f5d6..db2d7118 100644 --- a/Sources/Protocols/MessageCellDelegate.swift +++ b/Sources/Protocols/MessageCellDelegate.swift @@ -109,6 +109,16 @@ public protocol MessageCellDelegate: MessageLabelDelegate { /// method `messageForItem(at:indexPath:messagesCollectionView)`. func didTapAccessoryView(in cell: MessageCollectionViewCell) + /// Triggered when a tap occurs on the image. + /// + /// - Parameters: + /// - cell: The image where the touch occurred. + /// + /// You can get a reference to the `MessageType` for the cell by using `UICollectionView`'s + /// `indexPath(for: cell)` method. Then using the returned `IndexPath` with the `MessagesDataSource` + /// method `messageForItem(at:indexPath:messagesCollectionView)`. + func didTapImage(in cell: MessageCollectionViewCell) + /// Triggered when a tap occurs on the play button from audio cell. /// /// - Parameters: @@ -164,6 +174,8 @@ public extension MessageCellDelegate { func didTapCellBottomLabel(in cell: MessageCollectionViewCell) {} func didTapMessageTopLabel(in cell: MessageCollectionViewCell) {} + + func didTapImage(in cell: MessageCollectionViewCell) {} func didTapPlayButton(in cell: AudioMessageCell) {} diff --git a/Sources/Views/Cells/MediaMessageCell.swift b/Sources/Views/Cells/MediaMessageCell.swift index d7e1967b..6363e989 100644 --- a/Sources/Views/Cells/MediaMessageCell.swift +++ b/Sources/Views/Cells/MediaMessageCell.swift @@ -81,4 +81,17 @@ open class MediaMessageCell: MessageContentCell { displayDelegate.configureMediaMessageImageView(imageView, for: message, at: indexPath, in: messagesCollectionView) } + + /// Handle tap gesture on contentView and its subviews. + open override func handleTapGesture(_ gesture: UIGestureRecognizer) { + let touchLocation = gesture.location(in: self) + + switch true { + case imageView.frame.contains(touchLocation): + delegate?.didTapImage(in: self) + default: + break + } + } + } From 528cc8197c7b09ae67c71cfa20eac38781908fd1 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Aug 2019 23:05:23 -0400 Subject: [PATCH 23/64] Add custom cell guide. --- CUSTOM_CELLS.md | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CUSTOM_CELLS.md diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md new file mode 100644 index 00000000..d74c39ab --- /dev/null +++ b/CUSTOM_CELLS.md @@ -0,0 +1,76 @@ +# MessageKit Custom Cell Guide(s) + +- [How can I add a custom cell?](#how-can-i-add-a-custom-cell) + +## How can I add a custom cell? + +**Note:** If you choose to use the `.custom` kind you are responsible for all of the cell's layout. Any `UICollectionViewCell` can be returned for custom cells which means any of the styling you provide from the `MessageDisplayDelegate` will not effect your custom cell. Even if you subclass your cell from `MessageContentCell`. + +Creating a custom cell involves four parts. First, you will need to create your custom cell so that it inherits from `UICollectionViewCell`. Second, you will need to set the size of your custom cell by creating a class that inherits from `MessageSizeCalculator`. Third, you will need to add your custom message size calculator to a class you make that inherits from `MessagesCollectionViewFlowLayout`. Fourth, you will need to register your custom cell and reference your custom collection view flow layout. + +### Example + +Let's take a look at what it takes to create a custom cell that displays a red block for your custom message. + +- **1. Custom Cell**: We create a cell that inherits from `UICollectionViewCell` +**MyCustomCell.swift** +``` +open class MyCustomCell: UICollectionViewCell { + open func configure(with message: MessageType, at indexPath: IndexPath, and messagesCollectionView: MessagesCollectionView) { + self.contentView.backgroundColor = UIColor.red + } +} +``` + +- **2. MessageSizeCalculator**: We set the size of our cell by creating a class that inherits from `MessageSizeCalculator` +**CustomMessageSizeCalculator.swift** +``` +open class CustomMessageSizeCalculator: MessageSizeCalculator { + open override func messageContainerSize(for message: MessageType) -> CGSize { + //HERE - Customize to size your content appropriately. This just returns a constant size. + return CGSize(width: 300, height: 130) + } +} +``` + +- **3. MessageFlowLayout**: We add our custom message size calculator to our collection view layout by creating a class that inherits from `MessagesCollectionViewFlowLayout` +**MyCustomMessagesFlowLayout.swift** +``` +open class MyCustomMessagesFlowLayout: MessagesCollectionViewFlowLayout { + lazy open var customMessageSizeCalculator = CustomMessageSizeCalculator(layout: self) + + override open func cellSizeCalculatorForItem(at indexPath: IndexPath) -> CellSizeCalculator { + let message = messagesDataSource.messageForItem(at: indexPath, in: messagesCollectionView) + if case .custom = message.kind { + return customMessageSizeCalculator + } + return super.cellSizeCalculatorForItem(at: indexPath); + } +} +``` +- **4. Implementation**: We register our custom cell and reference our newly created `MyCustomMessagesFlowLayout.swift` +**ConversationViewController.swift** +``` +internal class ConversationViewController: MessagesViewController { + override func viewDidLoad() { + super.viewDidLoad() + messagesCollectionView = MessagesCollectionView(frame: .zero, collectionViewLayout: MyCustomMessagesFlowLayout()) + messagesCollectionView.register(MyCustomCell.self) + //... + } +//... + override open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let messagesDataSource = messagesCollectionView.messagesDataSource else { + fatalError("Ouch. nil data source for messages") + } + + let message = messagesDataSource.messageForItem(at: indexPath, in: messagesCollectionView) + if case .custom = message.kind { + let cell = messagesCollectionView.dequeueReusableCell(MyCustomCell.self, for: indexPath) + cell.configure(with: message, at: indexPath, and: messagesCollectionView) + return cell + } + return super.collectionView(collectionView, cellForItemAt: indexPath) + } +} +``` From 3b52d0f6a12ace3458e571090c58909149a5d26a Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 28 Sep 2019 19:41:48 -0400 Subject: [PATCH 24/64] Update Custom Cell Documentation --- CUSTOM_CELLS.md | 23 ++++++++++++++++------- Example/Podfile.lock | 6 +++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index d74c39ab..4f000c29 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -1,20 +1,26 @@ # MessageKit Custom Cell Guide(s) - [How can I add a custom cell?](#how-can-i-add-a-custom-cell) +- [Issue Reference](#how-can-i-add-a-custom-cell) ## How can I add a custom cell? -**Note:** If you choose to use the `.custom` kind you are responsible for all of the cell's layout. Any `UICollectionViewCell` can be returned for custom cells which means any of the styling you provide from the `MessageDisplayDelegate` will not effect your custom cell. Even if you subclass your cell from `MessageContentCell`. +**Note:** If you choose to use the `.custom` kind you are responsible for all of the cell's layout. You can design the cell in code or Interface Builder. Any `UICollectionViewCell` can be returned for custom cells which means any of the styling you provide from the `MessageDisplayDelegate` will not affect your custom cell, even if you subclass your cell from `MessageContentCell`. -Creating a custom cell involves four parts. First, you will need to create your custom cell so that it inherits from `UICollectionViewCell`. Second, you will need to set the size of your custom cell by creating a class that inherits from `MessageSizeCalculator`. Third, you will need to add your custom message size calculator to a class you make that inherits from `MessagesCollectionViewFlowLayout`. Fourth, you will need to register your custom cell and reference your custom collection view flow layout. +Creating a custom cell involves four parts: +1. Build a cell in Interface Builder or code that inherits from `UICollectionViewCell` +2. Set the size of your cell. Subclass `MessageSizeCalculator` if you want your cell to have the default MessageKit layout design. Subclass `CellSizeCalculator` if you want to further customize your own cell design. The implementation of this class will allow your custom cell to automatically size itself within the `messagesCollectionView`. +3. Add your custom cell size to the collection view flow layout. Subclass `MessagesCollectionViewFlowLayout`, and use the custom message size calculator from step 2, above. +4. Register your custom cell and reference your custom collection view flow layout. -### Example + +### Example: Let's take a look at what it takes to create a custom cell that displays a red block for your custom message. - **1. Custom Cell**: We create a cell that inherits from `UICollectionViewCell` **MyCustomCell.swift** -``` +```swift open class MyCustomCell: UICollectionViewCell { open func configure(with message: MessageType, at indexPath: IndexPath, and messagesCollectionView: MessagesCollectionView) { self.contentView.backgroundColor = UIColor.red @@ -24,7 +30,7 @@ open class MyCustomCell: UICollectionViewCell { - **2. MessageSizeCalculator**: We set the size of our cell by creating a class that inherits from `MessageSizeCalculator` **CustomMessageSizeCalculator.swift** -``` +```swift open class CustomMessageSizeCalculator: MessageSizeCalculator { open override func messageContainerSize(for message: MessageType) -> CGSize { //HERE - Customize to size your content appropriately. This just returns a constant size. @@ -35,7 +41,7 @@ open class CustomMessageSizeCalculator: MessageSizeCalculator { - **3. MessageFlowLayout**: We add our custom message size calculator to our collection view layout by creating a class that inherits from `MessagesCollectionViewFlowLayout` **MyCustomMessagesFlowLayout.swift** -``` +```swift open class MyCustomMessagesFlowLayout: MessagesCollectionViewFlowLayout { lazy open var customMessageSizeCalculator = CustomMessageSizeCalculator(layout: self) @@ -50,7 +56,7 @@ open class MyCustomMessagesFlowLayout: MessagesCollectionViewFlowLayout { ``` - **4. Implementation**: We register our custom cell and reference our newly created `MyCustomMessagesFlowLayout.swift` **ConversationViewController.swift** -``` +```swift internal class ConversationViewController: MessagesViewController { override func viewDidLoad() { super.viewDidLoad() @@ -74,3 +80,6 @@ internal class ConversationViewController: MessagesViewController { } } ``` + +## How can I add a custom cell? +- diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 71bb9fdb..9d32ee67 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,7 +1,7 @@ PODS: - InputBarAccessoryView (4.2.2) - - MessageKit (3.0.0-beta-swift4-2): - - InputBarAccessoryView + - MessageKit (3.0.0): + - InputBarAccessoryView (~> 4.2.2) DEPENDENCIES: - MessageKit (from `../`) @@ -16,7 +16,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: InputBarAccessoryView: 2b937602598e2fab3149f37f51dd7ad795653812 - MessageKit: feb3ca4fa02a14f3391781323ced1da84a0aa73c + MessageKit: b776b77d6f589edca10abdc63b060b804c0de4f4 PODFILE CHECKSUM: cecdb7bc8129cf99f66de9f68eea3256fec30c3d From b5235cc1e7faddc1ac4eda251c7ab5f689a92932 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 28 Sep 2019 19:43:34 -0400 Subject: [PATCH 25/64] Update Custom Cell Documentation --- CUSTOM_CELLS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index 4f000c29..24248028 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -7,7 +7,7 @@ **Note:** If you choose to use the `.custom` kind you are responsible for all of the cell's layout. You can design the cell in code or Interface Builder. Any `UICollectionViewCell` can be returned for custom cells which means any of the styling you provide from the `MessageDisplayDelegate` will not affect your custom cell, even if you subclass your cell from `MessageContentCell`. -Creating a custom cell involves four parts: +**Creating a custom cell involves four parts:** 1. Build a cell in Interface Builder or code that inherits from `UICollectionViewCell` 2. Set the size of your cell. Subclass `MessageSizeCalculator` if you want your cell to have the default MessageKit layout design. Subclass `CellSizeCalculator` if you want to further customize your own cell design. The implementation of this class will allow your custom cell to automatically size itself within the `messagesCollectionView`. 3. Add your custom cell size to the collection view flow layout. Subclass `MessagesCollectionViewFlowLayout`, and use the custom message size calculator from step 2, above. From ff72388625901f56bd8298f45ed0c8c00d40ac39 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 28 Sep 2019 19:47:16 -0400 Subject: [PATCH 26/64] Update Custom Cell Documentation --- CUSTOM_CELLS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index 24248028..ba44347e 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -1,7 +1,7 @@ # MessageKit Custom Cell Guide(s) - [How can I add a custom cell?](#how-can-i-add-a-custom-cell) -- [Issue Reference](#how-can-i-add-a-custom-cell) +- [Issue Reference](#other-custom-cell-guides?) ## How can I add a custom cell? @@ -81,5 +81,5 @@ internal class ConversationViewController: MessagesViewController { } ``` -## How can I add a custom cell? +## Other custom cell guides? - From 2bcc6ea008a057400fab6ed0e03fb3b54a6c888d Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 28 Sep 2019 19:48:30 -0400 Subject: [PATCH 27/64] Update Custom Cell Documentation --- CUSTOM_CELLS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index ba44347e..ce7533d3 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -1,7 +1,7 @@ # MessageKit Custom Cell Guide(s) - [How can I add a custom cell?](#how-can-i-add-a-custom-cell) -- [Issue Reference](#other-custom-cell-guides?) +- [Issue Reference](#other-custom-cell-guides) ## How can I add a custom cell? From db27093302e4e936441007341cf456e0a2f63ce2 Mon Sep 17 00:00:00 2001 From: Vlada Radchenko Date: Tue, 1 Oct 2019 18:30:48 +0300 Subject: [PATCH 28/64] dark mode support --- MessageKit.xcodeproj/project.pbxproj | 4 ++ .../Controllers/MessagesViewController.swift | 3 +- Sources/Extensions/UIColor+Extensions.swift | 41 +++++++++++-- Sources/Extensions/UIColor.swift | 60 +++++++++++++++++++ .../Protocols/MessagesDisplayDelegate.swift | 4 +- Sources/Views/AvatarView.swift | 2 +- Sources/Views/Cells/ContactMessageCell.swift | 4 +- Sources/Views/MessageLabel.swift | 4 +- Sources/Views/MessagesCollectionView.swift | 2 +- Sources/Views/TypingIndicator.swift | 2 +- .../MessagesViewControllerSpec.swift | 2 +- .../MessagesViewControllerTests.swift | 2 +- .../MessagesCollectionViewTests.swift | 2 +- 13 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 Sources/Extensions/UIColor.swift diff --git a/MessageKit.xcodeproj/project.pbxproj b/MessageKit.xcodeproj/project.pbxproj index cfaac857..fc125472 100644 --- a/MessageKit.xcodeproj/project.pbxproj +++ b/MessageKit.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 50FF34572237FE6A0004DCD7 /* UIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FF34562237FE6A0004DCD7 /* UIImage+Extension.swift */; }; 50FF34592237FE850004DCD7 /* ContactMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FF34582237FE840004DCD7 /* ContactMessageCell.swift */; }; 50FF345B2237FE9C0004DCD7 /* ContactMessageSizeCalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FF345A2237FE9C0004DCD7 /* ContactMessageSizeCalculator.swift */; }; + 797AD26423422BDB00E63579 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 797AD26323422BDB00E63579 /* UIColor.swift */; }; 88916B2D1CF0DF2F00469F91 /* MessageKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88916B221CF0DF2F00469F91 /* MessageKit.framework */; }; 8962AC8A1F87AB7D0030B058 /* MessagesCollectionViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8962AC831F87AB230030B058 /* MessagesCollectionViewTests.swift */; }; 8962AC8C1F87AB7D0030B058 /* AvatarViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8962AC851F87AB230030B058 /* AvatarViewTests.swift */; }; @@ -166,6 +167,7 @@ 50FF34562237FE6A0004DCD7 /* UIImage+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+Extension.swift"; sourceTree = ""; }; 50FF34582237FE840004DCD7 /* ContactMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactMessageCell.swift; sourceTree = ""; }; 50FF345A2237FE9C0004DCD7 /* ContactMessageSizeCalculator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactMessageSizeCalculator.swift; sourceTree = ""; }; + 797AD26323422BDB00E63579 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; 88916B221CF0DF2F00469F91 /* MessageKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MessageKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 88916B2C1CF0DF2F00469F91 /* MessageKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MessageKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8962AC741F87AB230030B058 /* MessageKitDateFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageKitDateFormatterTests.swift; sourceTree = ""; }; @@ -406,6 +408,7 @@ B7A03F651F8669EB006AEF79 /* UIColor+Extensions.swift */, B7A03F661F8669EB006AEF79 /* UIView+Extensions.swift */, 1FCA6D2F201C1CC900BC3480 /* UIEdgeInsets+Extensions.swift */, + 797AD26323422BDB00E63579 /* UIColor.swift */, ); path = Extensions; sourceTree = ""; @@ -643,6 +646,7 @@ 38F8063321740D9E00CDB9DB /* BubbleCircle.swift in Sources */, B7A03F5C1F8669CA006AEF79 /* MessageCellDelegate.swift in Sources */, 5073C11D2175BEC60040EAD5 /* AudioMessageSizeCalculator.swift in Sources */, + 797AD26423422BDB00E63579 /* UIColor.swift in Sources */, 1FF377A420087C82004FD648 /* MessageKitError.swift in Sources */, 1F6C040E206A2AF4007BDE44 /* MessageReusableView.swift in Sources */, 388119462253EC30004B26AF /* TypingIndicatorCellSizeCalculator.swift in Sources */, diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index db05420f..bc4bc00e 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -146,9 +146,10 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { private func setupDefaults() { extendedLayoutIncludesOpaqueBars = true automaticallyAdjustsScrollViewInsets = false - view.backgroundColor = .white + view.backgroundColor = .backgroundColor messagesCollectionView.keyboardDismissMode = .interactive messagesCollectionView.alwaysBounceVertical = true + messagesCollectionView.backgroundColor = .backgroundColor } private func setupDelegates() { diff --git a/Sources/Extensions/UIColor+Extensions.swift b/Sources/Extensions/UIColor+Extensions.swift index 0d85ba9e..fb5a1f96 100644 --- a/Sources/Extensions/UIColor+Extensions.swift +++ b/Sources/Extensions/UIColor+Extensions.swift @@ -26,14 +26,43 @@ import Foundation internal extension UIColor { - static let incomingGray = UIColor(red: 230/255, green: 230/255, blue: 235/255, alpha: 1.0) + static var incomingGray: UIColor { + if #available(iOS 13, *) { + return UIColor.systemGray5 + } else { + return UIColor(red: 230/255, green: 230/255, blue: 235/255, alpha: 1.0) + } + } - static let outgoingGreen = UIColor(red: 69/255, green: 214/255, blue: 93/255, alpha: 1.0) + static var outgoingGreen: UIColor { + if #available(iOS 13, *) { + return UIColor.systemGreen + } else { + return UIColor(red: 69/255, green: 214/255, blue: 93/255, alpha: 1.0) + } + } - static let inputBarGray = UIColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1.0) + static var inputBarGray: UIColor { + if #available(iOS 13, *) { + return UIColor.systemGray2 + } else { + return UIColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1.0) + } + } - static let playButtonLightGray = UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1.0) - - static let sendButtonBlue = UIColor(red: 15/255, green: 135/255, blue: 255/255, alpha: 1.0) + static var playButtonLightGray: UIColor { + if #available(iOS 13, *) { + return UIColor.systemGray6 + } else { + return UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1.0) + } + } + static var sendButtonBlue: UIColor { + if #available(iOS 13, *) { + return UIColor.systemBlue + } else { + return UIColor(red: 15/255, green: 135/255, blue: 255/255, alpha: 1.0) + } + } } diff --git a/Sources/Extensions/UIColor.swift b/Sources/Extensions/UIColor.swift new file mode 100644 index 00000000..df18caa7 --- /dev/null +++ b/Sources/Extensions/UIColor.swift @@ -0,0 +1,60 @@ +// +// UIColor.swift +// MessageKit +// +// Created by Vlada Radchenko on 9/30/19. +// Copyright © 2019 MessageKit. All rights reserved. +// + +import Foundation + +extension UIColor { + + static var backgroundColor: UIColor { + if #available(iOS 13, *) { + return systemBackground + } else { + return white + } + } + + static var labelColor: UIColor { + if #available(iOS 13, *) { + return label + } else { + return black + } + } + + static var placeholderTextColor: UIColor { + if #available(iOS 13, *) { + return placeholderText + } else { + return .darkGray + } + } + + static var grayColor: UIColor { + if #available(iOS 13, *) { + return .systemGray + } else { + return gray + } + } + + static var darkTextColor: UIColor { + if #available(iOS 13, *) { + return .systemGray + } else { + return darkText + } + } + + static var lightGrayColor: UIColor { + if #available(iOS 13, *) { + return .systemGray5 + } else { + return .lightGray + } + } +} diff --git a/Sources/Protocols/MessagesDisplayDelegate.swift b/Sources/Protocols/MessagesDisplayDelegate.swift index 29d43e80..70b72fc5 100644 --- a/Sources/Protocols/MessagesDisplayDelegate.swift +++ b/Sources/Protocols/MessagesDisplayDelegate.swift @@ -229,7 +229,7 @@ public extension MessagesDisplayDelegate { case .emoji: return .clear default: - guard let dataSource = messagesCollectionView.messagesDataSource else { return .white } + guard let dataSource = messagesCollectionView.messagesDataSource else { return .backgroundColor } return dataSource.isFromCurrentSender(message: message) ? .outgoingGreen : .incomingGray } } @@ -254,7 +254,7 @@ public extension MessagesDisplayDelegate { guard let dataSource = messagesCollectionView.messagesDataSource else { fatalError(MessageKitError.nilMessagesDataSource) } - return dataSource.isFromCurrentSender(message: message) ? .white : .darkText + return dataSource.isFromCurrentSender(message: message) ? .backgroundColor : .labelColor } func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType] { diff --git a/Sources/Views/AvatarView.swift b/Sources/Views/AvatarView.swift index 6563143e..31a7d363 100644 --- a/Sources/Views/AvatarView.swift +++ b/Sources/Views/AvatarView.swift @@ -161,7 +161,7 @@ open class AvatarView: UIImageView { // MARK: - Internal methods internal func prepareView() { - backgroundColor = .gray + backgroundColor = .grayColor contentMode = .scaleAspectFill layer.masksToBounds = true clipsToBounds = true diff --git a/Sources/Views/Cells/ContactMessageCell.swift b/Sources/Views/Cells/ContactMessageCell.swift index d7f50087..2273a834 100644 --- a/Sources/Views/Cells/ContactMessageCell.swift +++ b/Sources/Views/Cells/ContactMessageCell.swift @@ -34,7 +34,7 @@ open class ContactMessageCell: MessageContentCell { /// The view container that holds contact initials public lazy var initialsContainerView: UIView = { let initialsContainer = UIView(frame: CGRect.zero) - initialsContainer.backgroundColor = .white + initialsContainer.backgroundColor = .backgroundColor return initialsContainer }() @@ -42,7 +42,7 @@ open class ContactMessageCell: MessageContentCell { public lazy var initialsLabel: UILabel = { let initialsLabel = UILabel(frame: CGRect.zero) initialsLabel.textAlignment = .center - initialsLabel.textColor = .darkText + initialsLabel.textColor = .labelColor initialsLabel.font = UIFont.preferredFont(forTextStyle: .footnote) return initialsLabel }() diff --git a/Sources/Views/MessageLabel.swift b/Sources/Views/MessageLabel.swift index 90a78c05..8ae68e86 100644 --- a/Sources/Views/MessageLabel.swift +++ b/Sources/Views/MessageLabel.swift @@ -126,9 +126,9 @@ open class MessageLabel: UILabel { public static var defaultAttributes: [NSAttributedString.Key: Any] = { return [ - NSAttributedString.Key.foregroundColor: UIColor.darkText, + NSAttributedString.Key.foregroundColor: UIColor.darkTextColor, NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue, - NSAttributedString.Key.underlineColor: UIColor.darkText + NSAttributedString.Key.underlineColor: UIColor.darkTextColor ] }() diff --git a/Sources/Views/MessagesCollectionView.swift b/Sources/Views/MessagesCollectionView.swift index 27ca2d03..56cc313a 100644 --- a/Sources/Views/MessagesCollectionView.swift +++ b/Sources/Views/MessagesCollectionView.swift @@ -57,7 +57,7 @@ open class MessagesCollectionView: UICollectionView { public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { super.init(frame: frame, collectionViewLayout: layout) - backgroundColor = .white + backgroundColor = .backgroundColor registerReusableViews() setupGestureRecognizers() } diff --git a/Sources/Views/TypingIndicator.swift b/Sources/Views/TypingIndicator.swift index 60872b37..ff007c3d 100644 --- a/Sources/Views/TypingIndicator.swift +++ b/Sources/Views/TypingIndicator.swift @@ -33,7 +33,7 @@ open class TypingIndicator: UIView { public var bounceOffset: CGFloat = 2.5 /// A convenience accessor for the `backgroundColor` of each dot - open var dotColor: UIColor = UIColor.lightGray { + open var dotColor: UIColor = UIColor.lightGrayColor { didSet { dots.forEach { $0.backgroundColor = dotColor } } diff --git a/Tests/ControllersTest/MessagesViewControllerSpec.swift b/Tests/ControllersTest/MessagesViewControllerSpec.swift index 77c4de4c..5717fb32 100644 --- a/Tests/ControllersTest/MessagesViewControllerSpec.swift +++ b/Tests/ControllersTest/MessagesViewControllerSpec.swift @@ -70,7 +70,7 @@ final class MessagesViewControllerSpec: QuickSpec { expect(controller.extendedLayoutIncludesOpaqueBars).to(beTrue()) } it("sets the background color to be white") { - expect(controller.view.backgroundColor).to(be(UIColor.white)) + expect(controller.view.backgroundColor).to(be(UIColor.backgroundColor)) } it("sets keyboardDismissMode to .interactive") { let dismissMode = controller.messagesCollectionView.keyboardDismissMode diff --git a/Tests/ControllersTest/MessagesViewControllerTests.swift b/Tests/ControllersTest/MessagesViewControllerTests.swift index 640bbacd..c5f9f67e 100644 --- a/Tests/ControllersTest/MessagesViewControllerTests.swift +++ b/Tests/ControllersTest/MessagesViewControllerTests.swift @@ -105,7 +105,7 @@ class MessagesViewControllerTests: XCTestCase { func testCellForItemWithAttributedTextData_returnsTextMessageCell() { let messagesDataSource = MockMessagesDataSource() sut.messagesCollectionView.messagesDataSource = messagesDataSource - let attributes = [NSAttributedString.Key.foregroundColor: UIColor.black] + let attributes = [NSAttributedString.Key.foregroundColor: UIColor.labelColor] let attriutedString = NSAttributedString(string: "Test", attributes: attributes) messagesDataSource.messages.append(MockMessage(attributedText: attriutedString, user: messagesDataSource.senders[0], diff --git a/Tests/ViewsTests/MessagesCollectionViewTests.swift b/Tests/ViewsTests/MessagesCollectionViewTests.swift index a42fa54d..31d515f0 100644 --- a/Tests/ViewsTests/MessagesCollectionViewTests.swift +++ b/Tests/ViewsTests/MessagesCollectionViewTests.swift @@ -44,7 +44,7 @@ class MessagesCollectionViewTests: XCTestCase { func testInit() { XCTAssertEqual(messagesCollectionView.frame, rect) XCTAssertEqual(messagesCollectionView.collectionViewLayout, layout) - XCTAssertEqual(messagesCollectionView.backgroundColor, .white) + XCTAssertEqual(messagesCollectionView.backgroundColor, .backgroundColor) } } From 18f4c26be7aaac591b06d74f848d5202610f7c40 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 5 Oct 2019 18:19:34 -0400 Subject: [PATCH 29/64] Edit Custom Cell Documentation --- CUSTOM_CELLS.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index ce7533d3..6d72779e 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -1,7 +1,6 @@ # MessageKit Custom Cell Guide(s) - [How can I add a custom cell?](#how-can-i-add-a-custom-cell) -- [Issue Reference](#other-custom-cell-guides) ## How can I add a custom cell? @@ -33,7 +32,8 @@ open class MyCustomCell: UICollectionViewCell { ```swift open class CustomMessageSizeCalculator: MessageSizeCalculator { open override func messageContainerSize(for message: MessageType) -> CGSize { - //HERE - Customize to size your content appropriately. This just returns a constant size. + // Customize this function implementation to size your content appropriately. This example simply returns a constant size + // Refer to the default MessageKit cell implementations, and the Example App to see how to size a custom cell dynamically return CGSize(width: 300, height: 130) } } @@ -80,6 +80,3 @@ internal class ConversationViewController: MessagesViewController { } } ``` - -## Other custom cell guides? -- From 5512d22e00530ddd80b804615d552c0d8d3ae965 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 5 Oct 2019 18:24:44 -0400 Subject: [PATCH 30/64] Edit Custom Cell Documentation --- CUSTOM_CELLS.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index 6d72779e..98376f58 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -32,8 +32,7 @@ open class MyCustomCell: UICollectionViewCell { ```swift open class CustomMessageSizeCalculator: MessageSizeCalculator { open override func messageContainerSize(for message: MessageType) -> CGSize { - // Customize this function implementation to size your content appropriately. This example simply returns a constant size - // Refer to the default MessageKit cell implementations, and the Example App to see how to size a custom cell dynamically + // HERE return CGSize(width: 300, height: 130) } } From 16e6ee5d4f69b1226074a78d8c1d843356452d9e Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 5 Oct 2019 18:25:25 -0400 Subject: [PATCH 31/64] Edit Custom Cell Documentation --- CUSTOM_CELLS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index 98376f58..6d72779e 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -32,7 +32,8 @@ open class MyCustomCell: UICollectionViewCell { ```swift open class CustomMessageSizeCalculator: MessageSizeCalculator { open override func messageContainerSize(for message: MessageType) -> CGSize { - // HERE + // Customize this function implementation to size your content appropriately. This example simply returns a constant size + // Refer to the default MessageKit cell implementations, and the Example App to see how to size a custom cell dynamically return CGSize(width: 300, height: 130) } } From 95b0f34d4716c5055d46d0ea8e916f6e543e0e03 Mon Sep 17 00:00:00 2001 From: HShah Date: Tue, 15 Oct 2019 22:35:04 +0200 Subject: [PATCH 32/64] Removed the redandunt access modifiers --- Example/Sources/Data Generation/Lorem.swift | 8 ++++---- Sources/Controllers/MessagesViewController+Keyboard.swift | 8 ++++---- Sources/Controllers/MessagesViewController+Menu.swift | 4 ++-- Sources/Extensions/UIImage+Extension.swift | 2 +- Sources/Extensions/UIView+Extensions.swift | 2 +- Sources/Models/HorizontalEdgeInsets.swift | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Example/Sources/Data Generation/Lorem.swift b/Example/Sources/Data Generation/Lorem.swift index 47597730..b368af71 100755 --- a/Example/Sources/Data Generation/Lorem.swift +++ b/Example/Sources/Data Generation/Lorem.swift @@ -222,7 +222,7 @@ public extension Array { /** Shuffle the array in-place using the Fisher-Yates algorithm. */ - public mutating func shuffle() { + mutating func shuffle() { for i in 0..<(count - 1) { let j = Int(arc4random_uniform(UInt32(count - i))) + i if j != i { @@ -237,7 +237,7 @@ public extension Array { - returns: Returns a shuffled version of the array. */ - public func shuffled() -> [Element] { + func shuffled() -> [Element] { var list = self list.shuffle() @@ -249,7 +249,7 @@ public extension Array { - returns: Returns a random element from the array or `nil` if the array is empty. */ - public func random() -> Element? { + func random() -> Element? { return (count > 0) ? self.shuffled()[0] : nil } @@ -257,7 +257,7 @@ public extension Array { Return a random subset of `cnt` elements from the array. - returns: Returns a random subset of `cnt` elements from the array. */ - public func random(_ count: Int = 1) -> [Element] { + func random(_ count: Int = 1) -> [Element] { let result = shuffled() return (count > result.count) ? result : Array(result[0.. CGFloat { + func requiredInitialScrollViewBottomInset() -> CGFloat { guard let inputAccessoryView = inputAccessoryView else { return 0 } return max(0, inputAccessoryView.frame.height + additionalBottomInset - automaticallyAddedBottomInset) } diff --git a/Sources/Controllers/MessagesViewController+Menu.swift b/Sources/Controllers/MessagesViewController+Menu.swift index fefe53ee..9a02f20b 100644 --- a/Sources/Controllers/MessagesViewController+Menu.swift +++ b/Sources/Controllers/MessagesViewController+Menu.swift @@ -28,11 +28,11 @@ internal extension MessagesViewController { // MARK: - Register / Unregister Observers - internal func addMenuControllerObservers() { + func addMenuControllerObservers() { NotificationCenter.default.addObserver(self, selector: #selector(MessagesViewController.menuControllerWillShow(_:)), name: UIMenuController.willShowMenuNotification, object: nil) } - internal func removeMenuControllerObservers() { + func removeMenuControllerObservers() { NotificationCenter.default.removeObserver(self, name: UIMenuController.willShowMenuNotification, object: nil) } diff --git a/Sources/Extensions/UIImage+Extension.swift b/Sources/Extensions/UIImage+Extension.swift index 157fd0f4..5195a1e7 100644 --- a/Sources/Extensions/UIImage+Extension.swift +++ b/Sources/Extensions/UIImage+Extension.swift @@ -33,7 +33,7 @@ import UIKit /// This extension provide a way to access image resources with in framework public extension UIImage { - public class func messageKitImageWith(type: ImageType) -> UIImage? { + class func messageKitImageWith(type: ImageType) -> UIImage? { let assetBundle = Bundle.messageKitAssetBundle() let imagePath = assetBundle.path(forResource: type.rawValue, ofType: "png", inDirectory: "Images") let image = UIImage(contentsOfFile: imagePath ?? "") diff --git a/Sources/Extensions/UIView+Extensions.swift b/Sources/Extensions/UIView+Extensions.swift index ec01877f..1a3e4202 100644 --- a/Sources/Extensions/UIView+Extensions.swift +++ b/Sources/Extensions/UIView+Extensions.swift @@ -67,7 +67,7 @@ internal extension UIView { } @discardableResult - internal func addConstraints(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, centerY: NSLayoutYAxisAnchor? = nil, centerX: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, centerYConstant: CGFloat = 0, centerXConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) -> [NSLayoutConstraint] { + func addConstraints(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, centerY: NSLayoutYAxisAnchor? = nil, centerX: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, centerYConstant: CGFloat = 0, centerXConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) -> [NSLayoutConstraint] { if self.superview == nil { return [] diff --git a/Sources/Models/HorizontalEdgeInsets.swift b/Sources/Models/HorizontalEdgeInsets.swift index a1bf6740..c82141c6 100644 --- a/Sources/Models/HorizontalEdgeInsets.swift +++ b/Sources/Models/HorizontalEdgeInsets.swift @@ -49,7 +49,7 @@ public extension HorizontalEdgeInsets { internal extension HorizontalEdgeInsets { - internal var horizontal: CGFloat { + var horizontal: CGFloat { return left + right } } From 8f36baaf6f8909bca8171d07093e78ab3c92b566 Mon Sep 17 00:00:00 2001 From: Kino Date: Thu, 17 Oct 2019 19:02:56 -0700 Subject: [PATCH 33/64] Fixes @available annotations to correctly report deprecation/obsoletion --- Sources/Models/Sender.swift | 6 +++--- Sources/Supporting/MessageInputBar.swift | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Models/Sender.swift b/Sources/Models/Sender.swift index 28468785..7ef3f387 100644 --- a/Sources/Models/Sender.swift +++ b/Sources/Models/Sender.swift @@ -25,7 +25,7 @@ import Foundation /// An object that groups the metadata of a messages sender. -@available(*, deprecated: 3.0.0, message: "`Sender` has been replaced with the `SenderType` protocol in 3.0.0") +@available(*, deprecated, message: "`Sender` has been replaced with the `SenderType` protocol in 3.0.0") public struct Sender: SenderType { /// MARK: - Properties @@ -35,7 +35,7 @@ public struct Sender: SenderType { /// Note: This value must be unique across all senders. public let senderId: String - @available(*, deprecated: 3.0.0, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") + @available(*, deprecated, renamed: "senderId", message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") public var id: String { return senderId } @@ -50,7 +50,7 @@ public struct Sender: SenderType { self.displayName = displayName } - @available(*, deprecated: 3.0.0, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") + @available(*, deprecated, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") public init(id: String, displayName: String) { self.init(senderId: id, displayName: displayName) } diff --git a/Sources/Supporting/MessageInputBar.swift b/Sources/Supporting/MessageInputBar.swift index 575edd50..2e7652f2 100644 --- a/Sources/Supporting/MessageInputBar.swift +++ b/Sources/Supporting/MessageInputBar.swift @@ -25,10 +25,10 @@ import UIKit import InputBarAccessoryView -@available(*, obsoleted: 3.0.0, renamed: "InputBarAccessoryView") +@available(*, unavailable, renamed: "InputBarAccessoryView") public typealias MessageInputBar = InputBarAccessoryView -@available(*, obsoleted: 3.0.0, renamed: "InputBarAccessoryViewDelegate") +@available(*, unavailable, renamed: "InputBarAccessoryViewDelegate") public typealias MessageInputBarDelegate = InputBarAccessoryViewDelegate //public extension MessageInputBarDelegate { From 2f5377603a0a60e55eea32ebd18662a5dd98f061 Mon Sep 17 00:00:00 2001 From: Alex <627353+Alexander-Frost@users.noreply.github.com> Date: Tue, 29 Oct 2019 21:41:49 -0400 Subject: [PATCH 34/64] Update CUSTOM_CELLS.md Co-Authored-By: Austin Wright --- CUSTOM_CELLS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CUSTOM_CELLS.md b/CUSTOM_CELLS.md index 6d72779e..bdff909a 100644 --- a/CUSTOM_CELLS.md +++ b/CUSTOM_CELLS.md @@ -34,7 +34,7 @@ open class CustomMessageSizeCalculator: MessageSizeCalculator { open override func messageContainerSize(for message: MessageType) -> CGSize { // Customize this function implementation to size your content appropriately. This example simply returns a constant size // Refer to the default MessageKit cell implementations, and the Example App to see how to size a custom cell dynamically - return CGSize(width: 300, height: 130) + return CGSize(width: 300, height: 130) } } ``` From fb4d9cc0e58ca4f80825f6083b3217524827777b Mon Sep 17 00:00:00 2001 From: Andrew Abosh Date: Wed, 20 Nov 2019 11:39:22 -0500 Subject: [PATCH 35/64] Fixed requiredInitialScrollViewBottomInset not returning the correct value when inputAccessoryView is nil --- Sources/Controllers/MessagesViewController+Keyboard.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 510828ae..7e2cc499 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -122,8 +122,8 @@ internal extension MessagesViewController { } internal func requiredInitialScrollViewBottomInset() -> CGFloat { - guard let inputAccessoryView = inputAccessoryView else { return 0 } - return max(0, inputAccessoryView.frame.height + additionalBottomInset - automaticallyAddedBottomInset) + let inputAccessoryViewHeight = inputAccessoryView?.frame.height ?? 0 + return max(0, inputAccessoryViewHeight + additionalBottomInset - automaticallyAddedBottomInset) } /// iOS 11's UIScrollView can automatically add safe area insets to its contentInset, From 07d9c7788aed951b4a93679a5eb79d36a1d442ae Mon Sep 17 00:00:00 2001 From: hyouuu Date: Sun, 16 Feb 2020 22:05:43 -0800 Subject: [PATCH 36/64] Apply https://github.com/MessageKit/MessageKit/pull/1217 to dev --- Sources/Controllers/MessagesViewController+Keyboard.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 0590a38e..29b786a1 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -63,6 +63,11 @@ internal extension MessagesViewController { return } + guard self.presentedViewController == nil else { + // This is important to skip notifications from child modal controllers in iOS >= 13.0 + return + } + // Note that the check above does not exclude all notifications from an undocked keyboard, only the weird ones. // // We've tried following Apple's recommended approach of tracking UIKeyboardWillShow / UIKeyboardDidHide and ignoring frame From b85389cad1cf29a8fc81256b6f933b13295caff7 Mon Sep 17 00:00:00 2001 From: hyouuu Date: Sun, 16 Feb 2020 22:15:21 -0800 Subject: [PATCH 37/64] Update circle to use Xcode 11 --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e2a5ffbc..69c219d4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,11 +8,11 @@ jobs: build-and-test: environment: - - DESTINATION: "platform=iOS Simulator,name=iPhone XS" + - DESTINATION: "platform=iOS Simulator,name=iPhone 11 Pro" # Specify the Xcode version to use. macos: - xcode: "10.2.0" + xcode: "11.3.1" # Define the steps required to build the project. steps: From ec18b24a5407cb05c0771c1c316274eff9a695cb Mon Sep 17 00:00:00 2001 From: hyouuu Date: Mon, 17 Feb 2020 00:12:05 -0800 Subject: [PATCH 38/64] Downsize logo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0c2d77f..91abe47c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

- +

- +

[![CircleCI](https://circleci.com/gh/MessageKit/MessageKit.svg?style=svg)](https://circleci.com/gh/MessageKit/MessageKit) From fb41e3d0a461b699ccfe80a3579fc41de327d430 Mon Sep 17 00:00:00 2001 From: hyouuu Date: Mon, 17 Feb 2020 00:13:42 -0800 Subject: [PATCH 39/64] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 91abe47c..e246c887 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

- +

- +

[![CircleCI](https://circleci.com/gh/MessageKit/MessageKit.svg?style=svg)](https://circleci.com/gh/MessageKit/MessageKit) From 6dc34d4e0ab07be91b6dc1f1515d613d479934b9 Mon Sep 17 00:00:00 2001 From: hyouuu Date: Mon, 17 Feb 2020 00:14:22 -0800 Subject: [PATCH 40/64] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e246c887..7a00c00a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

- +

- +

[![CircleCI](https://circleci.com/gh/MessageKit/MessageKit.svg?style=svg)](https://circleci.com/gh/MessageKit/MessageKit) From d36568e5ab070c558831e0c53ca6128642f1be0d Mon Sep 17 00:00:00 2001 From: hyouuu Date: Mon, 17 Feb 2020 00:31:52 -0800 Subject: [PATCH 41/64] Add scrollToLastItem --- Sources/Views/MessagesCollectionView.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/Views/MessagesCollectionView.swift b/Sources/Views/MessagesCollectionView.swift index 56cc313a..2658b832 100644 --- a/Sources/Views/MessagesCollectionView.swift +++ b/Sources/Views/MessagesCollectionView.swift @@ -100,8 +100,24 @@ open class MessagesCollectionView: UICollectionView { cell?.handleTapGesture(gesture) } + // NOTE: It's possible for small content size this wouldn't work - https://github.com/MessageKit/MessageKit/issues/725 + public func scrollToLastItem(at pos: UICollectionView.ScrollPosition = .centeredVertically, animated: Bool = true) { + guard numberOfSections > 0 else { return } + + let lastSection = numberOfSections - 1 + let lastItem = numberOfItems(inSection: lastSection) - 1 + + guard lastItem >= 0 else { return } + + let indexPath = IndexPath(row: lastItem, section: lastSection) + scrollToItem(at: indexPath, at: pos, animated: animated) + } + + // NOTE: This method seems to cause crash in certain cases - https://github.com/MessageKit/MessageKit/issues/725 + // Could try using `scrollToLastItem` above public func scrollToBottom(animated: Bool = false) { - performBatchUpdates(nil) { _ in + performBatchUpdates(nil) { [weak self] _ in + guard let self = self else { return } let collectionViewContentHeight = self.collectionViewLayout.collectionViewContentSize.height self.scrollRectToVisible(CGRect(0.0, collectionViewContentHeight - 1.0, 1.0, 1.0), animated: animated) } From a3cb5aeaa60a98c6ef7200ffaa349a2e53aa4c41 Mon Sep 17 00:00:00 2001 From: hyouuu Date: Mon, 17 Feb 2020 00:32:46 -0800 Subject: [PATCH 42/64] Add scrollsToLastItemOnKeyboardBeginsEditing flag --- Sources/Controllers/MessagesViewController.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index bc4bc00e..982a2df5 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -36,10 +36,18 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { /// The `InputBarAccessoryView` used as the `inputAccessoryView` in the view controller. open lazy var messageInputBar = InputBarAccessoryView() + /// A Boolean value that determines whether the `MessagesCollectionView` scrolls to the + /// last item whenever the `InputTextView` begins editing. + /// + /// The default value of this property is `false`. + /// NOTE: This calls scrollToLastItem where as the below flag calls scrollToBottome - check methods for differences + open var scrollsToLastItemOnKeyboardBeginsEditing: Bool = false + /// A Boolean value that determines whether the `MessagesCollectionView` scrolls to the /// bottom whenever the `InputTextView` begins editing. /// /// The default value of this property is `false`. + /// NOTE: This calls scrollToBottome where as the above flag calls scrollToLastItem - check methods for differences open var scrollsToBottomOnKeyboardBeginsEditing: Bool = false /// A Boolean value that determines whether the `MessagesCollectionView` From 4d0350e96c2952a7fb930d449ce56e05a5d8384d Mon Sep 17 00:00:00 2001 From: hyouuu Date: Mon, 17 Feb 2020 00:33:27 -0800 Subject: [PATCH 43/64] Check scrollsToLastItemOnKeyboardBeginsEditing and scroll on begin editing --- .../MessagesViewController+Keyboard.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 29b786a1..7ec0be14 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -45,9 +45,15 @@ internal extension MessagesViewController { @objc private func handleTextViewDidBeginEditing(_ notification: Notification) { - if scrollsToBottomOnKeyboardBeginsEditing { - guard let inputTextView = notification.object as? InputTextView, inputTextView === messageInputBar.inputTextView else { return } - messagesCollectionView.scrollToBottom(animated: true) + if scrollsToLastItemOnKeyboardBeginsEditing || scrollsToBottomOnKeyboardBeginsEditing { + guard let inputTextView = notification.object as? InputTextView, + inputTextView === messageInputBar.inputTextView else { return } + + if scrollsToLastItemOnKeyboardBeginsEditing { + messagesCollectionView.scrollToLastItem() + } else { + messagesCollectionView.scrollToBottom(animated: true) + } } } From d1233de07132dee05fd948f74a37e59bff462839 Mon Sep 17 00:00:00 2001 From: hyouuu Date: Mon, 17 Feb 2020 01:27:07 -0800 Subject: [PATCH 44/64] default pos to bottom --- Sources/Views/MessagesCollectionView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Views/MessagesCollectionView.swift b/Sources/Views/MessagesCollectionView.swift index 2658b832..ce960897 100644 --- a/Sources/Views/MessagesCollectionView.swift +++ b/Sources/Views/MessagesCollectionView.swift @@ -101,7 +101,7 @@ open class MessagesCollectionView: UICollectionView { } // NOTE: It's possible for small content size this wouldn't work - https://github.com/MessageKit/MessageKit/issues/725 - public func scrollToLastItem(at pos: UICollectionView.ScrollPosition = .centeredVertically, animated: Bool = true) { + public func scrollToLastItem(at pos: UICollectionView.ScrollPosition = .bottom, animated: Bool = true) { guard numberOfSections > 0 else { return } let lastSection = numberOfSections - 1 From fa0b2c3e443a9f667eee7a67b462d4d4884fd112 Mon Sep 17 00:00:00 2001 From: Andrew Abosh Date: Mon, 17 Feb 2020 15:26:25 -0500 Subject: [PATCH 45/64] Revert "Merge remote-tracking branch 'origin/development'" This reverts commit 2e5479032ecfe4444756bb040a732c0deb443d3a, reversing changes made to fb4d9cc0e58ca4f80825f6083b3217524827777b. --- .circleci/config.yml | 2 +- .swift-version | 2 +- .swiftlint.yml | 1 + CHANGELOG.md | 22 -------------- Cartfile | 2 +- Cartfile.private | 2 +- Cartfile.resolved | 6 ++-- Example/.Podfile.un~ | Bin 0 -> 628 bytes Example/ChatExample.xcodeproj/project.pbxproj | 21 ++++++-------- .../xcschemes/ChatExample.xcscheme | 2 +- .../xcschemes/ChatExampleUITests.xcscheme | 2 +- Example/Podfile.lock | 12 ++++---- Example/Podfile~ | 16 +++++++++++ Example/Sources/Data Generation/Lorem.swift | 8 +++--- MessageKit.podspec | 8 +++--- MessageKit.xcodeproj/project.pbxproj | 10 +++---- .../xcschemes/MessageKit.xcscheme | 2 +- .../xcschemes/MessageKitTests.xcscheme | 2 +- .../MessagesViewController+Keyboard.swift | 8 +++--- .../MessagesViewController+Menu.swift | 4 +-- .../Controllers/MessagesViewController.swift | 2 +- Sources/Extensions/Bundle+Extensions.swift | 2 +- Sources/Extensions/CGRect+Extensions.swift | 2 +- .../NSAttributedString+Extensions.swift | 2 +- Sources/Extensions/UIColor+Extensions.swift | 2 ++ .../Extensions/UIEdgeInsets+Extensions.swift | 2 ++ Sources/Extensions/UIImage+Extension.swift | 2 +- Sources/Extensions/UIView+Extensions.swift | 4 ++- Sources/Layout/MessageSizeCalculator.swift | 1 - .../MessagesCollectionViewFlowLayout.swift | 2 +- Sources/Models/AvatarPosition.swift | 2 +- Sources/Models/DetectorType.swift | 4 +-- Sources/Models/HorizontalEdgeInsets.swift | 4 +-- Sources/Models/Sender.swift | 6 ++-- Sources/Supporting/MessageInputBar.swift | 27 ++++++++++++++++-- Sources/Views/Cells/AudioMessageCell.swift | 13 +-------- Sources/Views/Cells/MessageContentCell.swift | 3 -- Sources/Views/MessageLabel.swift | 5 ---- Sources/Views/MessagesCollectionView.swift | 3 +- 39 files changed, 110 insertions(+), 110 deletions(-) create mode 100644 Example/.Podfile.un~ create mode 100644 Example/Podfile~ diff --git a/.circleci/config.yml b/.circleci/config.yml index e2a5ffbc..e4c9ab21 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ jobs: # Specify the Xcode version to use. macos: - xcode: "10.2.0" + xcode: "10.0.0" # Define the steps required to build the project. steps: diff --git a/.swift-version b/.swift-version index 819e07a2..bf77d549 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -5.0 +4.2 diff --git a/.swiftlint.yml b/.swiftlint.yml index 5ebf9e77..8bf8a3da 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -12,6 +12,7 @@ custom_rules: message: "Use like open override or public override instead" # violation message. optional. severity: warning # violation severity. optional. opt_in_rules: + - explicit_acl - explicit_top_level_acl explicit_acl: error explicit_top_level_acl: error diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c1dcf8..7aba7f2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,28 +2,6 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/MessageKit/MessageKit/releases) on GitHub. -## Upcoming release - -### Fixed - - - Set the proper notification to invalidate layout. MessageKit now relies on `UIApplication` orientation notification instead of `UIDevice`, which invalidates the layout only when it is needed. [#1126](https://github.com/MessageKit/MessageKit/pull/1126) by [@bguidolim](https://github.com/bguidolim) - -### Added - -- Add missing textAlignment and textInsets assignments to layoutCellTopLabel method in MessageContentCell. [#1117](https://github.com/MessageKit/MessageKit/pull/1117) by [@mdescalzo](https://github.com/mdescalzo) - -- Add support for styling NSLinkAttribute with existing urlAttributes in MessageLabel. [#1091](https://github.com/MessageKit/MessageKit/pull/1091) by [@marcetcheverry](https://github.com/marcetcheverry) - -- Add loading indicator to AudioMessageCell. [#1084](https://github.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry) - -- Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) - -### Changed - -- Fixes scrollToBottom method to properly handle calls made early in the view lifecycle. [#1110](https://github.com/MessageKit/MessageKit/pull/1110) by [@marcetcheverry](https://github.com/marcetcheverry) - -- Add missing cellTopLabelAlignment to MessageSizeCalculator. [#1113](https://github.com/MessageKit/MessageKit/pull/1113) by [@marcetcheverry](https://github.com/marcetcheverry) - ## 3.0.0 ### Dependency Changes diff --git a/Cartfile b/Cartfile index ed7bec6d..50814158 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nathantannar4/InputBarAccessoryView" "4.3.0" +github "nathantannar4/InputBarAccessoryView" "4.2.1" diff --git a/Cartfile.private b/Cartfile.private index 29d169d6..70f82c40 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ github "Quick/Quick" ~> 2.0.0 -github "Quick/Nimble" ~> 8.0.0 +github "Quick/Nimble" ~> 8.0.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 7acd3164..de18a3b8 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "Quick/Nimble" "v8.0.1" -github "Quick/Quick" "v2.0.0" -github "nathantannar4/InputBarAccessoryView" "4.3.0" +github "Quick/Nimble" "v7.3.4" +github "Quick/Quick" "v1.3.4" +github "nathantannar4/InputBarAccessoryView" "4.2.2" diff --git a/Example/.Podfile.un~ b/Example/.Podfile.un~ new file mode 100644 index 0000000000000000000000000000000000000000..8e635e873c954879ae48535cb0638240cdf80041 GIT binary patch literal 628 zcmWH`%$*;a=aT=FfvJX1uI8zJ&VRp+HftVn-1)vg!s@o?+VAtHCSSQEcItls0|Ns; z5F-OdAP0m&0LBLMV~T~MSRf+t7a;N|BuI)4Ch{K$;KslNM`@Md~^VR_U1~3bu9%>KP>^1;tkS`aph0 sX_8)Yey%=LwRdI-j0w}I2UG>poK%#Umz)9CpPN`*l3Jv0+W34G05;o29{>OV literal 0 HcmV?d00001 diff --git a/Example/ChatExample.xcodeproj/project.pbxproj b/Example/ChatExample.xcodeproj/project.pbxproj index bfff37ea..86d703d4 100644 --- a/Example/ChatExample.xcodeproj/project.pbxproj +++ b/Example/ChatExample.xcodeproj/project.pbxproj @@ -371,7 +371,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = MessageKit; TargetAttributes = { 882B5E321CF7D4B900B6E160 = { @@ -394,7 +394,6 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -604,7 +603,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -653,7 +651,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -662,7 +660,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -703,7 +700,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -720,7 +717,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -736,7 +733,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -749,7 +746,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample"; }; name = Debug; @@ -764,7 +761,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample"; }; name = Release; @@ -777,7 +774,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; TEST_TARGET_NAME = ChatExample; }; name = Debug; @@ -791,7 +788,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; TEST_TARGET_NAME = ChatExample; }; name = Release; diff --git a/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme b/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme index 31f17b89..e34206a1 100644 --- a/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme +++ b/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme @@ -1,6 +1,6 @@ 4.3.0) + - InputBarAccessoryView (4.2.2) + - MessageKit (3.0.0-beta-swift4-2): + - InputBarAccessoryView DEPENDENCIES: - MessageKit (from `../`) @@ -15,9 +15,9 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - InputBarAccessoryView: 28dca73f28df7822fe5377f83cfc4547e22f90ff - MessageKit: 72add24fcba6c6ca1e09385285f6f66757340769 + InputBarAccessoryView: 2b937602598e2fab3149f37f51dd7ad795653812 + MessageKit: feb3ca4fa02a14f3391781323ced1da84a0aa73c PODFILE CHECKSUM: cecdb7bc8129cf99f66de9f68eea3256fec30c3d -COCOAPODS: 1.7.0 +COCOAPODS: 1.6.1 diff --git a/Example/Podfile~ b/Example/Podfile~ new file mode 100644 index 00000000..bf44d23b --- /dev/null +++ b/Example/Podfile~ @@ -0,0 +1,16 @@ +platform :ios, '9.0' + +target 'ChatExample' do + use_frameworks! + pod 'MessageKit', :path => '../' + pod 'MessageInputBar', :git => 'https://github.com/MessageKit/MessageInputBar.git', :branch => 'master' + +target 'ChatExampleTests' do + inherit! :search_paths +end + +target 'ChatExampleUITests' do + inherit! :search_paths +end + +end diff --git a/Example/Sources/Data Generation/Lorem.swift b/Example/Sources/Data Generation/Lorem.swift index b368af71..47597730 100755 --- a/Example/Sources/Data Generation/Lorem.swift +++ b/Example/Sources/Data Generation/Lorem.swift @@ -222,7 +222,7 @@ public extension Array { /** Shuffle the array in-place using the Fisher-Yates algorithm. */ - mutating func shuffle() { + public mutating func shuffle() { for i in 0..<(count - 1) { let j = Int(arc4random_uniform(UInt32(count - i))) + i if j != i { @@ -237,7 +237,7 @@ public extension Array { - returns: Returns a shuffled version of the array. */ - func shuffled() -> [Element] { + public func shuffled() -> [Element] { var list = self list.shuffle() @@ -249,7 +249,7 @@ public extension Array { - returns: Returns a random element from the array or `nil` if the array is empty. */ - func random() -> Element? { + public func random() -> Element? { return (count > 0) ? self.shuffled()[0] : nil } @@ -257,7 +257,7 @@ public extension Array { Return a random subset of `cnt` elements from the array. - returns: Returns a random subset of `cnt` elements from the array. */ - func random(_ count: Int = 1) -> [Element] { + public func random(_ count: Int = 1) -> [Element] { let result = shuffled() return (count > result.count) ? result : Array(result[0.. "MIT", :file => "LICENSE.md" } s.summary = 'An elegant messages UI library for iOS.' @@ -12,16 +12,16 @@ Pod::Spec.new do |s| s.source_files = 'Sources/**/*.swift' s.pod_target_xcconfig = { - "SWIFT_VERSION" => "5.0", + "SWIFT_VERSION" => "4.2", } - s.swift_version = '5.0' + s.swift_version = '4.2' s.ios.deployment_target = '9.0' s.ios.resource_bundle = { 'MessageKitAssets' => 'Assets/MessageKitAssets.bundle/Images' } s.requires_arc = true - s.dependency 'InputBarAccessoryView', '~> 4.3.0' + s.dependency 'InputBarAccessoryView', '~> 4.2.2' end diff --git a/MessageKit.xcodeproj/project.pbxproj b/MessageKit.xcodeproj/project.pbxproj index cfaac857..4b6ecfac 100644 --- a/MessageKit.xcodeproj/project.pbxproj +++ b/MessageKit.xcodeproj/project.pbxproj @@ -563,7 +563,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = MessageKit; TargetAttributes = { 88916B211CF0DF2F00469F91 = { @@ -788,7 +788,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -841,7 +841,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -871,7 +871,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -897,7 +897,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme b/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme index 1f6e5d93..edb000ac 100644 --- a/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme +++ b/MessageKit.xcodeproj/xcshareddata/xcschemes/MessageKit.xcscheme @@ -1,6 +1,6 @@ CGFloat { + internal func requiredInitialScrollViewBottomInset() -> CGFloat { let inputAccessoryViewHeight = inputAccessoryView?.frame.height ?? 0 return max(0, inputAccessoryViewHeight + additionalBottomInset - automaticallyAddedBottomInset) } diff --git a/Sources/Controllers/MessagesViewController+Menu.swift b/Sources/Controllers/MessagesViewController+Menu.swift index 9a02f20b..fefe53ee 100644 --- a/Sources/Controllers/MessagesViewController+Menu.swift +++ b/Sources/Controllers/MessagesViewController+Menu.swift @@ -28,11 +28,11 @@ internal extension MessagesViewController { // MARK: - Register / Unregister Observers - func addMenuControllerObservers() { + internal func addMenuControllerObservers() { NotificationCenter.default.addObserver(self, selector: #selector(MessagesViewController.menuControllerWillShow(_:)), name: UIMenuController.willShowMenuNotification, object: nil) } - func removeMenuControllerObservers() { + internal func removeMenuControllerObservers() { NotificationCenter.default.removeObserver(self, name: UIMenuController.willShowMenuNotification, object: nil) } diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index db05420f..0e154c4f 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -34,7 +34,7 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { open var messagesCollectionView = MessagesCollectionView() /// The `InputBarAccessoryView` used as the `inputAccessoryView` in the view controller. - open lazy var messageInputBar = InputBarAccessoryView() + open var messageInputBar = InputBarAccessoryView() /// A Boolean value that determines whether the `MessagesCollectionView` scrolls to the /// bottom whenever the `InputTextView` begins editing. diff --git a/Sources/Extensions/Bundle+Extensions.swift b/Sources/Extensions/Bundle+Extensions.swift index ea13d297..2cca400d 100644 --- a/Sources/Extensions/Bundle+Extensions.swift +++ b/Sources/Extensions/Bundle+Extensions.swift @@ -26,7 +26,7 @@ import Foundation internal extension Bundle { - static func messageKitAssetBundle() -> Bundle { + static func messageKitAssetBundle() -> Bundle { // swiftlint:disable:this explicit_acl let podBundle = Bundle(for: MessagesViewController.self) guard let resourceBundleUrl = podBundle.url(forResource: "MessageKitAssets", withExtension: "bundle") else { diff --git a/Sources/Extensions/CGRect+Extensions.swift b/Sources/Extensions/CGRect+Extensions.swift index f5112a3d..b3cadbd1 100644 --- a/Sources/Extensions/CGRect+Extensions.swift +++ b/Sources/Extensions/CGRect+Extensions.swift @@ -26,7 +26,7 @@ import Foundation internal extension CGRect { - init(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) { + init(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) { // swiftlint:disable:this explicit_acl self.init(x: x, y: y, width: w, height: h) } diff --git a/Sources/Extensions/NSAttributedString+Extensions.swift b/Sources/Extensions/NSAttributedString+Extensions.swift index e0fe3760..4025dac0 100644 --- a/Sources/Extensions/NSAttributedString+Extensions.swift +++ b/Sources/Extensions/NSAttributedString+Extensions.swift @@ -26,7 +26,7 @@ import Foundation internal extension NSAttributedString { - func width(considering height: CGFloat) -> CGFloat { + func width(considering height: CGFloat) -> CGFloat { // swiftlint:disable:this explicit_acl let constraintBox = CGSize(width: .greatestFiniteMagnitude, height: height) let rect = self.boundingRect(with: constraintBox, options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil) diff --git a/Sources/Extensions/UIColor+Extensions.swift b/Sources/Extensions/UIColor+Extensions.swift index 0d85ba9e..3c09bbcb 100644 --- a/Sources/Extensions/UIColor+Extensions.swift +++ b/Sources/Extensions/UIColor+Extensions.swift @@ -24,6 +24,8 @@ import Foundation +// swiftlint:disable explicit_acl + internal extension UIColor { static let incomingGray = UIColor(red: 230/255, green: 230/255, blue: 235/255, alpha: 1.0) diff --git a/Sources/Extensions/UIEdgeInsets+Extensions.swift b/Sources/Extensions/UIEdgeInsets+Extensions.swift index bd938be8..a3fc6153 100644 --- a/Sources/Extensions/UIEdgeInsets+Extensions.swift +++ b/Sources/Extensions/UIEdgeInsets+Extensions.swift @@ -24,6 +24,8 @@ import Foundation +// swiftlint:disable explicit_acl + internal extension UIEdgeInsets { var vertical: CGFloat { diff --git a/Sources/Extensions/UIImage+Extension.swift b/Sources/Extensions/UIImage+Extension.swift index 5195a1e7..157fd0f4 100644 --- a/Sources/Extensions/UIImage+Extension.swift +++ b/Sources/Extensions/UIImage+Extension.swift @@ -33,7 +33,7 @@ import UIKit /// This extension provide a way to access image resources with in framework public extension UIImage { - class func messageKitImageWith(type: ImageType) -> UIImage? { + public class func messageKitImageWith(type: ImageType) -> UIImage? { let assetBundle = Bundle.messageKitAssetBundle() let imagePath = assetBundle.path(forResource: type.rawValue, ofType: "png", inDirectory: "Images") let image = UIImage(contentsOfFile: imagePath ?? "") diff --git a/Sources/Extensions/UIView+Extensions.swift b/Sources/Extensions/UIView+Extensions.swift index 42bbbbd9..ec01877f 100644 --- a/Sources/Extensions/UIView+Extensions.swift +++ b/Sources/Extensions/UIView+Extensions.swift @@ -24,6 +24,8 @@ import UIKit +// swiftlint:disable explicit_acl + internal extension UIView { func fillSuperview() { @@ -65,7 +67,7 @@ internal extension UIView { } @discardableResult - func addConstraints(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, centerY: NSLayoutYAxisAnchor? = nil, centerX: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, centerYConstant: CGFloat = 0, centerXConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) -> [NSLayoutConstraint] { + internal func addConstraints(_ top: NSLayoutYAxisAnchor? = nil, left: NSLayoutXAxisAnchor? = nil, bottom: NSLayoutYAxisAnchor? = nil, right: NSLayoutXAxisAnchor? = nil, centerY: NSLayoutYAxisAnchor? = nil, centerX: NSLayoutXAxisAnchor? = nil, topConstant: CGFloat = 0, leftConstant: CGFloat = 0, bottomConstant: CGFloat = 0, rightConstant: CGFloat = 0, centerYConstant: CGFloat = 0, centerXConstant: CGFloat = 0, widthConstant: CGFloat = 0, heightConstant: CGFloat = 0) -> [NSLayoutConstraint] { if self.superview == nil { return [] diff --git a/Sources/Layout/MessageSizeCalculator.swift b/Sources/Layout/MessageSizeCalculator.swift index 2b95457f..4cca7e1c 100644 --- a/Sources/Layout/MessageSizeCalculator.swift +++ b/Sources/Layout/MessageSizeCalculator.swift @@ -78,7 +78,6 @@ open class MessageSizeCalculator: CellSizeCalculator { attributes.messageContainerPadding = messageContainerPadding(for: message) attributes.messageContainerSize = messageContainerSize(for: message) attributes.cellTopLabelSize = cellTopLabelSize(for: message, at: indexPath) - attributes.cellTopLabelAlignment = cellTopLabelAlignment(for: message) attributes.cellBottomLabelSize = cellBottomLabelSize(for: message, at: indexPath) attributes.cellBottomLabelAlignment = cellBottomLabelAlignment(for: message) attributes.messageTopLabelSize = messageTopLabelSize(for: message, at: indexPath) diff --git a/Sources/Layout/MessagesCollectionViewFlowLayout.swift b/Sources/Layout/MessagesCollectionViewFlowLayout.swift index 95ac736d..b5e76738 100644 --- a/Sources/Layout/MessagesCollectionViewFlowLayout.swift +++ b/Sources/Layout/MessagesCollectionViewFlowLayout.swift @@ -89,7 +89,7 @@ open class MessagesCollectionViewFlowLayout: UICollectionViewFlowLayout { } private func setupObserver() { - NotificationCenter.default.addObserver(self, selector: #selector(MessagesCollectionViewFlowLayout.handleOrientationChange(_:)), name: UIApplication.didChangeStatusBarOrientationNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(MessagesCollectionViewFlowLayout.handleOrientationChange(_:)), name: UIDevice.orientationDidChangeNotification, object: nil) } // MARK: - Typing Indicator API diff --git a/Sources/Models/AvatarPosition.swift b/Sources/Models/AvatarPosition.swift index c62c99fe..60219d1d 100644 --- a/Sources/Models/AvatarPosition.swift +++ b/Sources/Models/AvatarPosition.swift @@ -94,5 +94,5 @@ public extension AvatarPosition { static func == (lhs: AvatarPosition, rhs: AvatarPosition) -> Bool { return lhs.vertical == rhs.vertical && lhs.horizontal == rhs.horizontal } - + } diff --git a/Sources/Models/DetectorType.swift b/Sources/Models/DetectorType.swift index 1b711a77..d2b602a8 100644 --- a/Sources/Models/DetectorType.swift +++ b/Sources/Models/DetectorType.swift @@ -58,8 +58,8 @@ public enum DetectorType: Hashable { } ///The hashValue of the `DetectorType` so we can conform to `Hashable` and be sorted. - public func hash(into hasher: inout Hasher) { - hasher.combine(toInt()) + public func hash(into: inout Hasher) { + into.combine(toInt()) } /// Return an 'Int' value for each `DetectorType` type so `DetectorType` can conform to `Hashable` diff --git a/Sources/Models/HorizontalEdgeInsets.swift b/Sources/Models/HorizontalEdgeInsets.swift index 91461fa9..a1bf6740 100644 --- a/Sources/Models/HorizontalEdgeInsets.swift +++ b/Sources/Models/HorizontalEdgeInsets.swift @@ -40,8 +40,6 @@ public struct HorizontalEdgeInsets: Equatable { } } -// MARK: Equatable Conformance - public extension HorizontalEdgeInsets { static func == (lhs: HorizontalEdgeInsets, rhs: HorizontalEdgeInsets) -> Bool { @@ -51,7 +49,7 @@ public extension HorizontalEdgeInsets { internal extension HorizontalEdgeInsets { - var horizontal: CGFloat { + internal var horizontal: CGFloat { return left + right } } diff --git a/Sources/Models/Sender.swift b/Sources/Models/Sender.swift index bd5a31c5..28468785 100644 --- a/Sources/Models/Sender.swift +++ b/Sources/Models/Sender.swift @@ -25,7 +25,7 @@ import Foundation /// An object that groups the metadata of a messages sender. -@available(*, deprecated, message: "`Sender` has been replaced with the `SenderType` protocol in 3.0.0") +@available(*, deprecated: 3.0.0, message: "`Sender` has been replaced with the `SenderType` protocol in 3.0.0") public struct Sender: SenderType { /// MARK: - Properties @@ -35,7 +35,7 @@ public struct Sender: SenderType { /// Note: This value must be unique across all senders. public let senderId: String - @available(*, deprecated, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") + @available(*, deprecated: 3.0.0, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") public var id: String { return senderId } @@ -50,7 +50,7 @@ public struct Sender: SenderType { self.displayName = displayName } - @available(*, deprecated, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") + @available(*, deprecated: 3.0.0, message: "`id` has been renamed `senderId` as defined in the `SenderType` protocol") public init(id: String, displayName: String) { self.init(senderId: id, displayName: displayName) } diff --git a/Sources/Supporting/MessageInputBar.swift b/Sources/Supporting/MessageInputBar.swift index a2c2919c..575edd50 100644 --- a/Sources/Supporting/MessageInputBar.swift +++ b/Sources/Supporting/MessageInputBar.swift @@ -25,8 +25,31 @@ import UIKit import InputBarAccessoryView -@available(*, deprecated, renamed: "InputBarAccessoryView") +@available(*, obsoleted: 3.0.0, renamed: "InputBarAccessoryView") public typealias MessageInputBar = InputBarAccessoryView -@available(*, deprecated, renamed: "InputBarAccessoryViewDelegate") +@available(*, obsoleted: 3.0.0, renamed: "InputBarAccessoryViewDelegate") public typealias MessageInputBarDelegate = InputBarAccessoryViewDelegate + +//public extension MessageInputBarDelegate { +// +// @available(*, obsoleted: 3.0.0, message: "`MessageInputBar` has been replaced with `InputBarAccessoryView` in 3.0.0. Use `inputBar(_ inputBar: InputBarAccessoryView, didPressSendButtonWith text: String)` instead.") +// func messageInputBar(_ inputBar: MessageInputBar, didPressSendButtonWith text: String) { +// } +// +// @available(*, obsoleted: 3.0.0, message: "`MessageInputBar` has been replaced with `InputBarAccessoryView` in 3.0.0. Use `inputBar(_ inputBar: InputBarAccessoryView, textViewTextDidChangeTo text: String)` instead.") +// func messageInputBar(_ inputBar: MessageInputBar, textViewTextDidChangeTo text: String) { +// } +// +// @available(*, obsoleted: 3.0.0, message: "`MessageInputBar` has been replaced with `InputBarAccessoryView` in 3.0.0. Use `inputBar(_ inputBar: InputBarAccessoryView, didChangeIntrinsicContentTo size: CGSize)` instead.") +// func messageInputBar(_ inputBar: MessageInputBar, didChangeIntrinsicContentTo size: CGSize) { +// } +//} +// +//extension InputBarButtonItem { +// +// @available(*, renamed: "inputBarAccessoryView") +// public var messageInputBar: MessageInputBar? { +// return inputBarAccessoryView +// } +//} diff --git a/Sources/Views/Cells/AudioMessageCell.swift b/Sources/Views/Cells/AudioMessageCell.swift index b08d7ad5..a9251ce5 100644 --- a/Sources/Views/Cells/AudioMessageCell.swift +++ b/Sources/Views/Cells/AudioMessageCell.swift @@ -47,26 +47,18 @@ open class AudioMessageCell: MessageContentCell { return durationLabel }() - public lazy var activityIndicatorView: UIActivityIndicatorView = { - let activityIndicatorView = UIActivityIndicatorView(style: .gray) - activityIndicatorView.hidesWhenStopped = true - activityIndicatorView.isHidden = true - return activityIndicatorView - }() - public lazy var progressView: UIProgressView = { let progressView = UIProgressView(progressViewStyle: .default) progressView.progress = 0.0 return progressView }() - + // MARK: - Methods /// Responsible for setting up the constraints of the cell's subviews. open func setupConstraints() { playButton.constraint(equalTo: CGSize(width: 25, height: 25)) playButton.addConstraints(left: messageContainerView.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 5) - activityIndicatorView.addConstraints(centerY: playButton.centerYAnchor, centerX: playButton.centerXAnchor) durationLabel.addConstraints(right: messageContainerView.rightAnchor, centerY: messageContainerView.centerYAnchor, rightConstant: 15) progressView.addConstraints(left: playButton.rightAnchor, right: durationLabel.leftAnchor, centerY: messageContainerView.centerYAnchor, leftConstant: 5, rightConstant: 5) } @@ -74,7 +66,6 @@ open class AudioMessageCell: MessageContentCell { open override func setupSubviews() { super.setupSubviews() messageContainerView.addSubview(playButton) - messageContainerView.addSubview(activityIndicatorView) messageContainerView.addSubview(durationLabel) messageContainerView.addSubview(progressView) setupConstraints() @@ -84,8 +75,6 @@ open class AudioMessageCell: MessageContentCell { super.prepareForReuse() progressView.progress = 0 playButton.isSelected = false - activityIndicatorView.stopAnimating() - playButton.isHidden = false durationLabel.text = "0:00" } diff --git a/Sources/Views/Cells/MessageContentCell.swift b/Sources/Views/Cells/MessageContentCell.swift index 629cc272..9fdfefeb 100644 --- a/Sources/Views/Cells/MessageContentCell.swift +++ b/Sources/Views/Cells/MessageContentCell.swift @@ -267,9 +267,6 @@ open class MessageContentCell: MessageCollectionViewCell { /// Positions the cell's top label. /// - attributes: The `MessagesCollectionViewLayoutAttributes` for the cell. open func layoutCellTopLabel(with attributes: MessagesCollectionViewLayoutAttributes) { - cellTopLabel.textAlignment = attributes.cellTopLabelAlignment.textAlignment - cellTopLabel.textInsets = attributes.cellTopLabelAlignment.textInsets - cellTopLabel.frame = CGRect(origin: .zero, size: attributes.cellTopLabelSize) } diff --git a/Sources/Views/MessageLabel.swift b/Sources/Views/MessageLabel.swift index 90a78c05..3ea89490 100644 --- a/Sources/Views/MessageLabel.swift +++ b/Sources/Views/MessageLabel.swift @@ -273,11 +273,6 @@ open class MessageLabel: UILabel { guard let rangeTuples = rangesForDetectors[detector] else { continue } for (range, _) in rangeTuples { - // This will enable us to attribute it with our own styles, since `UILabel` does not provide link attribute overrides like `UITextView` does - if detector.textCheckingType == .link { - mutableAttributedString.removeAttribute(NSAttributedString.Key.link, range: range) - } - let attributes = detectorAttributes(for: detector) mutableAttributedString.addAttributes(attributes, range: range) } diff --git a/Sources/Views/MessagesCollectionView.swift b/Sources/Views/MessagesCollectionView.swift index 27ca2d03..22e75474 100644 --- a/Sources/Views/MessagesCollectionView.swift +++ b/Sources/Views/MessagesCollectionView.swift @@ -101,8 +101,9 @@ open class MessagesCollectionView: UICollectionView { } public func scrollToBottom(animated: Bool = false) { + let collectionViewContentHeight = collectionViewLayout.collectionViewContentSize.height + performBatchUpdates(nil) { _ in - let collectionViewContentHeight = self.collectionViewLayout.collectionViewContentSize.height self.scrollRectToVisible(CGRect(0.0, collectionViewContentHeight - 1.0, 1.0, 1.0), animated: animated) } } From 15df8793381d6d5eac43e30bb1bc3bb607a9b53e Mon Sep 17 00:00:00 2001 From: Kino Date: Mon, 17 Feb 2020 13:58:54 -0800 Subject: [PATCH 46/64] Fix merge --- Sources/Supporting/MessageInputBar.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sources/Supporting/MessageInputBar.swift b/Sources/Supporting/MessageInputBar.swift index 870d9330..7c6f7dbf 100644 --- a/Sources/Supporting/MessageInputBar.swift +++ b/Sources/Supporting/MessageInputBar.swift @@ -29,7 +29,4 @@ import InputBarAccessoryView public typealias MessageInputBar = InputBarAccessoryView @available(*, unavailable, renamed: "InputBarAccessoryViewDelegate") -public typealias MessageInputBar = InputBarAccessoryView - -@available(*, deprecated, renamed: "InputBarAccessoryViewDelegate") public typealias MessageInputBarDelegate = InputBarAccessoryViewDelegate From 378e60fcf2c73ec96d528cb53549a2d516e9d2c6 Mon Sep 17 00:00:00 2001 From: Shawn Gong Date: Mon, 17 Feb 2020 19:18:21 -0800 Subject: [PATCH 47/64] Fix tests --- Cartfile.resolved | 4 ++-- .../MessagesDisplayDelegateTests.swift | 8 ++++---- Tests/ViewsTests/AvatarViewTests.swift | 12 +++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 7acd3164..87c9aee3 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "Quick/Nimble" "v8.0.1" -github "Quick/Quick" "v2.0.0" +github "Quick/Nimble" "v8.0.5" +github "Quick/Quick" "v2.2.0" github "nathantannar4/InputBarAccessoryView" "4.3.0" diff --git a/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift b/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift index 6cbfb632..717d154e 100644 --- a/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift +++ b/Tests/ProtocolsTests/MessagesDisplayDelegateTests.swift @@ -71,7 +71,7 @@ class MessagesDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(backgroundColor, .white) + XCTAssertEqual(backgroundColor, .backgroundColor) } func testBackgroundColorForMessageWithEmoji_returnsClearForDefault() { @@ -143,7 +143,7 @@ class TextMessageDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(textColor, .white) + XCTAssertEqual(textColor, .backgroundColor) } func testTextColorFromYou_returnsDarkTextForDefault() { @@ -151,7 +151,7 @@ class TextMessageDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(textColor, .darkText) + XCTAssertEqual(textColor, .labelColor) } func testTextColorWithoutDataSource_returnsDarkTextForDefault() { @@ -161,7 +161,7 @@ class TextMessageDisplayDelegateTests: XCTestCase { at: IndexPath(item: 0, section: 0), in: sut.messagesCollectionView) - XCTAssertEqual(textColor, .darkText) + XCTAssertEqual(textColor, .labelColor) } func testEnableDetectors_returnsEmptyForDefault() { diff --git a/Tests/ViewsTests/AvatarViewTests.swift b/Tests/ViewsTests/AvatarViewTests.swift index e919f141..602632c7 100644 --- a/Tests/ViewsTests/AvatarViewTests.swift +++ b/Tests/ViewsTests/AvatarViewTests.swift @@ -42,7 +42,9 @@ class AvatarViewTests: XCTestCase { func testNoParams() { XCTAssertEqual(avatarView.layer.cornerRadius, 15.0) - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + // For certain dynamic colors, need to compare cgColor in XCTest + // https://stackoverflow.com/questions/58065340/how-to-compare-two-uidynamicprovidercolor + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) } func testWithImage() { @@ -50,7 +52,7 @@ class AvatarViewTests: XCTestCase { avatarView.set(avatar: avatar) XCTAssertEqual(avatar.initials, "?") XCTAssertEqual(avatarView.layer.cornerRadius, 15.0) - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) } func testInitialsOnly() { @@ -59,13 +61,13 @@ class AvatarViewTests: XCTestCase { XCTAssertEqual(avatarView.initials, avatar.initials) XCTAssertEqual(avatar.initials, "DL") XCTAssertEqual(avatarView.layer.cornerRadius, 15.0) - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) } func testSetBackground() { - XCTAssertEqual(avatarView.backgroundColor, UIColor.gray) + XCTAssertEqual(avatarView.backgroundColor!.cgColor, UIColor.grayColor.cgColor) avatarView.backgroundColor = UIColor.red - XCTAssertEqual(avatarView.backgroundColor, UIColor.red) + XCTAssertEqual(avatarView.backgroundColor!, UIColor.red) } func testGetImage() { From 3dfd26e934c2ea4364401558b703d36448b91f86 Mon Sep 17 00:00:00 2001 From: hyouuu Date: Tue, 18 Feb 2020 14:06:57 -0800 Subject: [PATCH 48/64] typo --- Sources/Controllers/MessagesViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index 982a2df5..e5122f16 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -40,7 +40,7 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { /// last item whenever the `InputTextView` begins editing. /// /// The default value of this property is `false`. - /// NOTE: This calls scrollToLastItem where as the below flag calls scrollToBottome - check methods for differences + /// NOTE: This calls scrollToLastItem where as the below flag calls scrollToBottom - check methods for differences open var scrollsToLastItemOnKeyboardBeginsEditing: Bool = false /// A Boolean value that determines whether the `MessagesCollectionView` scrolls to the From d4f8a466e05b9e55e5a8ae62e9976ebd26197d5d Mon Sep 17 00:00:00 2001 From: hyouuu Date: Tue, 18 Feb 2020 14:17:44 -0800 Subject: [PATCH 49/64] rename to lastItemIndex --- Sources/Views/MessagesCollectionView.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Views/MessagesCollectionView.swift b/Sources/Views/MessagesCollectionView.swift index ce960897..05515be2 100644 --- a/Sources/Views/MessagesCollectionView.swift +++ b/Sources/Views/MessagesCollectionView.swift @@ -105,11 +105,11 @@ open class MessagesCollectionView: UICollectionView { guard numberOfSections > 0 else { return } let lastSection = numberOfSections - 1 - let lastItem = numberOfItems(inSection: lastSection) - 1 + let lastItemIndex = numberOfItems(inSection: lastSection) - 1 - guard lastItem >= 0 else { return } + guard lastItemIndex >= 0 else { return } - let indexPath = IndexPath(row: lastItem, section: lastSection) + let indexPath = IndexPath(row: lastItemIndex, section: lastSection) scrollToItem(at: indexPath, at: pos, animated: animated) } From 29888c2c5ac99b1e3c4e33cebd8ecddb91b98e58 Mon Sep 17 00:00:00 2001 From: Kino Date: Tue, 18 Feb 2020 15:27:01 -0800 Subject: [PATCH 50/64] Add CHANGELOG entries for PR #1201 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c1dcf8..7cbb65cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,11 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa - Add missing cellTopLabelAlignment to MessageSizeCalculator. [#1113](https://github.com/MessageKit/MessageKit/pull/1113) by [@marcetcheverry](https://github.com/marcetcheverry) +- **Breaking Change** `MessageInputBar`, and `MessageInputBarDelegate` have been obsoleted. Use`InputBarAccessoryView` and `InputBarAccessoryViewDelegate` respectively. This change was previously meant for 3.0.0 but was implemented erroneously. [#1201](https://github.com/MessageKit/MessageKit/pull/1201) by [@kinoroy](https://github.com/kinoroy) + +- Deprecated `SenderType.id` in favour of `SenderType.senderId`. This change was previously meant for 3.0.0 but + was implemented erroneously. [#1201](https://github.com/MessageKit/MessageKit/pull/1201) by [@kinoroy](https://github.com/kinoroy) + ## 3.0.0 ### Dependency Changes From c28fdbb800df3d27231c959114997c68ee9bc62c Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 19 Feb 2020 09:11:05 -0800 Subject: [PATCH 51/64] Update readme and changelog for release 3.1.0 --- CHANGELOG.md | 10 ++++++++++ README.md | 14 ++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cbb65cd..2d853f97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ## Upcoming release +### Fixed + +### Added + +### Changed + +## 3.1.0 + ### Fixed - Set the proper notification to invalidate layout. MessageKit now relies on `UIApplication` orientation notification instead of `UIDevice`, which invalidates the layout only when it is needed. [#1126](https://github.com/MessageKit/MessageKit/pull/1126) by [@bguidolim](https://github.com/bguidolim) @@ -20,6 +28,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Changed +- **Breaking Change** Updated to Swift 5.0 [#1039](https://github.com/MessageKit/MessageKit/pull/1039) by [@nathantannar4](https://github.com/nathantannar4) + - Fixes scrollToBottom method to properly handle calls made early in the view lifecycle. [#1110](https://github.com/MessageKit/MessageKit/pull/1110) by [@marcetcheverry](https://github.com/marcetcheverry) - Add missing cellTopLabelAlignment to MessageSizeCalculator. [#1113](https://github.com/MessageKit/MessageKit/pull/1113) by [@marcetcheverry](https://github.com/marcetcheverry) diff --git a/README.md b/README.md index f0c2d77f..1f130f63 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,14 @@ See [VISION.md](https://github.com/MessageKit/MessageKit/blob/master/VISION.md) ## Installation ### [CocoaPods](https://cocoapods.org/) **Recommended** ````ruby -# Swift 4.2 +# Swift 5.0 pod 'MessageKit' ```` - -> If you are already using Swift 5, use the `3.0.0-swift5` branch until the offical release is made +> For Swift 4.2 use version 3.0.0 +````ruby +# Swift 4.2 +pod 'MessageKit', '~> 3.0.0' +```` ### [Carthage](https://github.com/Carthage/Carthage) @@ -61,9 +64,8 @@ github "MessageKit/MessageKit" ## Requirements -- **iOS9** or later -- **Swift 4.2** or later - +- **iOS 9** or later +- **Swift 5.0** or later ## Getting Started From fd1e1e91fe3c9fcb800349b3aef626d90d854cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ka=C5=A1par?= Date: Wed, 19 Feb 2020 09:19:31 -0800 Subject: [PATCH 52/64] Add more changes to the changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d853f97..de8c4447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Fixed - Set the proper notification to invalidate layout. MessageKit now relies on `UIApplication` orientation notification instead of `UIDevice`, which invalidates the layout only when it is needed. [#1126](https://github.com/MessageKit/MessageKit/pull/1126) by [@bguidolim](https://github.com/bguidolim) + + - Fixed `requiredInitialScrollViewBottomInset` when `inputAccessoryView` is `nil` [#1218](https://github.com/MessageKit/MessageKit/pull/1218) by [@aabosh](https://github.com/aabosh) ### Added @@ -26,6 +28,10 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa - Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) +- Add support for Dark Mode [#1189](https://github.com/MessageKit/MessageKit/pull/1189) by [@Vlada31R](https://github.com/Vlada31R) + +- Add support for `scrollToLastItem` and `scrollsToLastItemOnKeyboardBeginsEditing` [#1247](https://github.com/MessageKit/MessageKit/pull/1247) by [@youuu](https://github.com/youuu) + ### Changed - **Breaking Change** Updated to Swift 5.0 [#1039](https://github.com/MessageKit/MessageKit/pull/1039) by [@nathantannar4](https://github.com/nathantannar4) From 699b4e7bcd8e668507ded2c81572639b52ca6f52 Mon Sep 17 00:00:00 2001 From: Kino Date: Wed, 19 Feb 2020 16:18:19 -0800 Subject: [PATCH 53/64] Fix Eng project deprecation warning, Add recommended Base localization --- MessageKit.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MessageKit.xcodeproj/project.pbxproj b/MessageKit.xcodeproj/project.pbxproj index cfaac857..72509f16 100644 --- a/MessageKit.xcodeproj/project.pbxproj +++ b/MessageKit.xcodeproj/project.pbxproj @@ -577,11 +577,11 @@ }; buildConfigurationList = 88916B1C1CF0DF2F00469F91 /* Build configuration list for PBXProject "MessageKit" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, + Base, ); mainGroup = 88916B181CF0DF2F00469F91; productRefGroup = 88916B231CF0DF2F00469F91 /* Products */; From d707b91e0e2fd6a26a9915f5185e7e317dd7ba27 Mon Sep 17 00:00:00 2001 From: Kino Date: Wed, 19 Feb 2020 16:18:41 -0800 Subject: [PATCH 54/64] Fix improper MARK use warning --- Sources/Models/Sender.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Models/Sender.swift b/Sources/Models/Sender.swift index bd5a31c5..f29fa042 100644 --- a/Sources/Models/Sender.swift +++ b/Sources/Models/Sender.swift @@ -28,7 +28,7 @@ import Foundation @available(*, deprecated, message: "`Sender` has been replaced with the `SenderType` protocol in 3.0.0") public struct Sender: SenderType { - /// MARK: - Properties + // MARK: - Properties /// The unique String identifier for the sender. /// From c8d4013e866e56409ae27e83de42c2773b3255e5 Mon Sep 17 00:00:00 2001 From: Kino Date: Fri, 21 Feb 2020 12:48:23 -0800 Subject: [PATCH 55/64] Update InputBarAccessoryView to 4.3.2, edit Cartfile to allow < v5.0.0 --- Cartfile | 2 +- Cartfile.resolved | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartfile b/Cartfile index ed7bec6d..5e9a95f2 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nathantannar4/InputBarAccessoryView" "4.3.0" +github "nathantannar4/InputBarAccessoryView" ~> 4.3.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 87c9aee3..04ee5dc4 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ github "Quick/Nimble" "v8.0.5" github "Quick/Quick" "v2.2.0" -github "nathantannar4/InputBarAccessoryView" "4.3.0" +github "nathantannar4/InputBarAccessoryView" "4.3.2" From f1014d0a49b1374a02319d56acaac8a983b65404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ka=C5=A1par?= Date: Fri, 21 Feb 2020 21:00:58 -0800 Subject: [PATCH 56/64] Center images --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7a00c00a..ae7d9b07 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -

+

-

-

+

+

From ba48b696a950cc382f335eefde922a93b1ff7838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ka=C5=A1par?= Date: Fri, 21 Feb 2020 21:04:35 -0800 Subject: [PATCH 57/64] Move screenshot to second section --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ae7d9b07..59aa4058 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@

-

-

- + + A community-driven replacement for JSQMessagesViewController https://messagekit.github.io

[![CircleCI](https://circleci.com/gh/MessageKit/MessageKit.svg?style=svg)](https://circleci.com/gh/MessageKit/MessageKit) @@ -29,6 +28,10 @@ alt="Contributions Welcome"> +

+ +

+ ## Goals - Provide a :rotating_light:safe:rotating_light: environment for others to learn and grow through Open Source. From 5ba5295e22321483d55eb7ea717e2f1dddc8b7fb Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 21 Feb 2020 21:15:12 -0800 Subject: [PATCH 58/64] Update podfile, udpate pods, fix warnings, remove unnecessary code --- Example/ChatExample.xcodeproj/project.pbxproj | 7 ++----- Example/Podfile | 2 ++ Example/Podfile.lock | 14 ++++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Example/ChatExample.xcodeproj/project.pbxproj b/Example/ChatExample.xcodeproj/project.pbxproj index bfff37ea..89a85340 100644 --- a/Example/ChatExample.xcodeproj/project.pbxproj +++ b/Example/ChatExample.xcodeproj/project.pbxproj @@ -391,10 +391,9 @@ }; buildConfigurationList = 882B5E2E1CF7D4B900B6E160 /* Build configuration list for PBXProject "ChatExample" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -524,7 +523,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -713,7 +712,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = A830E27DBE0B66B89C5D2EB8 /* Pods-ChatExample.debug.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; @@ -728,7 +726,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9E0D67CD75BA7EB323FD391B /* Pods-ChatExample.release.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; diff --git a/Example/Podfile b/Example/Podfile index b77306c9..2e94b538 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,3 +1,5 @@ +source 'https://cdn.cocoapods.org/' + platform :ios, '9.0' target 'ChatExample' do diff --git a/Example/Podfile.lock b/Example/Podfile.lock index c76c9353..f0ebb0ef 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,7 @@ PODS: - - InputBarAccessoryView (4.3.0) + - InputBarAccessoryView (4.3.1): + - InputBarAccessoryView/Core (= 4.3.1) + - InputBarAccessoryView/Core (4.3.1) - MessageKit (3.1.0): - InputBarAccessoryView (~> 4.3.0) @@ -7,7 +9,7 @@ DEPENDENCIES: - MessageKit (from `../`) SPEC REPOS: - https://github.com/cocoapods/specs.git: + trunk: - InputBarAccessoryView EXTERNAL SOURCES: @@ -15,9 +17,9 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - InputBarAccessoryView: 28dca73f28df7822fe5377f83cfc4547e22f90ff - MessageKit: 72add24fcba6c6ca1e09385285f6f66757340769 + InputBarAccessoryView: 58a348be7ea2736c7eec60e5c315511c2dbb39fd + MessageKit: 3beb578737a5aa2bba25cc27c7b6d6faa09af5a7 -PODFILE CHECKSUM: cecdb7bc8129cf99f66de9f68eea3256fec30c3d +PODFILE CHECKSUM: 90bd12ca685503630d7fe716609f4974660ed5ee -COCOAPODS: 1.7.0 +COCOAPODS: 1.8.4 From 905524dd12aa87d44cca8d5c735cc54d74a73346 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Mon, 24 Feb 2020 19:03:51 +0100 Subject: [PATCH 59/64] Move UIColor extension to correct file --- MessageKit.xcodeproj/project.pbxproj | 4 -- Sources/Extensions/UIColor+Extensions.swift | 52 ++++++++++++++++++ Sources/Extensions/UIColor.swift | 60 --------------------- 3 files changed, 52 insertions(+), 64 deletions(-) delete mode 100644 Sources/Extensions/UIColor.swift diff --git a/MessageKit.xcodeproj/project.pbxproj b/MessageKit.xcodeproj/project.pbxproj index b29a8f71..72509f16 100644 --- a/MessageKit.xcodeproj/project.pbxproj +++ b/MessageKit.xcodeproj/project.pbxproj @@ -53,7 +53,6 @@ 50FF34572237FE6A0004DCD7 /* UIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FF34562237FE6A0004DCD7 /* UIImage+Extension.swift */; }; 50FF34592237FE850004DCD7 /* ContactMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FF34582237FE840004DCD7 /* ContactMessageCell.swift */; }; 50FF345B2237FE9C0004DCD7 /* ContactMessageSizeCalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FF345A2237FE9C0004DCD7 /* ContactMessageSizeCalculator.swift */; }; - 797AD26423422BDB00E63579 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 797AD26323422BDB00E63579 /* UIColor.swift */; }; 88916B2D1CF0DF2F00469F91 /* MessageKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88916B221CF0DF2F00469F91 /* MessageKit.framework */; }; 8962AC8A1F87AB7D0030B058 /* MessagesCollectionViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8962AC831F87AB230030B058 /* MessagesCollectionViewTests.swift */; }; 8962AC8C1F87AB7D0030B058 /* AvatarViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8962AC851F87AB230030B058 /* AvatarViewTests.swift */; }; @@ -167,7 +166,6 @@ 50FF34562237FE6A0004DCD7 /* UIImage+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+Extension.swift"; sourceTree = ""; }; 50FF34582237FE840004DCD7 /* ContactMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactMessageCell.swift; sourceTree = ""; }; 50FF345A2237FE9C0004DCD7 /* ContactMessageSizeCalculator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactMessageSizeCalculator.swift; sourceTree = ""; }; - 797AD26323422BDB00E63579 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; 88916B221CF0DF2F00469F91 /* MessageKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MessageKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 88916B2C1CF0DF2F00469F91 /* MessageKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MessageKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8962AC741F87AB230030B058 /* MessageKitDateFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageKitDateFormatterTests.swift; sourceTree = ""; }; @@ -408,7 +406,6 @@ B7A03F651F8669EB006AEF79 /* UIColor+Extensions.swift */, B7A03F661F8669EB006AEF79 /* UIView+Extensions.swift */, 1FCA6D2F201C1CC900BC3480 /* UIEdgeInsets+Extensions.swift */, - 797AD26323422BDB00E63579 /* UIColor.swift */, ); path = Extensions; sourceTree = ""; @@ -646,7 +643,6 @@ 38F8063321740D9E00CDB9DB /* BubbleCircle.swift in Sources */, B7A03F5C1F8669CA006AEF79 /* MessageCellDelegate.swift in Sources */, 5073C11D2175BEC60040EAD5 /* AudioMessageSizeCalculator.swift in Sources */, - 797AD26423422BDB00E63579 /* UIColor.swift in Sources */, 1FF377A420087C82004FD648 /* MessageKitError.swift in Sources */, 1F6C040E206A2AF4007BDE44 /* MessageReusableView.swift in Sources */, 388119462253EC30004B26AF /* TypingIndicatorCellSizeCalculator.swift in Sources */, diff --git a/Sources/Extensions/UIColor+Extensions.swift b/Sources/Extensions/UIColor+Extensions.swift index fb5a1f96..57f74578 100644 --- a/Sources/Extensions/UIColor+Extensions.swift +++ b/Sources/Extensions/UIColor+Extensions.swift @@ -66,3 +66,55 @@ internal extension UIColor { } } } + +internal extension UIColor { + + static var backgroundColor: UIColor { + if #available(iOS 13, *) { + return systemBackground + } else { + return white + } + } + + static var labelColor: UIColor { + if #available(iOS 13, *) { + return label + } else { + return black + } + } + + static var placeholderTextColor: UIColor { + if #available(iOS 13, *) { + return placeholderText + } else { + return .darkGray + } + } + + static var grayColor: UIColor { + if #available(iOS 13, *) { + return .systemGray + } else { + return gray + } + } + + static var darkTextColor: UIColor { + if #available(iOS 13, *) { + return .systemGray + } else { + return darkText + } + } + + static var lightGrayColor: UIColor { + if #available(iOS 13, *) { + return .systemGray5 + } else { + return .lightGray + } + } +} + diff --git a/Sources/Extensions/UIColor.swift b/Sources/Extensions/UIColor.swift deleted file mode 100644 index df18caa7..00000000 --- a/Sources/Extensions/UIColor.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// UIColor.swift -// MessageKit -// -// Created by Vlada Radchenko on 9/30/19. -// Copyright © 2019 MessageKit. All rights reserved. -// - -import Foundation - -extension UIColor { - - static var backgroundColor: UIColor { - if #available(iOS 13, *) { - return systemBackground - } else { - return white - } - } - - static var labelColor: UIColor { - if #available(iOS 13, *) { - return label - } else { - return black - } - } - - static var placeholderTextColor: UIColor { - if #available(iOS 13, *) { - return placeholderText - } else { - return .darkGray - } - } - - static var grayColor: UIColor { - if #available(iOS 13, *) { - return .systemGray - } else { - return gray - } - } - - static var darkTextColor: UIColor { - if #available(iOS 13, *) { - return .systemGray - } else { - return darkText - } - } - - static var lightGrayColor: UIColor { - if #available(iOS 13, *) { - return .systemGray5 - } else { - return .lightGray - } - } -} From 02db887f94340497d8ef32cb9c45a6864d2c8cb8 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Mon, 24 Feb 2020 19:06:27 +0100 Subject: [PATCH 60/64] Update docu about custom cells, add to readme --- CUSTOM_CELLS.md => Documentation/CUSTOM_CELLS.md | 0 README.md | 1 + 2 files changed, 1 insertion(+) rename CUSTOM_CELLS.md => Documentation/CUSTOM_CELLS.md (100%) diff --git a/CUSTOM_CELLS.md b/Documentation/CUSTOM_CELLS.md similarity index 100% rename from CUSTOM_CELLS.md rename to Documentation/CUSTOM_CELLS.md diff --git a/README.md b/README.md index 46b2b276..0b2c8fd1 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ public enum MessageKind { ``` If you choose to use the `.custom` kind you are responsible for all of the cells layout. Any `UICollectionViewCell` can be returned for custom cells which means any of the styling you provide from the `MessageDisplayDelegate` will not effect your custom cell. Even if you subclass your cell from `MessageContentCell`. +[Read more about custom cells](https://github.com/MessageKit/MessageKit/blob/master/Documentation/CUSTOM_CELLS.md) [Read more about the cases on the Quick Start guide.](https://github.com/MessageKit/MessageKit/blob/master/Documentation/QuickStart.md#messagekind) From a2e06a396ab89dcb78d448e4c282ef0dff4109ff Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Mon, 24 Feb 2020 19:35:19 +0100 Subject: [PATCH 61/64] Fix comments --- Sources/Controllers/MessagesViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index e5122f16..e74b0183 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -40,14 +40,14 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { /// last item whenever the `InputTextView` begins editing. /// /// The default value of this property is `false`. - /// NOTE: This calls scrollToLastItem where as the below flag calls scrollToBottom - check methods for differences + /// NOTE: This is related to `scrollToLastItem` whereas the below flag is related to `scrollToBottom` - check each function for differences open var scrollsToLastItemOnKeyboardBeginsEditing: Bool = false /// A Boolean value that determines whether the `MessagesCollectionView` scrolls to the /// bottom whenever the `InputTextView` begins editing. /// /// The default value of this property is `false`. - /// NOTE: This calls scrollToBottome where as the above flag calls scrollToLastItem - check methods for differences + /// NOTE: This is related to `scrollToBottom` whereas the above flag is related to `scrollToLastItem` - check each function for differences open var scrollsToBottomOnKeyboardBeginsEditing: Bool = false /// A Boolean value that determines whether the `MessagesCollectionView` From d58baeec90de21ea27b50c2700884a46461d942b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ka=C5=A1par?= Date: Tue, 25 Feb 2020 15:08:52 +0100 Subject: [PATCH 62/64] Update CHANGELOG.md --- CHANGELOG.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de8c4447..684b8da6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,6 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/MessageKit/MessageKit/releases) on GitHub. -## Upcoming release - -### Fixed - -### Added - -### Changed - ## 3.1.0 ### Fixed From b5bb86de787a9db8295569ba3a2019a6ccd9f5c4 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 25 Feb 2020 15:16:03 +0100 Subject: [PATCH 63/64] Prepare framework for beta version --- Example/Podfile.lock | 4 ++-- MessageKit.podspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index f0ebb0ef..9eef39c3 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -2,7 +2,7 @@ PODS: - InputBarAccessoryView (4.3.1): - InputBarAccessoryView/Core (= 4.3.1) - InputBarAccessoryView/Core (4.3.1) - - MessageKit (3.1.0): + - MessageKit (3.1.0-beta): - InputBarAccessoryView (~> 4.3.0) DEPENDENCIES: @@ -18,7 +18,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: InputBarAccessoryView: 58a348be7ea2736c7eec60e5c315511c2dbb39fd - MessageKit: 3beb578737a5aa2bba25cc27c7b6d6faa09af5a7 + MessageKit: 4327b7dd96484c53b09704379391125aa1ba6ba7 PODFILE CHECKSUM: 90bd12ca685503630d7fe716609f4974660ed5ee diff --git a/MessageKit.podspec b/MessageKit.podspec index 06b1f220..c82011a6 100644 --- a/MessageKit.podspec +++ b/MessageKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MessageKit' - s.version = '3.1.0' + s.version = '3.1.0-beta' s.license = { :type => "MIT", :file => "LICENSE.md" } s.summary = 'An elegant messages UI library for iOS.' From afe903e83675fe2321ced4e12b574385a48f2b31 Mon Sep 17 00:00:00 2001 From: Austin Wright <1952159+austinwright@users.noreply.github.com> Date: Tue, 25 Feb 2020 13:38:42 -0500 Subject: [PATCH 64/64] - Adjust version number to match previous conventions - Re-Generate podfile.lock for Example app --- Example/Podfile.lock | 4 ++-- MessageKit.podspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 9eef39c3..d99a2460 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -2,7 +2,7 @@ PODS: - InputBarAccessoryView (4.3.1): - InputBarAccessoryView/Core (= 4.3.1) - InputBarAccessoryView/Core (4.3.1) - - MessageKit (3.1.0-beta): + - MessageKit (3.1.0-beta.1): - InputBarAccessoryView (~> 4.3.0) DEPENDENCIES: @@ -18,7 +18,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: InputBarAccessoryView: 58a348be7ea2736c7eec60e5c315511c2dbb39fd - MessageKit: 4327b7dd96484c53b09704379391125aa1ba6ba7 + MessageKit: 6b809a162328346e0727dbcd040b5f9fd5f5ba15 PODFILE CHECKSUM: 90bd12ca685503630d7fe716609f4974660ed5ee diff --git a/MessageKit.podspec b/MessageKit.podspec index c82011a6..f2b4abd5 100644 --- a/MessageKit.podspec +++ b/MessageKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MessageKit' - s.version = '3.1.0-beta' + s.version = '3.1.0-beta.1' s.license = { :type => "MIT", :file => "LICENSE.md" } s.summary = 'An elegant messages UI library for iOS.'