From 782219f3cdc8cac644cc33657813a5f8319dbae7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 4 Mar 2018 10:22:28 +0300 Subject: groups_pms --- Juick/ViewControllers/DialogsViewController.m | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Juick/ViewControllers/DialogsViewController.m (limited to 'Juick/ViewControllers/DialogsViewController.m') 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 -- cgit v1.2.3