summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r--Juick/ViewControllers/DialogsViewController.h15
-rw-r--r--Juick/ViewControllers/DialogsViewController.m57
2 files changed, 72 insertions, 0 deletions
diff --git a/Juick/ViewControllers/DialogsViewController.h b/Juick/ViewControllers/DialogsViewController.h
new file mode 100644
index 0000000..c37f6a6
--- /dev/null
+++ b/Juick/ViewControllers/DialogsViewController.h
@@ -0,0 +1,15 @@
+//
+// DialogsViewController.h
+// Juick
+//
+// Created by Vitaly Takmazov on 04/03/2018.
+// Copyright © 2018 com.juick. All rights reserved.
+//
+
+#import "MessagesViewController.h"
+
+@interface DialogsViewController : UITableViewController
+
+@property(nonatomic, strong) NSMutableArray *chats;
+
+@end
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