summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/DialogsViewController.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-04 10:22:28 +0300
committerGravatar Vitaly Takmazov2018-03-04 10:22:28 +0300
commit782219f3cdc8cac644cc33657813a5f8319dbae7 (patch)
tree65591cd2beb07dd6364a78f6e1154798ae00cf0a /Juick/ViewControllers/DialogsViewController.m
parent5d0e97b3c1a1910a036f455b67205bc5eece1c29 (diff)
groups_pms
Diffstat (limited to 'Juick/ViewControllers/DialogsViewController.m')
-rw-r--r--Juick/ViewControllers/DialogsViewController.m57
1 files changed, 57 insertions, 0 deletions
diff --git a/Juick/ViewControllers/DialogsViewController.m b/Juick/ViewControllers/DialogsViewController.m
new file mode 100644
index 0000000..8eea017
--- /dev/null
+++ b/Juick/ViewControllers/DialogsViewController.m
@@ -0,0 +1,57 @@
+//
+// DialogsViewController.m
+// Juick
+//
+// Created by Vitaly Takmazov on 04/03/2018.
+// Copyright © 2018 com.juick. All rights reserved.
+//
+
+#import "DialogsViewController.h"
+#import "ColorScheme.h"
+#import "ConversationCell.h"
+#import "APIClient.h"
+
+@interface DialogsViewController ()
+
+@end
+
+@implementation DialogsViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ [self.view setBackgroundColor:[ColorScheme mainBackground]];
+ [self.tableView registerNib:[UINib nibWithNibName:@"ConversationCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"notificationCell"];
+ self.chats = [NSMutableArray array];
+ [[APIClient sharedClient] fetchChats:^(NSArray *groups, NSError *err) {
+ if (err == nil) {
+ [self.chats addObjectsFromArray:groups];
+ NSMutableArray *indexPaths = [NSMutableArray new];
+ for (NSUInteger index = 0; index < [groups count]; index++) {
+ [indexPaths addObject:[NSIndexPath indexPathForRow:index inSection: 0]];
+ }
+ [self.tableView beginUpdates];
+ [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];
+ [self.tableView endUpdates];
+ }
+ }];
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ return self.chats.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+ ConversationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath];
+ [cell configureWithChat:[self.chats objectAtIndex:indexPath.row]];
+ return cell;
+}
+
+
+@end