mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-26 05:05:52 +10:00
show feedConversations in FeedConversationsViewController
This commit is contained in:
@@ -52,9 +52,8 @@ class ConversationsViewController: UIViewController {
|
||||
}
|
||||
|
||||
lazy var conversations: Results<Conversation> = {
|
||||
//return self.realm.objects(Conversation).sorted("updatedUnixTime", ascending: false)
|
||||
// let predicate = NSPredicate(format: "type = %d", ConversationType.OneToOne.rawValue)
|
||||
return self.realm.objects(Conversation).sorted("updatedUnixTime", ascending: false)
|
||||
let predicate = NSPredicate(format: "type = %d", ConversationType.OneToOne.rawValue)
|
||||
return self.realm.objects(Conversation).filter(predicate).sorted("updatedUnixTime", ascending: false)
|
||||
}()
|
||||
|
||||
struct Listener {
|
||||
|
||||
@@ -7,11 +7,19 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RealmSwift
|
||||
|
||||
class FeedConversationsViewController: UIViewController {
|
||||
|
||||
@IBOutlet weak var feedConversationsTableView: UITableView!
|
||||
|
||||
var realm: Realm!
|
||||
|
||||
lazy var feedConversations: Results<Conversation> = {
|
||||
let predicate = NSPredicate(format: "type = %d", ConversationType.Group.rawValue)
|
||||
return self.realm.objects(Conversation).filter(predicate).sorted("updatedUnixTime", ascending: false)
|
||||
}()
|
||||
|
||||
let feedConversationCellID = "FeedConversationCell"
|
||||
|
||||
override func viewDidLoad() {
|
||||
@@ -19,8 +27,11 @@ class FeedConversationsViewController: UIViewController {
|
||||
|
||||
title = "Feeds"
|
||||
|
||||
realm = try! Realm()
|
||||
|
||||
feedConversationsTableView.registerNib(UINib(nibName: feedConversationCellID, bundle: nil), forCellReuseIdentifier: feedConversationCellID)
|
||||
feedConversationsTableView.rowHeight = 80
|
||||
feedConversationsTableView.tableFooterView = UIView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +40,14 @@ class FeedConversationsViewController: UIViewController {
|
||||
extension FeedConversationsViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
|
||||
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return 15
|
||||
return feedConversations.count
|
||||
}
|
||||
|
||||
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier(feedConversationCellID) as! FeedConversationCell
|
||||
if let conversation = feedConversations[safe: indexPath.row] {
|
||||
cell.configureWithConversation(conversation)
|
||||
}
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,5 +24,14 @@ class FeedConversationCell: UITableViewCell {
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
|
||||
|
||||
func configureWithConversation(conversation: Conversation) {
|
||||
|
||||
//self.conversation = conversation
|
||||
|
||||
//countOfUnreadMessages = countOfUnreadMessagesInConversation(conversation)
|
||||
|
||||
nameLabel.text = conversation.withGroup?.withFeed?.body
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user