diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4f8068..a95334f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,43 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Fixed +### Added + +### Changed + +### Removed + +## 3.6.0 + +### Fixed + +- Fixes an issue with Scroll problem on new messages with keyboard open [#1529](https://github.com/MessageKit/MessageKit/pull/1529) by [@politan8](https://github.com/politan8) + +- Fixes time stamp vertical alignment so labels align with messages when showMessageTimestampOnSwipeLeft is true. + by [@kurtsequoia](https://github.com/MessageKit/MessageKit/pull/1556) + +- **Breaking Change** Changed `MessagesLayoutDelegate`'s method for typing indicator size. Typing indicator's size is now correctly calculated based on delegate method `func typingIndicatorViewSize(for layout: MessagesCollectionViewFlowLayout) -> CGSize` [#1563](https://github.com/MessageKit/MessageKit/pull/1563) by [@kaspik](https://github.com/kaspik) + +### Added + +### Changed + +- Changed `resource_bundle` back to `resources` in MessageKit.podspec [#1565](https://github.com/MessageKit/MessageKit/pull/1565) by [@kaspik](https://github.com/kaspik) + +### Removed + +## 3.5.1 + +### Fixed +- `MessagesViewController` now smoothly scrolls messages off screen. [1531](https://github.com/MessageKit/MessageKit/issues/1531) & [1547](https://github.com/MessageKit/MessageKit/pull/1547) by [@mredig](https://github.com/mredig) + +### Changed +- Bump `InputBarAccessoryView` + +## 3.5.0 + +### Fixed + - maintainPositionOnKeyboardFrameChanged for small contentSize would scroll content out of bounds [#1506](https://github.com/MessageKit/MessageKit/pull/1506) by [@martinpucik](https://github.com/martinpucik) ### Added diff --git a/Cartfile b/Cartfile deleted file mode 100644 index 57a16b44..00000000 --- a/Cartfile +++ /dev/null @@ -1 +0,0 @@ -github "nathantannar4/InputBarAccessoryView" ~> 5.2.1 diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index b553a159..00000000 --- a/Cartfile.resolved +++ /dev/null @@ -1,3 +0,0 @@ -github "Quick/Nimble" "v8.1.2" -github "Quick/Quick" "v2.2.1" -github "nathantannar4/InputBarAccessoryView" "5.2.1" diff --git a/Documentation/QuickStart.md b/Documentation/QuickStart.md index 5d877594..89dd180f 100644 --- a/Documentation/QuickStart.md +++ b/Documentation/QuickStart.md @@ -100,13 +100,13 @@ public struct Sender: SenderType { } // Some global variables for the sake of the example. Using globals is not recommended! -let sender = Sender(id: "any_unique_id", displayName: "Steven") +let sender = Sender(senderId: "any_unique_id", displayName: "Steven") let messages: [MessageType] = [] extension ChatViewController: MessagesDataSource { func currentSender() -> SenderType { - return Sender(id: "any_unique_id", displayName: "Steven") + return Sender(senderId: "any_unique_id", displayName: "Steven") } func numberOfSections(in messagesCollectionView: MessagesCollectionView) -> Int { diff --git a/Gemfile b/Gemfile index ce1c92bd..f2e566d0 100644 --- a/Gemfile +++ b/Gemfile @@ -23,4 +23,4 @@ source 'https://rubygems.org' gem 'danger', '~> 6.2' -gem 'danger-swiftlint', '~> 0.24' \ No newline at end of file +gem 'danger-swiftlint', '~> 0.24' diff --git a/Gemfile.lock b/Gemfile.lock index 2490ff95..62e89c6a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,29 +24,29 @@ GEM no_proxy_fix octokit (~> 4.7) terminal-table (~> 1) - danger-swiftlint (0.24.3) + danger-swiftlint (0.24.5) danger rake (> 10) thor (~> 0.19) - faraday (0.17.3) + faraday (0.17.4) multipart-post (>= 1.2, < 3) faraday-http-cache (2.2.0) faraday (>= 0.8) - git (1.7.0) + git (1.8.1) rchardet (~> 1.8) - kramdown (2.3.0) + kramdown (2.3.1) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) multipart-post (2.1.1) nap (1.1.0) no_proxy_fix (0.1.2) - octokit (4.18.0) + octokit (4.20.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) open4 (1.3.4) - public_suffix (4.0.5) - rake (13.0.1) + public_suffix (4.0.6) + rake (13.0.3) rchardet (1.8.0) rexml (3.2.4) sawyer (0.8.2) diff --git a/MessageKit.podspec b/MessageKit.podspec index 844e3cc9..e230705e 100644 --- a/MessageKit.podspec +++ b/MessageKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MessageKit' - s.version = '3.4.2' + s.version = '3.6.0' s.license = { :type => "MIT", :file => "LICENSE.md" } s.summary = 'An elegant messages UI library for iOS.' @@ -14,8 +14,8 @@ Pod::Spec.new do |s| s.swift_version = '5.3' s.ios.deployment_target = '12.0' - s.ios.resource_bundle = { 'MessageKit' => 'Sources/Assets.xcassets' } + s.ios.resources = 'Sources/Assets.xcassets' - s.dependency 'InputBarAccessoryView', '~> 5.2.1' + s.dependency 'InputBarAccessoryView', '~> 5.3.1' end diff --git a/Package.swift b/Package.swift index 77893b6a..6458bac1 100644 --- a/Package.swift +++ b/Package.swift @@ -32,7 +32,7 @@ let package = Package( .library(name: "MessageKit", targets: ["MessageKit"]), ], dependencies: [ - .package(url: "https://github.com/nathantannar4/InputBarAccessoryView", .upToNextMajor(from: "5.2.1")) + .package(url: "https://github.com/nathantannar4/InputBarAccessoryView", .upToNextMajor(from: "5.3.1")) ], targets: [ .target( diff --git a/README.md b/README.md index 83f57a83..a9109f5b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ [![Danger](https://github.com/MessageKit/MessageKit/workflows/Danger/badge.svg)](https://github.com/MessageKit/MessageKit/actions?query=workflow%3A%22Danger%22) [![codecov](https://codecov.io/gh/MessageKit/MessageKit/branch/master/graph/badge.svg)](https://codecov.io/gh/MessageKit/MessageKit) -[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) Swift @@ -66,14 +65,6 @@ pod 'MessageKit', '~> 3.3.0' pod 'MessageKit', '~> 3.0.0' ``` -### [Carthage](https://github.com/Carthage/Carthage) - -To integrate MessageKit using Carthage, add the following to your `Cartfile`: - -``` -github "MessageKit/MessageKit" -``` - ### [Swift Package Manager](https://swift.org/package-manager/) Swift 5.3 in Xcode 12 [added support](https://github.com/apple/swift-evolution/blob/master/proposals/0271-package-manager-resources.md) for assets in Swift Packages. @@ -197,6 +188,9 @@ Add your app to the list of apps using this library and make a pull request. - [SmooveText](https://apps.apple.com/np/app/smoove-text/id1362792811) - [COYO Engage](https://apps.apple.com/app/coyo-engage/id1341588804) - [HitchPin](https://www.hitchpin.com) +- [Charge Running](https://apps.apple.com/app/charge-running-live-coaching/id1204578360) +- [HER](https://apps.apple.com/us/app/id573328837) +- [Girlfriend Plus](https://apps.apple.com/us/app/girlfriend-plus/id1011637655) _Please provide attribution, it is greatly appreciated._ @@ -206,6 +200,8 @@ _Please provide attribution, it is greatly appreciated._ - [@nathantannar4](https://github.com/nathantannar4), Nathan Tannar - [@zhongwuzw](https://github.com/zhongwuzw), Wu Zhong - [@austinwright](https://github.com/austinwright), Austin Wright +- [@kaspik](https://github.com/kaspik), Jakub Kaspar +- [@martinpucik](https://github.com/martinpucik), Martin Pucik ## Thanks diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 8511c0f6..59e0926e 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -98,6 +98,10 @@ internal extension MessagesViewController { let newBottomInset = requiredScrollViewBottomInset(forKeyboardFrame: keyboardEndFrame) let differenceOfBottomInset = newBottomInset - messageCollectionViewBottomInset + UIView.performWithoutAnimation { + messageCollectionViewBottomInset = newBottomInset + } + if maintainPositionOnKeyboardFrameChanged && differenceOfBottomInset != 0 { let contentOffset = CGPoint(x: messagesCollectionView.contentOffset.x, y: messagesCollectionView.contentOffset.y + differenceOfBottomInset) // Changing contentOffset to bigger number than the contentSize will result in a jump of content @@ -107,10 +111,6 @@ internal extension MessagesViewController { } messagesCollectionView.setContentOffset(contentOffset, animated: false) } - - UIView.performWithoutAnimation { - messageCollectionViewBottomInset = newBottomInset - } } // MARK: - Inset Computation diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index 0441c24c..f9c4d5c5 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -223,10 +223,12 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource, UIGestureRecogni private func setupDefaults() { extendedLayoutIncludesOpaqueBars = true view.backgroundColor = .collectionViewBackground - messagesCollectionView.contentInsetAdjustmentBehavior = .never messagesCollectionView.keyboardDismissMode = .interactive messagesCollectionView.alwaysBounceVertical = true messagesCollectionView.backgroundColor = .collectionViewBackground + if #available(iOS 13.0, *) { + messagesCollectionView.automaticallyAdjustsScrollIndicatorInsets = false + } } private func setupDelegates() { @@ -241,7 +243,7 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource, UIGestureRecogni private func setupConstraints() { messagesCollectionView.translatesAutoresizingMaskIntoConstraints = false - let top = messagesCollectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor) + let top = messagesCollectionView.topAnchor.constraint(equalTo: view.topAnchor) let bottom = messagesCollectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor) let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor) let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor) diff --git a/Sources/Extensions/Bundle+Extensions.swift b/Sources/Extensions/Bundle+Extensions.swift index 4fe47c26..f9884b50 100644 --- a/Sources/Extensions/Bundle+Extensions.swift +++ b/Sources/Extensions/Bundle+Extensions.swift @@ -29,12 +29,7 @@ internal extension Bundle { static var messageKitAssetBundle: Bundle = Bundle.module #else static var messageKitAssetBundle: Bundle { - guard let url = Bundle(for: MessagesViewController.self).url(forResource: "MessageKit", withExtension: "bundle"), - let resourcesBundle = Bundle(url: url) - else { - fatalError(MessageKitError.couldNotLoadAssetsBundle) - } - return resourcesBundle + return Bundle(for: MessagesViewController.self) } #endif } diff --git a/Sources/Layout/TypingIndicatorCellSizeCalculator.swift b/Sources/Layout/TypingIndicatorCellSizeCalculator.swift index 3e77663f..551465da 100644 --- a/Sources/Layout/TypingIndicatorCellSizeCalculator.swift +++ b/Sources/Layout/TypingIndicatorCellSizeCalculator.swift @@ -26,18 +26,13 @@ import UIKit open class TypingCellSizeCalculator: CellSizeCalculator { - open var height: CGFloat = 62 - public init(layout: MessagesCollectionViewFlowLayout? = nil) { super.init() self.layout = layout } open override func sizeForItem(at indexPath: IndexPath) -> CGSize { - guard let layout = layout else { return .zero } - let collectionViewWidth = layout.collectionView?.bounds.width ?? 0 - let contentInset = layout.collectionView?.contentInset ?? .zero - let inset = layout.sectionInset.horizontal + contentInset.horizontal - return CGSize(width: collectionViewWidth - inset, height: height) + guard let layout = layout as? MessagesCollectionViewFlowLayout else { return .zero } + return layout.messagesLayoutDelegate.typingIndicatorViewSize(for: layout) } } diff --git a/Sources/Protocols/MessagesLayoutDelegate.swift b/Sources/Protocols/MessagesLayoutDelegate.swift index 0e0238bb..a3d9ff5a 100644 --- a/Sources/Protocols/MessagesLayoutDelegate.swift +++ b/Sources/Protocols/MessagesLayoutDelegate.swift @@ -52,12 +52,11 @@ public protocol MessagesLayoutDelegate: AnyObject { /// Specifies the size to use for a typing indicator view. /// /// - Parameters: - /// - messagesCollectionView: The `MessagesCollectionView` in which this view will be displayed. + /// - layout: The `MessagesCollectionViewFlowLayout` layout. /// /// - Note: - /// The default value returned by this method is the width of the `messagesCollectionView` and - /// a height of 52. - func typingIndicatorViewSize(in messagesCollectionView: MessagesCollectionView) -> CGSize + /// The default value returned by this method is the width of the `messagesCollectionView` minus insets and a height of 62. + func typingIndicatorViewSize(for layout: MessagesCollectionViewFlowLayout) -> CGSize /// Specifies the top inset to use for a typing indicator view. /// @@ -134,8 +133,11 @@ public extension MessagesLayoutDelegate { return .zero } - func typingIndicatorViewSize(in messagesCollectionView: MessagesCollectionView) -> CGSize { - return CGSize(width: messagesCollectionView.bounds.width, height: 48) + func typingIndicatorViewSize(for layout: MessagesCollectionViewFlowLayout) -> CGSize { + let collectionViewWidth = layout.messagesCollectionView.bounds.width + let contentInset = layout.messagesCollectionView.contentInset + let inset = layout.sectionInset.horizontal + contentInset.horizontal + return CGSize(width: collectionViewWidth - inset, height: 62) } func typingIndicatorViewTopInset(in messagesCollectionView: MessagesCollectionView) -> CGFloat { diff --git a/Sources/Views/Cells/MessageContentCell.swift b/Sources/Views/Cells/MessageContentCell.swift index bb881add..618d0eae 100644 --- a/Sources/Views/Cells/MessageContentCell.swift +++ b/Sources/Views/Cells/MessageContentCell.swift @@ -357,7 +357,8 @@ open class MessageContentCell: MessageCollectionViewCell { /// - attributes: The `MessagesCollectionViewLayoutAttributes` for the cell. open func layoutTimeLabelView(with attributes: MessagesCollectionViewLayoutAttributes) { let paddingLeft: CGFloat = 10 - let origin = CGPoint(x: UIScreen.main.bounds.width + paddingLeft, y: contentView.frame.size.height * 0.5) + let origin = CGPoint(x: UIScreen.main.bounds.width + paddingLeft, + y: messageContainerView.frame.minY + messageContainerView.frame.height * 0.5 - messageTimestampLabel.font.ascender * 0.5) let size = CGSize(width: attributes.messageTimeLabelSize.width, height: attributes.messageTimeLabelSize.height) messageTimestampLabel.frame = CGRect(origin: origin, size: size) } diff --git a/Tests/MessageKitTests/Controllers Test/MessagesViewControllerTests.swift b/Tests/MessageKitTests/Controllers Test/MessagesViewControllerTests.swift index 9417eb26..49132706 100644 --- a/Tests/MessageKitTests/Controllers Test/MessagesViewControllerTests.swift +++ b/Tests/MessageKitTests/Controllers Test/MessagesViewControllerTests.swift @@ -232,7 +232,6 @@ final class MessagesViewControllerTests: XCTestCase { func testDefaultPropertyValues() { let controller = MessagesViewController() - XCTAssertFalse(controller.scrollsToBottomOnKeyboardBeginsEditing) XCTAssertTrue(controller.canBecomeFirstResponder) XCTAssertFalse(controller.shouldAutorotate) XCTAssertNotNil(controller.inputAccessoryView)