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 | |
parent | 6499148cb3f62e20534b62c181125ebeacfa3438 (diff) |
WIP
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 49 | ||||
-rw-r--r-- | Juick/ViewControllers/NewPostViewController.h | 3 | ||||
-rw-r--r-- | Juick/ViewControllers/NewPostViewController.m | 21 | ||||
-rw-r--r-- | Juick/ViewControllers/RootNavigationController.h | 13 | ||||
-rw-r--r-- | Juick/ViewControllers/RootNavigationController.m | 24 |
5 files changed, 27 insertions, 83 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; } diff --git a/Juick/ViewControllers/NewPostViewController.h b/Juick/ViewControllers/NewPostViewController.h index ceaca49..3d4ba88 100644 --- a/Juick/ViewControllers/NewPostViewController.h +++ b/Juick/ViewControllers/NewPostViewController.h @@ -9,5 +9,6 @@ #import <UIKit/UIKit.h> @interface NewPostViewController : UIViewController - +@property (weak, nonatomic) IBOutlet UITextView *textView; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint; @end diff --git a/Juick/ViewControllers/NewPostViewController.m b/Juick/ViewControllers/NewPostViewController.m index 318de4e..9643b78 100644 --- a/Juick/ViewControllers/NewPostViewController.m +++ b/Juick/ViewControllers/NewPostViewController.m @@ -12,6 +12,7 @@ @interface NewPostViewController () @property (nonatomic, assign) BOOL didSetupConstraints; +@property (nonatomic, assign) int paddingValue; @end @@ -21,14 +22,17 @@ { [super viewDidLoad]; self.navigationController.visibleViewController.title = @"Post"; - self.view.backgroundColor = [ColorScheme mainBackground]; self.navigationController.visibleViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelCompose)]; self.navigationController.visibleViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd - target:self action:@selector(doneCompose)]; + target:self action:@selector(doneCompose)]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; + [self.textView becomeFirstResponder]; } - (void) cancelCompose { + [self.textView resignFirstResponder]; [self.navigationController.visibleViewController.navigationController popViewControllerAnimated:YES]; } @@ -36,4 +40,17 @@ [self.navigationController.visibleViewController.navigationController popToRootViewControllerAnimated:YES]; } +-(void) keyboardDidShow:(NSNotification *)sender { + CGRect frame = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; + CGRect newFrame = [self.view convertRect:frame fromView:[[UIApplication sharedApplication] delegate].window]; + [self.view layoutIfNeeded]; + [UIView animateWithDuration:[sender.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{ + self.bottomConstraint.constant = newFrame.origin.y - CGRectGetHeight(self.view.frame) + self.paddingValue; + [self.view layoutIfNeeded]; + }]; +} +-(void) keyboardWillHide:(NSNotification *)sender { + self.bottomConstraint.constant = self.paddingValue; + [self.view layoutIfNeeded]; +} @end diff --git a/Juick/ViewControllers/RootNavigationController.h b/Juick/ViewControllers/RootNavigationController.h deleted file mode 100644 index f7f6734..0000000 --- a/Juick/ViewControllers/RootNavigationController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// RootNavigationController.h -// Juick -// -// Created by Vitaly Takmazov on 24/09/2017. -// Copyright © 2017 com.juick. All rights reserved. -// - -#import <UIKit/UIKit.h> - -@interface RootNavigationController : UINavigationController - -@end diff --git a/Juick/ViewControllers/RootNavigationController.m b/Juick/ViewControllers/RootNavigationController.m deleted file mode 100644 index 9be0a5f..0000000 --- a/Juick/ViewControllers/RootNavigationController.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// RootNavigationController.m -// Juick -// -// Created by Vitaly Takmazov on 24/09/2017. -// Copyright © 2017 com.juick. All rights reserved. -// - -#import "RootNavigationController.h" -#import "ColorScheme.h" - -@interface RootNavigationController () - -@end - -@implementation RootNavigationController - -- (void) awakeFromNib { - [super awakeFromNib]; - [self.toolbar setTintColor:[ColorScheme linkColor]]; - [self.visibleViewController setToolbarItems:@[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nearby_icon"] style:UIBarButtonItemStylePlain target:self action:nil],[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"new_chat_icon"] style:UIBarButtonItemStylePlain target:self action:nil],[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"chats_icon"] style:UIBarButtonItemStylePlain target:self action:nil],[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]] animated:YES]; -} - -@end |