-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessageRoomDatasource.swift
72 lines (64 loc) · 3.27 KB
/
MessageRoomDatasource.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// MessageRoomDatasource.swift
// comblie
//
// Created by Cal on 11/16/15.
// Copyright © 2015 Comblie. All rights reserved.
//
import UIKit
class MessageRoomDatasource: NSObject, UITableViewDataSource {
var tableView : UITableView
var items : NSMutableArray
init(tableView : UITableView) {
self.items = ["a","a","a","a","a","a","a","a"]
self.tableView = tableView
self.tableView.registerNib(UINib(nibName: "IncomingMessageCell", bundle: nil), forCellReuseIdentifier: "IncomingMessage")
self.tableView.registerNib(UINib(nibName: "IncomingMessageTwoCell", bundle: nil), forCellReuseIdentifier: "IncomingMessageTwo")
self.tableView.registerNib(UINib(nibName: "OutgoingMessageCell", bundle: nil), forCellReuseIdentifier: "OutgoingMessage")
self.tableView.registerNib(UINib(nibName: "TimeMessageCell", bundle: nil), forCellReuseIdentifier: "TimeMessage")
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.items.count
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var currentCell : UITableViewCell!
// Configure the cell...
if(indexPath.row==0){
// Create first cell
let cell = tableView.dequeueReusableCellWithIdentifier("TimeMessage", forIndexPath: indexPath) as! TimeMessageCellController
cell.timeLabel.text = "YESTERDAY 5:02 PM"
currentCell = cell
} else if(indexPath.row==1){
// Create second cell
let cell = tableView.dequeueReusableCellWithIdentifier("IncomingMessage", forIndexPath: indexPath) as! IncomingMessageCellController
cell.message.text = "Hey, how's it going?"
currentCell = cell
} else if(indexPath.row==2){
// Create second cell
let cell = tableView.dequeueReusableCellWithIdentifier("TimeMessage", forIndexPath: indexPath) as! TimeMessageCellController
cell.timeLabel.text = "TODAY 12:38 PM"
currentCell = cell
}else if(indexPath.row==6){
// Create second cell
let cell = tableView.dequeueReusableCellWithIdentifier("TimeMessage", forIndexPath: indexPath) as! TimeMessageCellController
cell.timeLabel.text = "3:30 PM"
currentCell = cell
}else if(indexPath.row==7){
// Create second cell
let cell = tableView.dequeueReusableCellWithIdentifier("IncomingMessage", forIndexPath: indexPath) as! IncomingMessageCellController
cell.message.text = "Sounds good, I'll see you later then."
currentCell = cell
} else{
// Create all others
let cell = tableView.dequeueReusableCellWithIdentifier("OutgoingMessage", forIndexPath: indexPath) as! OutgoingMessageCellController
cell.message.text = "This is just sample text used as a filler to show what the message box looks like."
currentCell = cell
}
// Configure the cell...
return currentCell
}
}