Merge branch '3.0.0-beta' of github.com:MessageKit/MessageKit into share_contact

# Conflicts:
#	Example/Sources/Data Generation/SampleData.swift
#	Sources/Views/Cells/AudioMessageCell.swift
This commit is contained in:
Iosif Moldovan
2019-03-12 16:42:05 +02:00
94 changed files with 627 additions and 299 deletions
@@ -25,7 +25,7 @@
import UIKit
import MapKit
import MessageKit
import MessageInputBar
import InputBarAccessoryView
final class AdvancedExampleViewController: ChatViewController {
@@ -100,9 +100,11 @@ final class AdvancedExampleViewController: ChatViewController {
layout?.setMessageIncomingAccessoryViewSize(CGSize(width: 30, height: 30))
layout?.setMessageIncomingAccessoryViewPadding(HorizontalEdgeInsets(left: 8, right: 0))
layout?.setMessageIncomingAccessoryViewPosition(.messageBottom)
layout?.setMessageOutgoingAccessoryViewSize(CGSize(width: 30, height: 30))
layout?.setMessageOutgoingAccessoryViewPadding(HorizontalEdgeInsets(left: 0, right: 8))
layout?.setMessageOutgoingAccessoryViewPosition(.messageBottom)
messagesCollectionView.messagesLayoutDelegate = self
messagesCollectionView.messagesDisplayDelegate = self
}
@@ -133,7 +135,7 @@ final class AdvancedExampleViewController: ChatViewController {
messageInputBar.sendButton.image = #imageLiteral(resourceName: "ic_up")
messageInputBar.sendButton.title = nil
messageInputBar.sendButton.imageView?.layer.cornerRadius = 16
messageInputBar.textViewPadding.right = -38
messageInputBar.middleContentViewPadding.right = -38
let charCountButton = InputBarButtonItem()
.configure {
$0.title = "0/140"
@@ -144,15 +146,15 @@ final class AdvancedExampleViewController: ChatViewController {
}.onTextViewDidChange { (item, textView) in
item.title = "\(textView.text.count)/140"
let isOverLimit = textView.text.count > 140
item.messageInputBar?.shouldManageSendButtonEnabledState = !isOverLimit // Disable automated management when over limit
item.inputBarAccessoryView?.shouldManageSendButtonEnabledState = !isOverLimit // Disable automated management when over limit
if isOverLimit {
item.messageInputBar?.sendButton.isEnabled = false
item.inputBarAccessoryView?.sendButton.isEnabled = false
}
let color = isOverLimit ? .red : UIColor(white: 0.6, alpha: 1)
item.setTitleColor(color, for: .normal)
}
let bottomItems = [makeButton(named: "ic_at"), makeButton(named: "ic_hashtag"), makeButton(named: "ic_library"), .flexibleSpace, charCountButton]
messageInputBar.textViewPadding.bottom = 8
messageInputBar.middleContentViewPadding.bottom = 8
messageInputBar.setStackViewItems(bottomItems, forStack: .bottom, animated: false)
// This just adds some more flare
@@ -176,12 +178,12 @@ final class AdvancedExampleViewController: ChatViewController {
func isPreviousMessageSameSender(at indexPath: IndexPath) -> Bool {
guard indexPath.section - 1 >= 0 else { return false }
return messageList[indexPath.section].sender == messageList[indexPath.section - 1].sender
return messageList[indexPath.section].user == messageList[indexPath.section - 1].user
}
func isNextMessageSameSender(at indexPath: IndexPath) -> Bool {
guard indexPath.section + 1 < messageList.count else { return false }
return messageList[indexPath.section].sender == messageList[indexPath.section + 1].sender
return messageList[indexPath.section].user == messageList[indexPath.section + 1].user
}
func setTypingIndicatorHidden(_ isHidden: Bool, performUpdates updates: (() -> Void)? = nil) {
@@ -205,8 +207,16 @@ final class AdvancedExampleViewController: ChatViewController {
$0.tintColor = .primaryColor
}.onDeselected {
$0.tintColor = UIColor(white: 0.8, alpha: 1)
}.onTouchUpInside { _ in
}.onTouchUpInside {
print("Item Tapped")
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let action = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
actionSheet.addAction(action)
if let popoverPresentationController = actionSheet.popoverPresentationController {
popoverPresentationController.sourceView = $0
popoverPresentationController.sourceRect = $0.frame
}
self.navigationController?.present(actionSheet, animated: true, completion: nil)
}
}
@@ -326,7 +336,8 @@ extension AdvancedExampleViewController: MessagesDisplayDelegate {
func configureAccessoryView(_ accessoryView: UIView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) {
// Cells are reused, so only add a button here once. For real use you would need to
// ensure any subviews are removed if not needed
guard accessoryView.subviews.isEmpty else { return }
accessoryView.subviews.forEach { $0.removeFromSuperview() }
let button = UIButton(type: .infoLight)
button.tintColor = .primaryColor
accessoryView.addSubview(button)
@@ -25,7 +25,6 @@
import UIKit
import MapKit
import MessageKit
import MessageInputBar
final class BasicExampleViewController: ChatViewController {
@@ -24,7 +24,7 @@ SOFTWARE.
import UIKit
import MessageKit
import MessageInputBar
import InputBarAccessoryView
/// A base class for the example controllers
class ChatViewController: MessagesViewController, MessagesDataSource {
@@ -111,7 +111,7 @@ class ChatViewController: MessagesViewController, MessagesDataSource {
func configureMessageInputBar() {
messageInputBar.delegate = self
messageInputBar.inputTextView.tintColor = .primaryColor
messageInputBar.sendButton.tintColor = .primaryColor
messageInputBar.sendButton.setTitleColor(.primaryColor, for: .normal)
}
// MARK: - Helpers
@@ -142,7 +142,7 @@ class ChatViewController: MessagesViewController, MessagesDataSource {
// MARK: - MessagesDataSource
func currentSender() -> Sender {
func currentSender() -> SenderType {
return SampleData.shared.currentSender
}
@@ -278,23 +278,23 @@ extension ChatViewController: MessageLabelDelegate {
// MARK: - MessageInputBarDelegate
extension ChatViewController: MessageInputBarDelegate {
func messageInputBar(_ inputBar: MessageInputBar, didPressSendButtonWith text: String) {
extension ChatViewController: InputBarAccessoryViewDelegate {
func inputBar(_ inputBar: InputBarAccessoryView, didPressSendButtonWith text: String) {
for component in inputBar.inputTextView.components {
let user = SampleData.shared.currentSender
if let str = component as? String {
let message = MockMessage(text: str, sender: currentSender(), messageId: UUID().uuidString, date: Date())
let message = MockMessage(text: str, user: user, messageId: UUID().uuidString, date: Date())
insertMessage(message)
} else if let img = component as? UIImage {
let message = MockMessage(image: img, sender: currentSender(), messageId: UUID().uuidString, date: Date())
let message = MockMessage(image: img, user: user, messageId: UUID().uuidString, date: Date())
insertMessage(message)
}
}
inputBar.inputTextView.text = String()
messagesCollectionView.scrollToBottom(animated: true)
}
}
@@ -24,7 +24,6 @@
import UIKit
import MessageKit
import MessageInputBar
import SafariServices
final internal class LaunchViewController: UITableViewController {
@@ -24,7 +24,6 @@
import UIKit
import MessageKit
import MessageInputBar
final internal class SettingsViewController: UITableViewController {