mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
Add support for emoji-only messages
Adds a new message type that handles text that doubles the font size and removes the message background to model how iMessage displays emoji-only messages.
This commit is contained in:
@@ -70,7 +70,7 @@ final class SampleData {
|
||||
|
||||
var now = Date()
|
||||
|
||||
let messageTypes = ["Text", "Text", "Text", "AttributedText", "Photo", "Video", "Location"]
|
||||
let messageTypes = ["Text", "Text", "Text", "AttributedText", "Photo", "Video", "Location", "Emoji"]
|
||||
|
||||
let attributes = ["Font1", "Font2", "Font3", "Font4", "Color", "Combo"]
|
||||
|
||||
@@ -83,6 +83,15 @@ final class SampleData {
|
||||
CLLocation(latitude: 39.3218, longitude: -113.3317)
|
||||
]
|
||||
|
||||
let emojis = [
|
||||
"👍",
|
||||
"👋",
|
||||
"👋👋👋",
|
||||
"😱😱",
|
||||
"🎈",
|
||||
"🇧🇷",
|
||||
]
|
||||
|
||||
func attributedString(with text: String) -> NSAttributedString {
|
||||
let nsString = NSString(string: text)
|
||||
var mutableAttributedString = NSMutableAttributedString(string: text)
|
||||
@@ -139,6 +148,7 @@ final class SampleData {
|
||||
let randomNumberImage = Int(arc4random_uniform(UInt32(messageImages.count)))
|
||||
let randomMessageType = Int(arc4random_uniform(UInt32(messageTypes.count)))
|
||||
let randomNumberLocation = Int(arc4random_uniform(UInt32(locations.count)))
|
||||
let randomNumberEmoji = Int(arc4random_uniform(UInt32(emojis.count)))
|
||||
let uniqueID = NSUUID().uuidString
|
||||
let sender = senders[randomNumberSender]
|
||||
let date = dateAddingRandomTime()
|
||||
@@ -157,6 +167,8 @@ final class SampleData {
|
||||
return MockMessage(thumbnail: image, sender: sender, messageId: uniqueID, date: date)
|
||||
case "Location":
|
||||
return MockMessage(location: locations[randomNumberLocation], sender: sender, messageId: uniqueID, date: date)
|
||||
case "Emoji":
|
||||
return MockMessage(emoji: emojis[randomNumberEmoji], sender: sender, messageId: uniqueID, date: date)
|
||||
default:
|
||||
fatalError("Unrecognized mock message type")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user