diff options
author | Vitaly Takmazov | 2017-10-15 23:47:11 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-15 23:47:11 +0300 |
commit | 8ae952ec8df2a713afeaef5960a88888e050c6fc (patch) | |
tree | b7b09deed573336e5d274eed790c30ba57e4a910 /Juick/ViewControllers/MessagesViewController.m | |
parent | 6499148cb3f62e20534b62c181125ebeacfa3438 (diff) |
WIP
Diffstat (limited to 'Juick/ViewControllers/MessagesViewController.m')
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 49 |
1 files changed, 6 insertions, 43 deletions
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index b877cd1..badc4a3 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -7,7 +7,6 @@ // #import "MessagesViewController.h" -@import YYWebImage; #import "MessageCell.h" #import "Message.h" @@ -21,7 +20,7 @@ #import "NSURL+PathParameters.h" -@interface MessagesViewController (); +@interface MessagesViewController () @property(nonatomic, strong) NSMutableArray *messages; @property(nonatomic, assign) Boolean dataLoading; @@ -63,18 +62,16 @@ self.dataLoading = NO; [self.view setBackgroundColor:[ColorScheme mainBackground]]; - self.messages = [NSMutableArray array]; - self.params = [NSMutableDictionary new]; - self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 500.0f; + self.messages = [NSMutableArray array]; + self.params = [NSMutableDictionary new]; self.refreshControl = [UIRefreshControl new]; [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged]; if ([User isAuthenticated]) { [User checkIsValid:^(BOOL success) { if (success) { self.path = [APIClient feedUrl]; - [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeSound|UIUserNotificationTypeBadge) categories:nil]]; [self refreshData]; } else { [User throwUnableToLogin]; @@ -85,36 +82,12 @@ self.path = [APIClient messagesUrl]; [self refreshData]; } - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"profile_icon"] style:UIBarButtonItemStylePlain target:self action:@selector(composePressed)]; - self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"settings_icon"] style:UIBarButtonItemStylePlain target:self action:@selector(composePressed)]; } - (void) composePressed { } -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(contentSizeCategoryChanged:) - name:UIContentSizeCategoryDidChangeNotification - object:nil]; -} - -- (void)viewDidDisappear:(BOOL)animated -{ - [super viewDidDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self - name:UIContentSizeCategoryDidChangeNotification - object:nil]; -} - -- (void)contentSizeCategoryChanged:(NSNotification *)notification -{ - [self.tableView reloadData]; -} - - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } @@ -124,20 +97,10 @@ } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"messageCell" forIndexPath:indexPath]; Message *msg = [self.messages objectAtIndex:indexPath.row]; - cell.layer.borderWidth = 6; - cell.layer.borderColor = [ColorScheme mainBackground].CGColor; - [cell setMessage:msg]; - if ([msg.attach length] > 0) { - [cell.attach yy_setImageWithURL:[NSURL URLWithString:msg.attach] placeholder:[UIImage imageNamed:@"AttachPlaceholder"] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) { - [cell setNeedsUpdateConstraints]; - [cell updateConstraintsIfNeeded]; - }]; - } else { - cell.attach.image = nil; - } - + NSString * cellIdentifier = @"messageCell"; + MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; + [cell configureWithMessage:msg]; return cell; } |