Files
MessageKit/Example/Sources/SampleData.swift
T
MacmeDan 5d79572fd9 Added the Avatar struct which has an image and initials.
Added an `Avatar` property to the `AvatarView`
Replaced the `imageView` in the `MessagesCollectionViewCell` with the `AvatarView`
Moved the `Avatar.playground` to the example project so users can play around and learn it capabilities.
Updated the example project and abstracted the `sampleData` to its own file.
Updated the organization for the project to `MessageKit` instead of `Hex bits`
2017-08-07 17:46:22 -06:00

47 lines
2.4 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// SampleData.swift
// ChatExample
//
// Created by Dan Leonard on 8/7/17.
// Copyright © 2017 MessageKit. All rights reserved.
//
import MessageKit
struct SampleData {
let Dan = Sender(id: "123456", displayName: "Dan Leonard")
let Steven = Sender(id: "654321", displayName: "Steven")
let Jobs = Sender(id: "000001", displayName: "Steve Jobs")
let Cook = Sender(id: "656361", displayName: "Tim Cook")
func getMessages() -> [MockMessage] {
let msg1 = MockMessage(text: "Check out this awesome UI library for Chat", sender: Dan, messageId: UUID().uuidString)
let msg2 = MockMessage(text: "This is insane.", sender: Steven, messageId: UUID().uuidString)
let msg3 = MockMessage(text: "Companies that get confused, that think their goal is revenue or stock price or something. You have to focus on the things that lead to those.", sender: Cook, messageId: UUID().uuidString)
let msg4 = MockMessage(text: "My favorite things in life dont cost any money. Its really clear that the most precious resource we all have is time.", sender: Jobs, messageId: UUID().uuidString)
let msg5 = MockMessage(text: "You know, this iPhone, as a matter of fact, the engine in here is made in America. And not only are the engines in here made in America, but engines are made in America and are exported. The glass on this phone is made in Kentucky. And so we've been working for years on doing more and more in the United States.", sender: Cook, messageId: UUID().uuidString)
let msg6 = MockMessage(text: "I think if you do something and it turns out pretty good, then you should go do something else wonderful, not dwell on it for too long. Just figure out whats next.", sender: Jobs, messageId: UUID().uuidString)
return [msg1, msg2, msg3, msg4, msg5, msg6]
}
func getCurrentSender() -> Sender {
return Dan
}
func getAvatarFor(sender: Sender) -> Avatar {
switch sender {
case Dan:
return Avatar(image: #imageLiteral(resourceName: "Dan-Leonard"), initals: "DL")
case Steven:
return Avatar(initals: "S")
case Jobs:
return Avatar(image: #imageLiteral(resourceName: "Steve-Jobs"), initals: "SJ")
case Cook:
return Avatar(image: #imageLiteral(resourceName: "Tim-Cook"))
default:
return Avatar()
}
}
}